Version Description
- 29 October 2015=
- Changed video image
- Adjust revision times by GMT offset.
- Don't overwrite media queries sub styles, rather just append them.
Download this release
Release Info
Developer | gpriday |
Plugin | SiteOrigin CSS |
Version | 1.0.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.2 to 1.0.3
- css/images/video.jpg +0 -0
- js/css.js +1 -1
- js/css.min.js +1 -79
- js/csslint.min.js +4 -277
- js/editor.min.js +1 -63
- js/inspector.min.js +1 -26
- js/jquery.sizes.min.js +1 -8
- js/specificity.min.js +1 -3
- lib/codemirror/addon/fold/brace-fold.min.js +1 -15
- lib/codemirror/addon/fold/comment-fold.min.js +1 -10
- lib/codemirror/addon/fold/foldcode.min.js +1 -18
- lib/codemirror/addon/fold/foldgutter.min.js +1 -20
- lib/codemirror/addon/fold/indent-fold.min.js +1 -6
- lib/codemirror/addon/fold/markdown-fold.min.js +1 -8
- lib/codemirror/addon/fold/xml-fold.min.js +1 -27
- lib/codemirror/addon/hint/anyword-hint.min.js +1 -6
- lib/codemirror/addon/hint/css-hint.min.js +1 -11
- lib/codemirror/addon/hint/html-hint.min.js +1 -9
- lib/codemirror/addon/hint/javascript-hint.min.js +1 -26
- lib/codemirror/addon/hint/show-hint.min.js +1 -35
- lib/codemirror/addon/hint/sql-hint.min.js +1 -38
- lib/codemirror/addon/hint/xml-hint.min.js +1 -22
- lib/codemirror/addon/lint/coffeescript-lint.min.js +1 -6
- lib/codemirror/addon/lint/css-lint.min.js +1 -6
- lib/codemirror/addon/lint/javascript-lint.min.js +1 -15
- lib/codemirror/addon/lint/json-lint.min.js +1 -7
- lib/codemirror/addon/lint/lint.min.js +1 -34
- lib/codemirror/addon/lint/yaml-lint.min.js +1 -7
- lib/codemirror/addon/merge/merge.min.js +1 -109
- lib/codemirror/lib/codemirror.min.js +5 -1036
- lib/codemirror/mode/css/css.min.js +1 -57
- lib/codemirror/mode/css/less_test.min.js +1 -3
- lib/codemirror/mode/css/scss_test.min.js +1 -3
- lib/codemirror/mode/css/test.min.js +1 -3
- lib/codemirror/mode/sass/sass.min.js +1 -67
- lib/minicolors/jquery.minicolors.min.js +1 -49
- readme.txt +10 -5
- so-css.php +3 -3
- tpl/page.php +2 -7
css/images/video.jpg
CHANGED
Binary file
|
js/css.js
CHANGED
@@ -442,7 +442,7 @@
|
|
442 |
}
|
443 |
}
|
444 |
else {
|
445 |
-
cssObject.subStyles = minimalObject.subStyles; //TODO, make this intelligent too
|
446 |
}
|
447 |
|
448 |
}
|
442 |
}
|
443 |
}
|
444 |
else {
|
445 |
+
cssObject.subStyles = cssObject.subStyles.concat(minimalObject.subStyles); //TODO, make this intelligent too
|
446 |
}
|
447 |
|
448 |
}
|
js/css.min.js
CHANGED
@@ -1,79 +1 @@
|
|
1 |
-
|
2 |
-
(function($){'use strict';var fi=function(){this.cssImportStatements=[];this.cssKeyframeStatements=[];this.cssRegex=new RegExp('([\\s\\S]*?){([\\s\\S]*?)}','gi');this.cssMediaQueryRegex='((@media [\\s\\S]*?){([\\s\\S]*?}\\s*?)})';this.cssKeyframeRegex='((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})';this.combinedCSSRegex='((\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})';this.cssCommentsRegex='(\\/\\*[\\s\\S]*?\\*\\/)';this.cssImportStatementRegex=new RegExp('@import .*?;','gi');};fi.prototype.stripComments=function(cssString){var regex=new RegExp(this.cssCommentsRegex,'gi');return cssString.replace(regex,'');};fi.prototype.parseCSS=function(source){if(source===undefined){return[];}
|
3 |
-
var css=[];while(true){var imports=this.cssImportStatementRegex.exec(source);if(imports!==null){this.cssImportStatements.push(imports[0]);css.push({selector:'@imports',type:'imports',styles:imports[0]});}
|
4 |
-
else{break;}}
|
5 |
-
source=source.replace(this.cssImportStatementRegex,'');var keyframesRegex=new RegExp(this.cssKeyframeRegex,'gi');var arr;while(true){arr=keyframesRegex.exec(source);if(arr===null){break;}
|
6 |
-
css.push({selector:'@keyframes',type:'keyframes',styles:arr[0]});}
|
7 |
-
source=source.replace(keyframesRegex,'');var unified=new RegExp(this.combinedCSSRegex,'gi');while(true){arr=unified.exec(source);if(arr===null){break;}
|
8 |
-
var selector='';if(arr[2]===undefined){selector=arr[5].split('\r\n').join('\n').trim();}
|
9 |
-
else{selector=arr[2].split('\r\n').join('\n').trim();}
|
10 |
-
var commentsRegex=new RegExp(this.cssCommentsRegex,'gi');var comments=commentsRegex.exec(selector);if(comments!==null){selector=selector.replace(commentsRegex,'').trim();}
|
11 |
-
selector=selector.replace(/\n+/,"\n");if(selector.indexOf('@media')!==-1){var cssObject={selector:selector,type:'media',subStyles:this.parseCSS(arr[3]+'\n}')};if(comments!==null){cssObject.comments=comments[0];}
|
12 |
-
css.push(cssObject);}
|
13 |
-
else{var rules=this.parseRules(arr[6]);var style={selector:selector,rules:rules};if(selector==='@font-face'){style.type='font-face';}
|
14 |
-
if(comments!==null){style.comments=comments[0];}
|
15 |
-
css.push(style);}}
|
16 |
-
return css;};fi.prototype.parseRules=function(rules){rules=rules.split('\r\n').join('\n');var ret=[];rules=rules.split(';');for(var i=0;i<rules.length;i++){var line=rules[i];line=line.trim();if(line.indexOf(':')!==-1){line=line.split(':');var cssDirective=line[0].trim();var cssValue=line.slice(1).join(':').trim();ret.push({directive:cssDirective,value:cssValue});}
|
17 |
-
else{if(line.trim().substr(0,7)==='base64,'){ret[ret.length-1].value+=line.trim();}
|
18 |
-
else{if(line.length>0){ret.push({directive:'',value:line,defective:true});}}}}
|
19 |
-
return ret;};fi.prototype.findCorrespondingRule=function(rules,directive,value){if(value===undefined){value=false;}
|
20 |
-
var ret=false;for(var i=0;i<rules.length;i++){if(rules[i].directive==directive){ret=rules[i];if(value===rules[i].value){break;}}}
|
21 |
-
return ret;};fi.prototype.findBySelector=function(cssObjectArray,selector,contains){if(contains===undefined){contains=false;}
|
22 |
-
var found=[];for(var i=0;i<cssObjectArray.length;i++){if(contains===false){if(cssObjectArray[i].selector===selector){found.push(cssObjectArray[i]);}}
|
23 |
-
else{if(cssObjectArray[i].selector.indexOf(selector)!==-1){found.push(cssObjectArray[i]);}}}
|
24 |
-
if(found.length<2){return found;}
|
25 |
-
else{var base=found[0];for(i=1;i<found.length;i++){this.intelligentCSSPush([base],found[i]);}
|
26 |
-
return[base];}};fi.prototype.deleteBySelector=function(cssObjectArray,selector){var ret=[];for(var i=0;i<cssObjectArray.length;i++){if(cssObjectArray[i].selector!==selector){ret.push(cssObjectArray[i]);}}
|
27 |
-
return ret;};fi.prototype.compressCSS=function(cssObjectArray){var compressed=[];var done={};for(var i=0;i<cssObjectArray.length;i++){var obj=cssObjectArray[i];if(done[obj.selector]===true){continue;}
|
28 |
-
var found=this.findBySelector(cssObjectArray,obj.selector);if(found.length!==0){compressed.push(found[0]);done[obj.selector]=true;}}
|
29 |
-
return compressed;};fi.prototype.cssDiff=function(css1,css2){if(css1.selector!==css2.selector){return false;}
|
30 |
-
if((css1.type==='media'||css2.type==='media')){return false;}
|
31 |
-
var diff={selector:css1.selector,rules:[]};var rule1,rule2;for(var i=0;i<css1.rules.length;i++){rule1=css1.rules[i];rule2=this.findCorrespondingRule(css2.rules,rule1.directive,rule1.value);if(rule2===false){diff.rules.push(rule1);}
|
32 |
-
else{if(rule1.value!==rule2.value){diff.rules.push(rule1);}}}
|
33 |
-
for(var ii=0;ii<css2.rules.length;ii++){rule2=css2.rules[ii];rule1=this.findCorrespondingRule(css1.rules,rule2.directive);if(rule1===false){rule2.type='DELETED';diff.rules.push(rule2);}}
|
34 |
-
if(diff.rules.length===0){return false;}
|
35 |
-
return diff;};fi.prototype.intelligentMerge=function(cssObjectArray,newArray,reverse){if(reverse===undefined){reverse=false;}
|
36 |
-
for(var i=0;i<newArray.length;i++){this.intelligentCSSPush(cssObjectArray,newArray[i],reverse);}
|
37 |
-
for(i=0;i<cssObjectArray.length;i++){var cobj=cssObjectArray[i];if(cobj.type==='media'||(cobj.type==='keyframes')){continue;}
|
38 |
-
cobj.rules=this.compactRules(cobj.rules);}};fi.prototype.intelligentCSSPush=function(cssObjectArray,minimalObject,reverse){var pushSelector=minimalObject.selector;var cssObject=false;if(reverse===undefined){reverse=false;}
|
39 |
-
if(reverse===false){for(var i=0;i<cssObjectArray.length;i++){if(cssObjectArray[i].selector===minimalObject.selector){cssObject=cssObjectArray[i];break;}}}
|
40 |
-
else{for(var j=cssObjectArray.length-1;j>-1;j--){if(cssObjectArray[j].selector===minimalObject.selector){cssObject=cssObjectArray[j];break;}}}
|
41 |
-
if(cssObject===false){cssObjectArray.push(minimalObject);}
|
42 |
-
else{if(minimalObject.type!=='media'){for(var ii=0;ii<minimalObject.rules.length;ii++){var rule=minimalObject.rules[ii];var oldRule=this.findCorrespondingRule(cssObject.rules,rule.directive);if(oldRule===false){cssObject.rules.push(rule);}else if(rule.type==='DELETED'){oldRule.type='DELETED';}
|
43 |
-
else{oldRule.value=rule.value;}}}
|
44 |
-
else{cssObject.subStyles=minimalObject.subStyles;}}};fi.prototype.compactRules=function(rules){var newRules=[];for(var i=0;i<rules.length;i++){if(rules[i].type!=='DELETED'){newRules.push(rules[i]);}}
|
45 |
-
return newRules;};fi.prototype.getCSSForEditor=function(cssBase,depth){if(depth===undefined){depth=0;}
|
46 |
-
var ret='';if(cssBase===undefined){cssBase=this.css;}
|
47 |
-
for(var i=0;i<cssBase.length;i++){if(cssBase[i].type==='imports'){ret+=cssBase[i].styles+'\n\n';}}
|
48 |
-
for(i=0;i<cssBase.length;i++){var tmp=cssBase[i];if(tmp.selector===undefined){continue;}
|
49 |
-
var comments="";if(tmp.comments!==undefined){comments=tmp.comments+'\n';}
|
50 |
-
if(tmp.type==='media'){ret+=comments+tmp.selector+'{\n';ret+=this.getCSSForEditor(tmp.subStyles,depth+1);ret+='}\n\n';}
|
51 |
-
else if(tmp.type!=='keyframes'&&tmp.type!=='imports'){ret+=this.getSpaces(depth)+comments+tmp.selector+' {\n';ret+=this.getCSSOfRules(tmp.rules,depth+1);ret+=this.getSpaces(depth)+'}\n\n';}}
|
52 |
-
for(i=0;i<cssBase.length;i++){if(cssBase[i].type==='keyframes'){ret+=cssBase[i].styles+'\n\n';}}
|
53 |
-
return ret;};fi.prototype.getImports=function(cssObjectArray){var imps=[];for(var i=0;i<cssObjectArray.length;i++){if(cssObjectArray[i].type==='imports'){imps.push(cssObjectArray[i].styles);}}
|
54 |
-
return imps;};fi.prototype.getCSSOfRules=function(rules,depth){var ret='';for(var i=0;i<rules.length;i++){if(rules[i]===undefined){continue;}
|
55 |
-
if(rules[i].value===''){continue;}
|
56 |
-
if(rules[i].defective===undefined){ret+=this.getSpaces(depth)+rules[i].directive+': '+rules[i].value+';\n';}
|
57 |
-
else{ret+=this.getSpaces(depth)+rules[i].value+';\n';}}
|
58 |
-
return ret||'\n';};fi.prototype.getSpaces=function(num){var ret='';for(var i=0;i<num*2;i++){ret+=' ';}
|
59 |
-
return ret;};fi.prototype.applyNamespacing=function(css,forcedNamespace){var cssObjectArray=css;var namespaceClass='.'+this.cssPreviewNamespace;if(forcedNamespace!==undefined){namespaceClass=forcedNamespace;}
|
60 |
-
if(typeof css==='string'){cssObjectArray=this.parseCSS(css);}
|
61 |
-
for(var i=0;i<cssObjectArray.length;i++){var obj=cssObjectArray[i];if(obj.selector.indexOf('@font-face')>-1||obj.selector.indexOf('keyframes')>-1||obj.selector.indexOf('@import')>-1||obj.selector.indexOf('.form-all')>-1||obj.selector.indexOf('#stage')>-1){continue;}
|
62 |
-
if(obj.type!=='media'){var selector=obj.selector.split(',');var newSelector=[];for(var j=0;j<selector.length;j++){if(selector[j].indexOf('.supernova')===-1){newSelector.push(namespaceClass+' '+selector[j]);}
|
63 |
-
else{newSelector.push(selector[j]);}}
|
64 |
-
obj.selector=newSelector.join(',');}
|
65 |
-
else{obj.subStyles=this.applyNamespacing(obj.subStyles,forcedNamespace);}}
|
66 |
-
return cssObjectArray;};fi.prototype.clearNamespacing=function(css,returnObj){if(returnObj===undefined){returnObj=false;}
|
67 |
-
var cssObjectArray=css;var namespaceClass='.'+this.cssPreviewNamespace;if(typeof css==='string'){cssObjectArray=this.parseCSS(css);}
|
68 |
-
for(var i=0;i<cssObjectArray.length;i++){var obj=cssObjectArray[i];if(obj.type!=='media'){var selector=obj.selector.split(',');var newSelector=[];for(var j=0;j<selector.length;j++){newSelector.push(selector[j].split(namespaceClass+' ').join(''));}
|
69 |
-
obj.selector=newSelector.join(',');}
|
70 |
-
else{obj.subStyles=this.clearNamespacing(obj.subStyles,true);}}
|
71 |
-
if(returnObj===false){return this.getCSSForEditor(cssObjectArray);}
|
72 |
-
else{return cssObjectArray;}};fi.prototype.createStyleElement=function(id,css,format){if(format===undefined){format=false;}
|
73 |
-
if(this.testMode===false&&format!=='nonamespace'){css=this.applyNamespacing(css);}
|
74 |
-
if(typeof css!=='string'){css=this.getCSSForEditor(css);}
|
75 |
-
if(format===true){css=this.getCSSForEditor(this.parseCSS(css));}
|
76 |
-
if(this.testMode!==false){return this.testMode('create style #'+id,css);}
|
77 |
-
var __el=document.getElementById(id);if(__el){__el.parentNode.removeChild(__el);}
|
78 |
-
var head=document.head||document.getElementsByTagName('head')[0],style=document.createElement('style');style.id=id;style.type='text/css';head.appendChild(style);if(style.styleSheet&&!style.sheet){style.styleSheet.cssText=css;}
|
79 |
-
else{style.appendChild(document.createTextNode(css));}};window.cssjs=fi;})();
|
1 |
+
!function(e){"use strict";var t=function(){this.cssImportStatements=[],this.cssKeyframeStatements=[],this.cssRegex=new RegExp("([\\s\\S]*?){([\\s\\S]*?)}","gi"),this.cssMediaQueryRegex="((@media [\\s\\S]*?){([\\s\\S]*?}\\s*?)})",this.cssKeyframeRegex="((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})",this.combinedCSSRegex="((\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",this.cssCommentsRegex="(\\/\\*[\\s\\S]*?\\*\\/)",this.cssImportStatementRegex=new RegExp("@import .*?;","gi")};t.prototype.stripComments=function(e){var t=new RegExp(this.cssCommentsRegex,"gi");return e.replace(t,"")},t.prototype.parseCSS=function(e){if(void 0===e)return[];for(var t=[];;){var s=this.cssImportStatementRegex.exec(e);if(null===s)break;this.cssImportStatements.push(s[0]),t.push({selector:"@imports",type:"imports",styles:s[0]})}e=e.replace(this.cssImportStatementRegex,"");for(var r,i=new RegExp(this.cssKeyframeRegex,"gi");;){if(r=i.exec(e),null===r)break;t.push({selector:"@keyframes",type:"keyframes",styles:r[0]})}e=e.replace(i,"");for(var n=new RegExp(this.combinedCSSRegex,"gi");;){if(r=n.exec(e),null===r)break;var o="";o=void 0===r[2]?r[5].split("\r\n").join("\n").trim():r[2].split("\r\n").join("\n").trim();var l=new RegExp(this.cssCommentsRegex,"gi"),p=l.exec(o);if(null!==p&&(o=o.replace(l,"").trim()),o=o.replace(/\n+/,"\n"),-1!==o.indexOf("@media")){var a={selector:o,type:"media",subStyles:this.parseCSS(r[3]+"\n}")};null!==p&&(a.comments=p[0]),t.push(a)}else{var c=this.parseRules(r[6]),u={selector:o,rules:c};"@font-face"===o&&(u.type="font-face"),null!==p&&(u.comments=p[0]),t.push(u)}}return t},t.prototype.parseRules=function(e){e=e.split("\r\n").join("\n");var t=[];e=e.split(";");for(var s=0;s<e.length;s++){var r=e[s];if(r=r.trim(),-1!==r.indexOf(":")){r=r.split(":");var i=r[0].trim(),n=r.slice(1).join(":").trim();t.push({directive:i,value:n})}else"base64,"===r.trim().substr(0,7)?t[t.length-1].value+=r.trim():r.length>0&&t.push({directive:"",value:r,defective:!0})}return t},t.prototype.findCorrespondingRule=function(e,t,s){void 0===s&&(s=!1);for(var r=!1,i=0;i<e.length&&(e[i].directive!=t||(r=e[i],s!==e[i].value));i++);return r},t.prototype.findBySelector=function(e,t,s){void 0===s&&(s=!1);for(var r=[],i=0;i<e.length;i++)s===!1?e[i].selector===t&&r.push(e[i]):-1!==e[i].selector.indexOf(t)&&r.push(e[i]);if(r.length<2)return r;var n=r[0];for(i=1;i<r.length;i++)this.intelligentCSSPush([n],r[i]);return[n]},t.prototype.deleteBySelector=function(e,t){for(var s=[],r=0;r<e.length;r++)e[r].selector!==t&&s.push(e[r]);return s},t.prototype.compressCSS=function(e){for(var t=[],s={},r=0;r<e.length;r++){var i=e[r];if(s[i.selector]!==!0){var n=this.findBySelector(e,i.selector);0!==n.length&&(t.push(n[0]),s[i.selector]=!0)}}return t},t.prototype.cssDiff=function(e,t){if(e.selector!==t.selector)return!1;if("media"===e.type||"media"===t.type)return!1;for(var s,r,i={selector:e.selector,rules:[]},n=0;n<e.rules.length;n++)s=e.rules[n],r=this.findCorrespondingRule(t.rules,s.directive,s.value),r===!1?i.rules.push(s):s.value!==r.value&&i.rules.push(s);for(var o=0;o<t.rules.length;o++)r=t.rules[o],s=this.findCorrespondingRule(e.rules,r.directive),s===!1&&(r.type="DELETED",i.rules.push(r));return 0===i.rules.length?!1:i},t.prototype.intelligentMerge=function(e,t,s){void 0===s&&(s=!1);for(var r=0;r<t.length;r++)this.intelligentCSSPush(e,t[r],s);for(r=0;r<e.length;r++){var i=e[r];"media"!==i.type&&"keyframes"!==i.type&&(i.rules=this.compactRules(i.rules))}},t.prototype.intelligentCSSPush=function(e,t,s){var r=(t.selector,!1);if(void 0===s&&(s=!1),s===!1){for(var i=0;i<e.length;i++)if(e[i].selector===t.selector){r=e[i];break}}else for(var n=e.length-1;n>-1;n--)if(e[n].selector===t.selector){r=e[n];break}if(r===!1)e.push(t);else if("media"!==t.type)for(var o=0;o<t.rules.length;o++){var l=t.rules[o],p=this.findCorrespondingRule(r.rules,l.directive);p===!1?r.rules.push(l):"DELETED"===l.type?p.type="DELETED":p.value=l.value}else r.subStyles=r.subStyles.concat(t.subStyles)},t.prototype.compactRules=function(e){for(var t=[],s=0;s<e.length;s++)"DELETED"!==e[s].type&&t.push(e[s]);return t},t.prototype.getCSSForEditor=function(e,t){void 0===t&&(t=0);var s="";void 0===e&&(e=this.css);for(var r=0;r<e.length;r++)"imports"===e[r].type&&(s+=e[r].styles+"\n\n");for(r=0;r<e.length;r++){var i=e[r];if(void 0!==i.selector){var n="";void 0!==i.comments&&(n=i.comments+"\n"),"media"===i.type?(s+=n+i.selector+"{\n",s+=this.getCSSForEditor(i.subStyles,t+1),s+="}\n\n"):"keyframes"!==i.type&&"imports"!==i.type&&(s+=this.getSpaces(t)+n+i.selector+" {\n",s+=this.getCSSOfRules(i.rules,t+1),s+=this.getSpaces(t)+"}\n\n")}}for(r=0;r<e.length;r++)"keyframes"===e[r].type&&(s+=e[r].styles+"\n\n");return s},t.prototype.getImports=function(e){for(var t=[],s=0;s<e.length;s++)"imports"===e[s].type&&t.push(e[s].styles);return t},t.prototype.getCSSOfRules=function(e,t){for(var s="",r=0;r<e.length;r++)void 0!==e[r]&&""!==e[r].value&&(s+=void 0===e[r].defective?this.getSpaces(t)+e[r].directive+": "+e[r].value+";\n":this.getSpaces(t)+e[r].value+";\n");return s||"\n"},t.prototype.getSpaces=function(e){for(var t="",s=0;2*e>s;s++)t+=" ";return t},t.prototype.applyNamespacing=function(e,t){var s=e,r="."+this.cssPreviewNamespace;void 0!==t&&(r=t),"string"==typeof e&&(s=this.parseCSS(e));for(var i=0;i<s.length;i++){var n=s[i];if(!(n.selector.indexOf("@font-face")>-1||n.selector.indexOf("keyframes")>-1||n.selector.indexOf("@import")>-1||n.selector.indexOf(".form-all")>-1||n.selector.indexOf("#stage")>-1))if("media"!==n.type){for(var o=n.selector.split(","),l=[],p=0;p<o.length;p++)-1===o[p].indexOf(".supernova")?l.push(r+" "+o[p]):l.push(o[p]);n.selector=l.join(",")}else n.subStyles=this.applyNamespacing(n.subStyles,t)}return s},t.prototype.clearNamespacing=function(e,t){void 0===t&&(t=!1);var s=e,r="."+this.cssPreviewNamespace;"string"==typeof e&&(s=this.parseCSS(e));for(var i=0;i<s.length;i++){var n=s[i];if("media"!==n.type){for(var o=n.selector.split(","),l=[],p=0;p<o.length;p++)l.push(o[p].split(r+" ").join(""));n.selector=l.join(",")}else n.subStyles=this.clearNamespacing(n.subStyles,!0)}return t===!1?this.getCSSForEditor(s):s},t.prototype.createStyleElement=function(e,t,s){if(void 0===s&&(s=!1),this.testMode===!1&&"nonamespace"!==s&&(t=this.applyNamespacing(t)),"string"!=typeof t&&(t=this.getCSSForEditor(t)),s===!0&&(t=this.getCSSForEditor(this.parseCSS(t))),this.testMode!==!1)return this.testMode("create style #"+e,t);var r=document.getElementById(e);r&&r.parentNode.removeChild(r);var i=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.id=e,n.type="text/css",i.appendChild(n),n.styleSheet&&!n.sheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))},window.cssjs=t}();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/csslint.min.js
CHANGED
@@ -1,277 +1,4 @@
|
|
1 |
-
|
2 |
-
var exports=exports||{};var CSSLint=(function(){var parserlib={};(function(){function EventTarget(){this._listeners={};}
|
3 |
-
EventTarget.prototype={constructor:EventTarget,addListener:function(type,listener){if(!this._listeners[type]){this._listeners[type]=[];}
|
4 |
-
this.
|
5 |
-
if(typeof event.target!="undefined"){event.target=this;}
|
6 |
-
if(typeof event.type=="undefined"){throw new Error("Event object missing 'type' property.");}
|
7 |
-
if(this._listeners[event.type]){var listeners=this._listeners[event.type].concat();for(var i=0,len=listeners.length;i<len;i++){listeners[i].call(this,event);}}},removeListener:function(type,listener){if(this._listeners[type]){var listeners=this._listeners[type];for(var i=0,len=listeners.length;i<len;i++){if(listeners[i]===listener){listeners.splice(i,1);break;}}}}};function StringReader(text){this._input=text.replace(/\n\r?/g,"\n");this._line=1;this._col=1;this._cursor=0;}
|
8 |
-
StringReader.prototype={constructor:StringReader,getCol:function(){return this._col;},getLine:function(){return this._line;},eof:function(){return(this._cursor==this._input.length);},peek:function(count){var c=null;count=(typeof count=="undefined"?1:count);if(this._cursor<this._input.length){c=this._input.charAt(this._cursor+count-1);}
|
9 |
-
return c;},read:function(){var c=null;if(this._cursor<this._input.length){if(this._input.charAt(this._cursor)=="\n"){this._line++;this._col=1;}else{this._col++;}
|
10 |
-
c=this._input.charAt(this._cursor++);}
|
11 |
-
return c;},mark:function(){this._bookmark={cursor:this._cursor,line:this._line,col:this._col};},reset:function(){if(this._bookmark){this._cursor=this._bookmark.cursor;this._line=this._bookmark.line;this._col=this._bookmark.col;delete this._bookmark;}},readTo:function(pattern){var buffer="",c;while(buffer.length<pattern.length||buffer.lastIndexOf(pattern)!=buffer.length-pattern.length){c=this.read();if(c){buffer+=c;}else{throw new Error("Expected \""+pattern+"\" at line "+this._line+", col "+this._col+".");}}
|
12 |
-
return buffer;},readWhile:function(filter){var buffer="",c=this.read();while(c!==null&&filter(c)){buffer+=c;c=this.read();}
|
13 |
-
return buffer;},readMatch:function(matcher){var source=this._input.substring(this._cursor),value=null;if(typeof matcher=="string"){if(source.indexOf(matcher)===0){value=this.readCount(matcher.length);}}else if(matcher instanceof RegExp){if(matcher.test(source)){value=this.readCount(RegExp.lastMatch.length);}}
|
14 |
-
return value;},readCount:function(count){var buffer="";while(count--){buffer+=this.read();}
|
15 |
-
return buffer;}};function SyntaxError(message,line,col){this.col=col;this.line=line;this.message=message;}
|
16 |
-
SyntaxError.prototype=new Error();function SyntaxUnit(text,line,col,type){this.col=col;this.line=line;this.text=text;this.type=type;}
|
17 |
-
SyntaxUnit.fromToken=function(token){return new SyntaxUnit(token.value,token.startLine,token.startCol);};SyntaxUnit.prototype={constructor:SyntaxUnit,valueOf:function(){return this.toString();},toString:function(){return this.text;}};function TokenStreamBase(input,tokenData){this._reader=input?new StringReader(input.toString()):null;this._token=null;this._tokenData=tokenData;this._lt=[];this._ltIndex=0;this._ltIndexCache=[];}
|
18 |
-
TokenStreamBase.createTokenData=function(tokens){var nameMap=[],typeMap={},tokenData=tokens.concat([]),i=0,len=tokenData.length+1;tokenData.UNKNOWN=-1;tokenData.unshift({name:"EOF"});for(;i<len;i++){nameMap.push(tokenData[i].name);tokenData[tokenData[i].name]=i;if(tokenData[i].text){typeMap[tokenData[i].text]=i;}}
|
19 |
-
tokenData.name=function(tt){return nameMap[tt];};tokenData.type=function(c){return typeMap[c];};return tokenData;};TokenStreamBase.prototype={constructor:TokenStreamBase,match:function(tokenTypes,channel){if(!(tokenTypes instanceof Array)){tokenTypes=[tokenTypes];}
|
20 |
-
var tt=this.get(channel),i=0,len=tokenTypes.length;while(i<len){if(tt==tokenTypes[i++]){return true;}}
|
21 |
-
this.unget();return false;},mustMatch:function(tokenTypes,channel){var token;if(!(tokenTypes instanceof Array)){tokenTypes=[tokenTypes];}
|
22 |
-
if(!this.match.apply(this,arguments)){token=this.LT(1);throw new SyntaxError("Expected "+this._tokenData[tokenTypes[0]].name+" at line "+token.startLine+", col "+token.startCol+".",token.startLine,token.startCol);}},advance:function(tokenTypes,channel){while(this.LA(0)!==0&&!this.match(tokenTypes,channel)){this.get();}
|
23 |
-
return this.LA(0);},get:function(channel){var tokenInfo=this._tokenData,reader=this._reader,value,i=0,len=tokenInfo.length,found=false,token,info;if(this._lt.length&&this._ltIndex>=0&&this._ltIndex<this._lt.length){i++;this._token=this._lt[this._ltIndex++];info=tokenInfo[this._token.type];while((info.channel!==undefined&&channel!==info.channel)&&this._ltIndex<this._lt.length){this._token=this._lt[this._ltIndex++];info=tokenInfo[this._token.type];i++;}
|
24 |
-
if((info.channel===undefined||channel===info.channel)&&this._ltIndex<=this._lt.length){this._ltIndexCache.push(i);return this._token.type;}}
|
25 |
-
token=this._getToken();if(token.type>-1&&!tokenInfo[token.type].hide){token.channel=tokenInfo[token.type].channel;this._token=token;this._lt.push(token);this._ltIndexCache.push(this._lt.length-this._ltIndex+i);if(this._lt.length>5){this._lt.shift();}
|
26 |
-
if(this._ltIndexCache.length>5){this._ltIndexCache.shift();}
|
27 |
-
this._ltIndex=this._lt.length;}
|
28 |
-
info=tokenInfo[token.type];if(info&&(info.hide||(info.channel!==undefined&&channel!==info.channel))){return this.get(channel);}else{return token.type;}},LA:function(index){var total=index,tt;if(index>0){if(index>5){throw new Error("Too much lookahead.");}
|
29 |
-
while(total){tt=this.get();total--;}
|
30 |
-
while(total<index){this.unget();total++;}}else if(index<0){if(this._lt[this._ltIndex+index]){tt=this._lt[this._ltIndex+index].type;}else{throw new Error("Too much lookbehind.");}}else{tt=this._token.type;}
|
31 |
-
return tt;},LT:function(index){this.LA(index);return this._lt[this._ltIndex+index-1];},peek:function(){return this.LA(1);},token:function(){return this._token;},tokenName:function(tokenType){if(tokenType<0||tokenType>this._tokenData.length){return"UNKNOWN_TOKEN";}else{return this._tokenData[tokenType].name;}},tokenType:function(tokenName){return this._tokenData[tokenName]||-1;},unget:function(){if(this._ltIndexCache.length){this._ltIndex-=this._ltIndexCache.pop();this._token=this._lt[this._ltIndex-1];}else{throw new Error("Too much lookahead.");}}};parserlib.util={StringReader:StringReader,SyntaxError:SyntaxError,SyntaxUnit:SyntaxUnit,EventTarget:EventTarget,TokenStreamBase:TokenStreamBase};})();(function(){var EventTarget=parserlib.util.EventTarget,TokenStreamBase=parserlib.util.TokenStreamBase,StringReader=parserlib.util.StringReader,SyntaxError=parserlib.util.SyntaxError,SyntaxUnit=parserlib.util.SyntaxUnit;var Colors={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",activeBorder:"Active window border.",activecaption:"Active window caption.",appworkspace:"Background color of multiple document interface.",background:"Desktop background.",buttonface:"The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.",buttonhighlight:"The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",buttonshadow:"The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",buttontext:"Text on push buttons.",captiontext:"Text in caption, size box, and scrollbar arrow box.",graytext:"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",highlight:"Item(s) selected in a control.",highlighttext:"Text of item(s) selected in a control.",inactiveborder:"Inactive window border.",inactivecaption:"Inactive window caption.",inactivecaptiontext:"Color of text in an inactive caption.",infobackground:"Background color for tooltip controls.",infotext:"Text color for tooltip controls.",menu:"Menu background.",menutext:"Text in menus.",scrollbar:"Scroll bar gray area.",threeddarkshadow:"The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedface:"The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedhighlight:"The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedlightshadow:"The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedshadow:"The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",window:"Window background.",windowframe:"Window frame.",windowtext:"Text in windows."};function Combinator(text,line,col){SyntaxUnit.call(this,text,line,col,Parser.COMBINATOR_TYPE);this.type="unknown";if(/^\s+$/.test(text)){this.type="descendant";}else if(text==">"){this.type="child";}else if(text=="+"){this.type="adjacent-sibling";}else if(text=="~"){this.type="sibling";}}
|
32 |
-
Combinator.prototype=new SyntaxUnit();Combinator.prototype.constructor=Combinator;function MediaFeature(name,value){SyntaxUnit.call(this,"("+name+(value!==null?":"+value:"")+")",name.startLine,name.startCol,Parser.MEDIA_FEATURE_TYPE);this.name=name;this.value=value;}
|
33 |
-
MediaFeature.prototype=new SyntaxUnit();MediaFeature.prototype.constructor=MediaFeature;function MediaQuery(modifier,mediaType,features,line,col){SyntaxUnit.call(this,(modifier?modifier+" ":"")+(mediaType?mediaType:"")+(mediaType&&features.length>0?" and ":"")+features.join(" and "),line,col,Parser.MEDIA_QUERY_TYPE);this.modifier=modifier;this.mediaType=mediaType;this.features=features;}
|
34 |
-
MediaQuery.prototype=new SyntaxUnit();MediaQuery.prototype.constructor=MediaQuery;function Parser(options){EventTarget.call(this);this.options=options||{};this._tokenStream=null;}
|
35 |
-
Parser.DEFAULT_TYPE=0;Parser.COMBINATOR_TYPE=1;Parser.MEDIA_FEATURE_TYPE=2;Parser.MEDIA_QUERY_TYPE=3;Parser.PROPERTY_NAME_TYPE=4;Parser.PROPERTY_VALUE_TYPE=5;Parser.PROPERTY_VALUE_PART_TYPE=6;Parser.SELECTOR_TYPE=7;Parser.SELECTOR_PART_TYPE=8;Parser.SELECTOR_SUB_PART_TYPE=9;Parser.prototype=function(){var proto=new EventTarget(),prop,additions={constructor:Parser,DEFAULT_TYPE:0,COMBINATOR_TYPE:1,MEDIA_FEATURE_TYPE:2,MEDIA_QUERY_TYPE:3,PROPERTY_NAME_TYPE:4,PROPERTY_VALUE_TYPE:5,PROPERTY_VALUE_PART_TYPE:6,SELECTOR_TYPE:7,SELECTOR_PART_TYPE:8,SELECTOR_SUB_PART_TYPE:9,_stylesheet:function(){var tokenStream=this._tokenStream,charset=null,count,token,tt;this.fire("startstylesheet");this._charset();this._skipCruft();while(tokenStream.peek()==Tokens.IMPORT_SYM){this._import();this._skipCruft();}
|
36 |
-
while(tokenStream.peek()==Tokens.NAMESPACE_SYM){this._namespace();this._skipCruft();}
|
37 |
-
tt=tokenStream.peek();while(tt>Tokens.EOF){try{switch(tt){case Tokens.MEDIA_SYM:this._media();this._skipCruft();break;case Tokens.PAGE_SYM:this._page();this._skipCruft();break;case Tokens.FONT_FACE_SYM:this._font_face();this._skipCruft();break;case Tokens.KEYFRAMES_SYM:this._keyframes();this._skipCruft();break;case Tokens.VIEWPORT_SYM:this._viewport();this._skipCruft();break;case Tokens.UNKNOWN_SYM:tokenStream.get();if(!this.options.strict){this.fire({type:"error",error:null,message:"Unknown @ rule: "+tokenStream.LT(0).value+".",line:tokenStream.LT(0).startLine,col:tokenStream.LT(0).startCol});count=0;while(tokenStream.advance([Tokens.LBRACE,Tokens.RBRACE])==Tokens.LBRACE){count++;}
|
38 |
-
while(count){tokenStream.advance([Tokens.RBRACE]);count--;}}else{throw new SyntaxError("Unknown @ rule.",tokenStream.LT(0).startLine,tokenStream.LT(0).startCol);}
|
39 |
-
break;case Tokens.S:this._readWhitespace();break;default:if(!this._ruleset()){switch(tt){case Tokens.CHARSET_SYM:token=tokenStream.LT(1);this._charset(false);throw new SyntaxError("@charset not allowed here.",token.startLine,token.startCol);case Tokens.IMPORT_SYM:token=tokenStream.LT(1);this._import(false);throw new SyntaxError("@import not allowed here.",token.startLine,token.startCol);case Tokens.NAMESPACE_SYM:token=tokenStream.LT(1);this._namespace(false);throw new SyntaxError("@namespace not allowed here.",token.startLine,token.startCol);default:tokenStream.get();this._unexpectedToken(tokenStream.token());}}}}catch(ex){if(ex instanceof SyntaxError&&!this.options.strict){this.fire({type:"error",error:ex,message:ex.message,line:ex.line,col:ex.col});}else{throw ex;}}
|
40 |
-
tt=tokenStream.peek();}
|
41 |
-
if(tt!=Tokens.EOF){this._unexpectedToken(tokenStream.token());}
|
42 |
-
this.fire("endstylesheet");},_charset:function(emit){var tokenStream=this._tokenStream,charset,token,line,col;if(tokenStream.match(Tokens.CHARSET_SYM)){line=tokenStream.token().startLine;col=tokenStream.token().startCol;this._readWhitespace();tokenStream.mustMatch(Tokens.STRING);token=tokenStream.token();charset=token.value;this._readWhitespace();tokenStream.mustMatch(Tokens.SEMICOLON);if(emit!==false){this.fire({type:"charset",charset:charset,line:line,col:col});}}},_import:function(emit){var tokenStream=this._tokenStream,tt,uri,importToken,mediaList=[];tokenStream.mustMatch(Tokens.IMPORT_SYM);importToken=tokenStream.token();this._readWhitespace();tokenStream.mustMatch([Tokens.STRING,Tokens.URI]);uri=tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/,"$1");this._readWhitespace();mediaList=this._media_query_list();tokenStream.mustMatch(Tokens.SEMICOLON);this._readWhitespace();if(emit!==false){this.fire({type:"import",uri:uri,media:mediaList,line:importToken.startLine,col:importToken.startCol});}},_namespace:function(emit){var tokenStream=this._tokenStream,line,col,prefix,uri;tokenStream.mustMatch(Tokens.NAMESPACE_SYM);line=tokenStream.token().startLine;col=tokenStream.token().startCol;this._readWhitespace();if(tokenStream.match(Tokens.IDENT)){prefix=tokenStream.token().value;this._readWhitespace();}
|
43 |
-
tokenStream.mustMatch([Tokens.STRING,Tokens.URI]);uri=tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/,"$1");this._readWhitespace();tokenStream.mustMatch(Tokens.SEMICOLON);this._readWhitespace();if(emit!==false){this.fire({type:"namespace",prefix:prefix,uri:uri,line:line,col:col});}},_media:function(){var tokenStream=this._tokenStream,line,col,mediaList;tokenStream.mustMatch(Tokens.MEDIA_SYM);line=tokenStream.token().startLine;col=tokenStream.token().startCol;this._readWhitespace();mediaList=this._media_query_list();tokenStream.mustMatch(Tokens.LBRACE);this._readWhitespace();this.fire({type:"startmedia",media:mediaList,line:line,col:col});while(true){if(tokenStream.peek()==Tokens.PAGE_SYM){this._page();}else if(tokenStream.peek()==Tokens.FONT_FACE_SYM){this._font_face();}else if(!this._ruleset()){break;}}
|
44 |
-
tokenStream.mustMatch(Tokens.RBRACE);this._readWhitespace();this.fire({type:"endmedia",media:mediaList,line:line,col:col});},_media_query_list:function(){var tokenStream=this._tokenStream,mediaList=[];this._readWhitespace();if(tokenStream.peek()==Tokens.IDENT||tokenStream.peek()==Tokens.LPAREN){mediaList.push(this._media_query());}
|
45 |
-
while(tokenStream.match(Tokens.COMMA)){this._readWhitespace();mediaList.push(this._media_query());}
|
46 |
-
return mediaList;},_media_query:function(){var tokenStream=this._tokenStream,type=null,ident=null,token=null,expressions=[];if(tokenStream.match(Tokens.IDENT)){ident=tokenStream.token().value.toLowerCase();if(ident!="only"&&ident!="not"){tokenStream.unget();ident=null;}else{token=tokenStream.token();}}
|
47 |
-
this._readWhitespace();if(tokenStream.peek()==Tokens.IDENT){type=this._media_type();if(token===null){token=tokenStream.token();}}else if(tokenStream.peek()==Tokens.LPAREN){if(token===null){token=tokenStream.LT(1);}
|
48 |
-
expressions.push(this._media_expression());}
|
49 |
-
if(type===null&&expressions.length===0){return null;}else{this._readWhitespace();while(tokenStream.match(Tokens.IDENT)){if(tokenStream.token().value.toLowerCase()!="and"){this._unexpectedToken(tokenStream.token());}
|
50 |
-
this._readWhitespace();expressions.push(this._media_expression());}}
|
51 |
-
return new MediaQuery(ident,type,expressions,token.startLine,token.startCol);},_media_type:function(){return this._media_feature();},_media_expression:function(){var tokenStream=this._tokenStream,feature=null,token,expression=null;tokenStream.mustMatch(Tokens.LPAREN);feature=this._media_feature();this._readWhitespace();if(tokenStream.match(Tokens.COLON)){this._readWhitespace();token=tokenStream.LT(1);expression=this._expression();}
|
52 |
-
tokenStream.mustMatch(Tokens.RPAREN);this._readWhitespace();return new MediaFeature(feature,(expression?new SyntaxUnit(expression,token.startLine,token.startCol):null));},_media_feature:function(){var tokenStream=this._tokenStream;tokenStream.mustMatch(Tokens.IDENT);return SyntaxUnit.fromToken(tokenStream.token());},_page:function(){var tokenStream=this._tokenStream,line,col,identifier=null,pseudoPage=null;tokenStream.mustMatch(Tokens.PAGE_SYM);line=tokenStream.token().startLine;col=tokenStream.token().startCol;this._readWhitespace();if(tokenStream.match(Tokens.IDENT)){identifier=tokenStream.token().value;if(identifier.toLowerCase()==="auto"){this._unexpectedToken(tokenStream.token());}}
|
53 |
-
if(tokenStream.peek()==Tokens.COLON){pseudoPage=this._pseudo_page();}
|
54 |
-
this._readWhitespace();this.fire({type:"startpage",id:identifier,pseudo:pseudoPage,line:line,col:col});this._readDeclarations(true,true);this.fire({type:"endpage",id:identifier,pseudo:pseudoPage,line:line,col:col});},_margin:function(){var tokenStream=this._tokenStream,line,col,marginSym=this._margin_sym();if(marginSym){line=tokenStream.token().startLine;col=tokenStream.token().startCol;this.fire({type:"startpagemargin",margin:marginSym,line:line,col:col});this._readDeclarations(true);this.fire({type:"endpagemargin",margin:marginSym,line:line,col:col});return true;}else{return false;}},_margin_sym:function(){var tokenStream=this._tokenStream;if(tokenStream.match([Tokens.TOPLEFTCORNER_SYM,Tokens.TOPLEFT_SYM,Tokens.TOPCENTER_SYM,Tokens.TOPRIGHT_SYM,Tokens.TOPRIGHTCORNER_SYM,Tokens.BOTTOMLEFTCORNER_SYM,Tokens.BOTTOMLEFT_SYM,Tokens.BOTTOMCENTER_SYM,Tokens.BOTTOMRIGHT_SYM,Tokens.BOTTOMRIGHTCORNER_SYM,Tokens.LEFTTOP_SYM,Tokens.LEFTMIDDLE_SYM,Tokens.LEFTBOTTOM_SYM,Tokens.RIGHTTOP_SYM,Tokens.RIGHTMIDDLE_SYM,Tokens.RIGHTBOTTOM_SYM]))
|
55 |
-
{return SyntaxUnit.fromToken(tokenStream.token());}else{return null;}},_pseudo_page:function(){var tokenStream=this._tokenStream;tokenStream.mustMatch(Tokens.COLON);tokenStream.mustMatch(Tokens.IDENT);return tokenStream.token().value;},_font_face:function(){var tokenStream=this._tokenStream,line,col;tokenStream.mustMatch(Tokens.FONT_FACE_SYM);line=tokenStream.token().startLine;col=tokenStream.token().startCol;this._readWhitespace();this.fire({type:"startfontface",line:line,col:col});this._readDeclarations(true);this.fire({type:"endfontface",line:line,col:col});},_viewport:function(){var tokenStream=this._tokenStream,line,col;tokenStream.mustMatch(Tokens.VIEWPORT_SYM);line=tokenStream.token().startLine;col=tokenStream.token().startCol;this._readWhitespace();this.fire({type:"startviewport",line:line,col:col});this._readDeclarations(true);this.fire({type:"endviewport",line:line,col:col});},_operator:function(inFunction){var tokenStream=this._tokenStream,token=null;if(tokenStream.match([Tokens.SLASH,Tokens.COMMA])||(inFunction&&tokenStream.match([Tokens.PLUS,Tokens.STAR,Tokens.MINUS]))){token=tokenStream.token();this._readWhitespace();}
|
56 |
-
return token?PropertyValuePart.fromToken(token):null;},_combinator:function(){var tokenStream=this._tokenStream,value=null,token;if(tokenStream.match([Tokens.PLUS,Tokens.GREATER,Tokens.TILDE])){token=tokenStream.token();value=new Combinator(token.value,token.startLine,token.startCol);this._readWhitespace();}
|
57 |
-
return value;},_unary_operator:function(){var tokenStream=this._tokenStream;if(tokenStream.match([Tokens.MINUS,Tokens.PLUS])){return tokenStream.token().value;}else{return null;}},_property:function(){var tokenStream=this._tokenStream,value=null,hack=null,tokenValue,token,line,col;if(tokenStream.peek()==Tokens.STAR&&this.options.starHack){tokenStream.get();token=tokenStream.token();hack=token.value;line=token.startLine;col=token.startCol;}
|
58 |
-
if(tokenStream.match(Tokens.IDENT)){token=tokenStream.token();tokenValue=token.value;if(tokenValue.charAt(0)=="_"&&this.options.underscoreHack){hack="_";tokenValue=tokenValue.substring(1);}
|
59 |
-
value=new PropertyName(tokenValue,hack,(line||token.startLine),(col||token.startCol));this._readWhitespace();}
|
60 |
-
return value;},_ruleset:function(){var tokenStream=this._tokenStream,tt,selectors;try{selectors=this._selectors_group();}catch(ex){if(ex instanceof SyntaxError&&!this.options.strict){this.fire({type:"error",error:ex,message:ex.message,line:ex.line,col:ex.col});tt=tokenStream.advance([Tokens.RBRACE]);if(tt==Tokens.RBRACE){}else{throw ex;}}else{throw ex;}
|
61 |
-
return true;}
|
62 |
-
if(selectors){this.fire({type:"startrule",selectors:selectors,line:selectors[0].line,col:selectors[0].col});this._readDeclarations(true);this.fire({type:"endrule",selectors:selectors,line:selectors[0].line,col:selectors[0].col});}
|
63 |
-
return selectors;},_selectors_group:function(){var tokenStream=this._tokenStream,selectors=[],selector;selector=this._selector();if(selector!==null){selectors.push(selector);while(tokenStream.match(Tokens.COMMA)){this._readWhitespace();selector=this._selector();if(selector!==null){selectors.push(selector);}else{this._unexpectedToken(tokenStream.LT(1));}}}
|
64 |
-
return selectors.length?selectors:null;},_selector:function(){var tokenStream=this._tokenStream,selector=[],nextSelector=null,combinator=null,ws=null;nextSelector=this._simple_selector_sequence();if(nextSelector===null){return null;}
|
65 |
-
selector.push(nextSelector);do{combinator=this._combinator();if(combinator!==null){selector.push(combinator);nextSelector=this._simple_selector_sequence();if(nextSelector===null){this._unexpectedToken(tokenStream.LT(1));}else{selector.push(nextSelector);}}else{if(this._readWhitespace()){ws=new Combinator(tokenStream.token().value,tokenStream.token().startLine,tokenStream.token().startCol);combinator=this._combinator();nextSelector=this._simple_selector_sequence();if(nextSelector===null){if(combinator!==null){this._unexpectedToken(tokenStream.LT(1));}}else{if(combinator!==null){selector.push(combinator);}else{selector.push(ws);}
|
66 |
-
selector.push(nextSelector);}}else{break;}}}while(true);return new Selector(selector,selector[0].line,selector[0].col);},_simple_selector_sequence:function(){var tokenStream=this._tokenStream,elementName=null,modifiers=[],selectorText="",components=[function(){return tokenStream.match(Tokens.HASH)?new SelectorSubPart(tokenStream.token().value,"id",tokenStream.token().startLine,tokenStream.token().startCol):null;},this._class,this._attrib,this._pseudo,this._negation],i=0,len=components.length,component=null,found=false,line,col;line=tokenStream.LT(1).startLine;col=tokenStream.LT(1).startCol;elementName=this._type_selector();if(!elementName){elementName=this._universal();}
|
67 |
-
if(elementName!==null){selectorText+=elementName;}
|
68 |
-
while(true){if(tokenStream.peek()===Tokens.S){break;}
|
69 |
-
while(i<len&&component===null){component=components[i++].call(this);}
|
70 |
-
if(component===null){if(selectorText===""){return null;}else{break;}}else{i=0;modifiers.push(component);selectorText+=component.toString();component=null;}}
|
71 |
-
return selectorText!==""?new SelectorPart(elementName,modifiers,selectorText,line,col):null;},_type_selector:function(){var tokenStream=this._tokenStream,ns=this._namespace_prefix(),elementName=this._element_name();if(!elementName){if(ns){tokenStream.unget();if(ns.length>1){tokenStream.unget();}}
|
72 |
-
return null;}else{if(ns){elementName.text=ns+elementName.text;elementName.col-=ns.length;}
|
73 |
-
return elementName;}},_class:function(){var tokenStream=this._tokenStream,token;if(tokenStream.match(Tokens.DOT)){tokenStream.mustMatch(Tokens.IDENT);token=tokenStream.token();return new SelectorSubPart("."+token.value,"class",token.startLine,token.startCol-1);}else{return null;}},_element_name:function(){var tokenStream=this._tokenStream,token;if(tokenStream.match(Tokens.IDENT)){token=tokenStream.token();return new SelectorSubPart(token.value,"elementName",token.startLine,token.startCol);}else{return null;}},_namespace_prefix:function(){var tokenStream=this._tokenStream,value="";if(tokenStream.LA(1)===Tokens.PIPE||tokenStream.LA(2)===Tokens.PIPE){if(tokenStream.match([Tokens.IDENT,Tokens.STAR])){value+=tokenStream.token().value;}
|
74 |
-
tokenStream.mustMatch(Tokens.PIPE);value+="|";}
|
75 |
-
return value.length?value:null;},_universal:function(){var tokenStream=this._tokenStream,value="",ns;ns=this._namespace_prefix();if(ns){value+=ns;}
|
76 |
-
if(tokenStream.match(Tokens.STAR)){value+="*";}
|
77 |
-
return value.length?value:null;},_attrib:function(){var tokenStream=this._tokenStream,value=null,ns,token;if(tokenStream.match(Tokens.LBRACKET)){token=tokenStream.token();value=token.value;value+=this._readWhitespace();ns=this._namespace_prefix();if(ns){value+=ns;}
|
78 |
-
tokenStream.mustMatch(Tokens.IDENT);value+=tokenStream.token().value;value+=this._readWhitespace();if(tokenStream.match([Tokens.PREFIXMATCH,Tokens.SUFFIXMATCH,Tokens.SUBSTRINGMATCH,Tokens.EQUALS,Tokens.INCLUDES,Tokens.DASHMATCH])){value+=tokenStream.token().value;value+=this._readWhitespace();tokenStream.mustMatch([Tokens.IDENT,Tokens.STRING]);value+=tokenStream.token().value;value+=this._readWhitespace();}
|
79 |
-
tokenStream.mustMatch(Tokens.RBRACKET);return new SelectorSubPart(value+"]","attribute",token.startLine,token.startCol);}else{return null;}},_pseudo:function(){var tokenStream=this._tokenStream,pseudo=null,colons=":",line,col;if(tokenStream.match(Tokens.COLON)){if(tokenStream.match(Tokens.COLON)){colons+=":";}
|
80 |
-
if(tokenStream.match(Tokens.IDENT)){pseudo=tokenStream.token().value;line=tokenStream.token().startLine;col=tokenStream.token().startCol-colons.length;}else if(tokenStream.peek()==Tokens.FUNCTION){line=tokenStream.LT(1).startLine;col=tokenStream.LT(1).startCol-colons.length;pseudo=this._functional_pseudo();}
|
81 |
-
if(pseudo){pseudo=new SelectorSubPart(colons+pseudo,"pseudo",line,col);}}
|
82 |
-
return pseudo;},_functional_pseudo:function(){var tokenStream=this._tokenStream,value=null;if(tokenStream.match(Tokens.FUNCTION)){value=tokenStream.token().value;value+=this._readWhitespace();value+=this._expression();tokenStream.mustMatch(Tokens.RPAREN);value+=")";}
|
83 |
-
return value;},_expression:function(){var tokenStream=this._tokenStream,value="";while(tokenStream.match([Tokens.PLUS,Tokens.MINUS,Tokens.DIMENSION,Tokens.NUMBER,Tokens.STRING,Tokens.IDENT,Tokens.LENGTH,Tokens.FREQ,Tokens.ANGLE,Tokens.TIME,Tokens.RESOLUTION,Tokens.SLASH])){value+=tokenStream.token().value;value+=this._readWhitespace();}
|
84 |
-
return value.length?value:null;},_negation:function(){var tokenStream=this._tokenStream,line,col,value="",arg,subpart=null;if(tokenStream.match(Tokens.NOT)){value=tokenStream.token().value;line=tokenStream.token().startLine;col=tokenStream.token().startCol;value+=this._readWhitespace();arg=this._negation_arg();value+=arg;value+=this._readWhitespace();tokenStream.match(Tokens.RPAREN);value+=tokenStream.token().value;subpart=new SelectorSubPart(value,"not",line,col);subpart.args.push(arg);}
|
85 |
-
return subpart;},_negation_arg:function(){var tokenStream=this._tokenStream,args=[this._type_selector,this._universal,function(){return tokenStream.match(Tokens.HASH)?new SelectorSubPart(tokenStream.token().value,"id",tokenStream.token().startLine,tokenStream.token().startCol):null;},this._class,this._attrib,this._pseudo],arg=null,i=0,len=args.length,elementName,line,col,part;line=tokenStream.LT(1).startLine;col=tokenStream.LT(1).startCol;while(i<len&&arg===null){arg=args[i].call(this);i++;}
|
86 |
-
if(arg===null){this._unexpectedToken(tokenStream.LT(1));}
|
87 |
-
if(arg.type=="elementName"){part=new SelectorPart(arg,[],arg.toString(),line,col);}else{part=new SelectorPart(null,[arg],arg.toString(),line,col);}
|
88 |
-
return part;},_declaration:function(){var tokenStream=this._tokenStream,property=null,expr=null,prio=null,error=null,invalid=null,propertyName="";property=this._property();if(property!==null){tokenStream.mustMatch(Tokens.COLON);this._readWhitespace();expr=this._expr();if(!expr||expr.length===0){this._unexpectedToken(tokenStream.LT(1));}
|
89 |
-
prio=this._prio();propertyName=property.toString();if(this.options.starHack&&property.hack=="*"||this.options.underscoreHack&&property.hack=="_"){propertyName=property.text;}
|
90 |
-
try{this._validateProperty(propertyName,expr);}catch(ex){invalid=ex;}
|
91 |
-
this.fire({type:"property",property:property,value:expr,important:prio,line:property.line,col:property.col,invalid:invalid});return true;}else{return false;}},_prio:function(){var tokenStream=this._tokenStream,result=tokenStream.match(Tokens.IMPORTANT_SYM);this._readWhitespace();return result;},_expr:function(inFunction){var tokenStream=this._tokenStream,values=[],value=null,operator=null;value=this._term();if(value!==null){values.push(value);do{operator=this._operator(inFunction);if(operator){values.push(operator);}
|
92 |
-
value=this._term();if(value===null){break;}else{values.push(value);}}while(true);}
|
93 |
-
return values.length>0?new PropertyValue(values,values[0].line,values[0].col):null;},_term:function(){var tokenStream=this._tokenStream,unary=null,value=null,token,line,col;unary=this._unary_operator();if(unary!==null){line=tokenStream.token().startLine;col=tokenStream.token().startCol;}
|
94 |
-
if(tokenStream.peek()==Tokens.IE_FUNCTION&&this.options.ieFilters){value=this._ie_function();if(unary===null){line=tokenStream.token().startLine;col=tokenStream.token().startCol;}}else if(tokenStream.match([Tokens.NUMBER,Tokens.PERCENTAGE,Tokens.LENGTH,Tokens.ANGLE,Tokens.TIME,Tokens.FREQ,Tokens.STRING,Tokens.IDENT,Tokens.URI,Tokens.UNICODE_RANGE])){value=tokenStream.token().value;if(unary===null){line=tokenStream.token().startLine;col=tokenStream.token().startCol;}
|
95 |
-
this._readWhitespace();}else{token=this._hexcolor();if(token===null){if(unary===null){line=tokenStream.LT(1).startLine;col=tokenStream.LT(1).startCol;}
|
96 |
-
if(value===null){if(tokenStream.LA(3)==Tokens.EQUALS&&this.options.ieFilters){value=this._ie_function();}else{value=this._function();}}}else{value=token.value;if(unary===null){line=token.startLine;col=token.startCol;}}}
|
97 |
-
return value!==null?new PropertyValuePart(unary!==null?unary+value:value,line,col):null;},_function:function(){var tokenStream=this._tokenStream,functionText=null,expr=null,lt;if(tokenStream.match(Tokens.FUNCTION)){functionText=tokenStream.token().value;this._readWhitespace();expr=this._expr(true);functionText+=expr;if(this.options.ieFilters&&tokenStream.peek()==Tokens.EQUALS){do{if(this._readWhitespace()){functionText+=tokenStream.token().value;}
|
98 |
-
if(tokenStream.LA(0)==Tokens.COMMA){functionText+=tokenStream.token().value;}
|
99 |
-
tokenStream.match(Tokens.IDENT);functionText+=tokenStream.token().value;tokenStream.match(Tokens.EQUALS);functionText+=tokenStream.token().value;lt=tokenStream.peek();while(lt!=Tokens.COMMA&<!=Tokens.S&<!=Tokens.RPAREN){tokenStream.get();functionText+=tokenStream.token().value;lt=tokenStream.peek();}}while(tokenStream.match([Tokens.COMMA,Tokens.S]));}
|
100 |
-
tokenStream.match(Tokens.RPAREN);functionText+=")";this._readWhitespace();}
|
101 |
-
return functionText;},_ie_function:function(){var tokenStream=this._tokenStream,functionText=null,expr=null,lt;if(tokenStream.match([Tokens.IE_FUNCTION,Tokens.FUNCTION])){functionText=tokenStream.token().value;do{if(this._readWhitespace()){functionText+=tokenStream.token().value;}
|
102 |
-
if(tokenStream.LA(0)==Tokens.COMMA){functionText+=tokenStream.token().value;}
|
103 |
-
tokenStream.match(Tokens.IDENT);functionText+=tokenStream.token().value;tokenStream.match(Tokens.EQUALS);functionText+=tokenStream.token().value;lt=tokenStream.peek();while(lt!=Tokens.COMMA&<!=Tokens.S&<!=Tokens.RPAREN){tokenStream.get();functionText+=tokenStream.token().value;lt=tokenStream.peek();}}while(tokenStream.match([Tokens.COMMA,Tokens.S]));tokenStream.match(Tokens.RPAREN);functionText+=")";this._readWhitespace();}
|
104 |
-
return functionText;},_hexcolor:function(){var tokenStream=this._tokenStream,token=null,color;if(tokenStream.match(Tokens.HASH)){token=tokenStream.token();color=token.value;if(!/#[a-f0-9]{3,6}/i.test(color)){throw new SyntaxError("Expected a hex color but found '"+color+"' at line "+token.startLine+", col "+token.startCol+".",token.startLine,token.startCol);}
|
105 |
-
this._readWhitespace();}
|
106 |
-
return token;},_keyframes:function(){var tokenStream=this._tokenStream,token,tt,name,prefix="";tokenStream.mustMatch(Tokens.KEYFRAMES_SYM);token=tokenStream.token();if(/^@\-([^\-]+)\-/.test(token.value)){prefix=RegExp.$1;}
|
107 |
-
this._readWhitespace();name=this._keyframe_name();this._readWhitespace();tokenStream.mustMatch(Tokens.LBRACE);this.fire({type:"startkeyframes",name:name,prefix:prefix,line:token.startLine,col:token.startCol});this._readWhitespace();tt=tokenStream.peek();while(tt==Tokens.IDENT||tt==Tokens.PERCENTAGE){this._keyframe_rule();this._readWhitespace();tt=tokenStream.peek();}
|
108 |
-
this.fire({type:"endkeyframes",name:name,prefix:prefix,line:token.startLine,col:token.startCol});this._readWhitespace();tokenStream.mustMatch(Tokens.RBRACE);},_keyframe_name:function(){var tokenStream=this._tokenStream,token;tokenStream.mustMatch([Tokens.IDENT,Tokens.STRING]);return SyntaxUnit.fromToken(tokenStream.token());},_keyframe_rule:function(){var tokenStream=this._tokenStream,token,keyList=this._key_list();this.fire({type:"startkeyframerule",keys:keyList,line:keyList[0].line,col:keyList[0].col});this._readDeclarations(true);this.fire({type:"endkeyframerule",keys:keyList,line:keyList[0].line,col:keyList[0].col});},_key_list:function(){var tokenStream=this._tokenStream,token,key,keyList=[];keyList.push(this._key());this._readWhitespace();while(tokenStream.match(Tokens.COMMA)){this._readWhitespace();keyList.push(this._key());this._readWhitespace();}
|
109 |
-
return keyList;},_key:function(){var tokenStream=this._tokenStream,token;if(tokenStream.match(Tokens.PERCENTAGE)){return SyntaxUnit.fromToken(tokenStream.token());}else if(tokenStream.match(Tokens.IDENT)){token=tokenStream.token();if(/from|to/i.test(token.value)){return SyntaxUnit.fromToken(token);}
|
110 |
-
tokenStream.unget();}
|
111 |
-
this._unexpectedToken(tokenStream.LT(1));},_skipCruft:function(){while(this._tokenStream.match([Tokens.S,Tokens.CDO,Tokens.CDC])){}},_readDeclarations:function(checkStart,readMargins){var tokenStream=this._tokenStream,tt;this._readWhitespace();if(checkStart){tokenStream.mustMatch(Tokens.LBRACE);}
|
112 |
-
this._readWhitespace();try{while(true){if(tokenStream.match(Tokens.SEMICOLON)||(readMargins&&this._margin())){}else if(this._declaration()){if(!tokenStream.match(Tokens.SEMICOLON)){break;}}else{break;}
|
113 |
-
this._readWhitespace();}
|
114 |
-
tokenStream.mustMatch(Tokens.RBRACE);this._readWhitespace();}catch(ex){if(ex instanceof SyntaxError&&!this.options.strict){this.fire({type:"error",error:ex,message:ex.message,line:ex.line,col:ex.col});tt=tokenStream.advance([Tokens.SEMICOLON,Tokens.RBRACE]);if(tt==Tokens.SEMICOLON){this._readDeclarations(false,readMargins);}else if(tt!=Tokens.RBRACE){throw ex;}}else{throw ex;}}},_readWhitespace:function(){var tokenStream=this._tokenStream,ws="";while(tokenStream.match(Tokens.S)){ws+=tokenStream.token().value;}
|
115 |
-
return ws;},_unexpectedToken:function(token){throw new SyntaxError("Unexpected token '"+token.value+"' at line "+token.startLine+", col "+token.startCol+".",token.startLine,token.startCol);},_verifyEnd:function(){if(this._tokenStream.LA(1)!=Tokens.EOF){this._unexpectedToken(this._tokenStream.LT(1));}},_validateProperty:function(property,value){Validation.validate(property,value);},parse:function(input){this._tokenStream=new TokenStream(input,Tokens);this._stylesheet();},parseStyleSheet:function(input){return this.parse(input);},parseMediaQuery:function(input){this._tokenStream=new TokenStream(input,Tokens);var result=this._media_query();this._verifyEnd();return result;},parsePropertyValue:function(input){this._tokenStream=new TokenStream(input,Tokens);this._readWhitespace();var result=this._expr();this._readWhitespace();this._verifyEnd();return result;},parseRule:function(input){this._tokenStream=new TokenStream(input,Tokens);this._readWhitespace();var result=this._ruleset();this._readWhitespace();this._verifyEnd();return result;},parseSelector:function(input){this._tokenStream=new TokenStream(input,Tokens);this._readWhitespace();var result=this._selector();this._readWhitespace();this._verifyEnd();return result;},parseStyleAttribute:function(input){input+="}";this._tokenStream=new TokenStream(input,Tokens);this._readDeclarations();}};for(prop in additions){if(additions.hasOwnProperty(prop)){proto[prop]=additions[prop];}}
|
116 |
-
return proto;}();var Properties={"alignment-adjust":"auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>","alignment-baseline":"baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical","animation":1,"animation-delay":{multi:"<time>",comma:true},"animation-direction":{multi:"normal | alternate",comma:true},"animation-duration":{multi:"<time>",comma:true},"animation-iteration-count":{multi:"<number> | infinite",comma:true},"animation-name":{multi:"none | <ident>",comma:true},"animation-play-state":{multi:"running | paused",comma:true},"animation-timing-function":1,"-moz-animation-delay":{multi:"<time>",comma:true},"-moz-animation-direction":{multi:"normal | alternate",comma:true},"-moz-animation-duration":{multi:"<time>",comma:true},"-moz-animation-iteration-count":{multi:"<number> | infinite",comma:true},"-moz-animation-name":{multi:"none | <ident>",comma:true},"-moz-animation-play-state":{multi:"running | paused",comma:true},"-ms-animation-delay":{multi:"<time>",comma:true},"-ms-animation-direction":{multi:"normal | alternate",comma:true},"-ms-animation-duration":{multi:"<time>",comma:true},"-ms-animation-iteration-count":{multi:"<number> | infinite",comma:true},"-ms-animation-name":{multi:"none | <ident>",comma:true},"-ms-animation-play-state":{multi:"running | paused",comma:true},"-webkit-animation-delay":{multi:"<time>",comma:true},"-webkit-animation-direction":{multi:"normal | alternate",comma:true},"-webkit-animation-duration":{multi:"<time>",comma:true},"-webkit-animation-iteration-count":{multi:"<number> | infinite",comma:true},"-webkit-animation-name":{multi:"none | <ident>",comma:true},"-webkit-animation-play-state":{multi:"running | paused",comma:true},"-o-animation-delay":{multi:"<time>",comma:true},"-o-animation-direction":{multi:"normal | alternate",comma:true},"-o-animation-duration":{multi:"<time>",comma:true},"-o-animation-iteration-count":{multi:"<number> | infinite",comma:true},"-o-animation-name":{multi:"none | <ident>",comma:true},"-o-animation-play-state":{multi:"running | paused",comma:true},"appearance":"icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal | none | inherit","azimuth":function(expression){var simple="<angle> | leftwards | rightwards | inherit",direction="left-side | far-left | left | center-left | center | center-right | right | far-right | right-side",behind=false,valid=false,part;if(!ValidationTypes.isAny(expression,simple)){if(ValidationTypes.isAny(expression,"behind")){behind=true;valid=true;}
|
117 |
-
if(ValidationTypes.isAny(expression,direction)){valid=true;if(!behind){ValidationTypes.isAny(expression,"behind");}}}
|
118 |
-
if(expression.hasNext()){part=expression.next();if(valid){throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}else{throw new ValidationError("Expected (<'azimuth'>) but found '"+part+"'.",part.line,part.col);}}},"backface-visibility":"visible | hidden","background":1,"background-attachment":{multi:"<attachment>",comma:true},"background-clip":{multi:"<box>",comma:true},"background-color":"<color> | inherit","background-image":{multi:"<bg-image>",comma:true},"background-origin":{multi:"<box>",comma:true},"background-position":{multi:"<bg-position>",comma:true},"background-repeat":{multi:"<repeat-style>"},"background-size":{multi:"<bg-size>",comma:true},"baseline-shift":"baseline | sub | super | <percentage> | <length>","behavior":1,"binding":1,"bleed":"<length>","bookmark-label":"<content> | <attr> | <string>","bookmark-level":"none | <integer>","bookmark-state":"open | closed","bookmark-target":"none | <uri> | <attr>","border":"<border-width> || <border-style> || <color>","border-bottom":"<border-width> || <border-style> || <color>","border-bottom-color":"<color> | inherit","border-bottom-left-radius":"<x-one-radius>","border-bottom-right-radius":"<x-one-radius>","border-bottom-style":"<border-style>","border-bottom-width":"<border-width>","border-collapse":"collapse | separate | inherit","border-color":{multi:"<color> | inherit",max:4},"border-image":1,"border-image-outset":{multi:"<length> | <number>",max:4},"border-image-repeat":{multi:"stretch | repeat | round",max:2},"border-image-slice":function(expression){var valid=false,numeric="<number> | <percentage>",fill=false,count=0,max=4,part;if(ValidationTypes.isAny(expression,"fill")){fill=true;valid=true;}
|
119 |
-
while(expression.hasNext()&&count<max){valid=ValidationTypes.isAny(expression,numeric);if(!valid){break;}
|
120 |
-
count++;}
|
121 |
-
if(!fill){ValidationTypes.isAny(expression,"fill");}else{valid=true;}
|
122 |
-
if(expression.hasNext()){part=expression.next();if(valid){throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}else{throw new ValidationError("Expected ([<number> | <percentage>]{1,4} && fill?) but found '"+part+"'.",part.line,part.col);}}},"border-image-source":"<image> | none","border-image-width":{multi:"<length> | <percentage> | <number> | auto",max:4},"border-left":"<border-width> || <border-style> || <color>","border-left-color":"<color> | inherit","border-left-style":"<border-style>","border-left-width":"<border-width>","border-radius":function(expression){var valid=false,simple="<length> | <percentage> | inherit",slash=false,fill=false,count=0,max=8,part;while(expression.hasNext()&&count<max){valid=ValidationTypes.isAny(expression,simple);if(!valid){if(expression.peek()=="/"&&count>0&&!slash){slash=true;max=count+5;expression.next();}else{break;}}
|
123 |
-
count++;}
|
124 |
-
if(expression.hasNext()){part=expression.next();if(valid){throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}else{throw new ValidationError("Expected (<'border-radius'>) but found '"+part+"'.",part.line,part.col);}}},"border-right":"<border-width> || <border-style> || <color>","border-right-color":"<color> | inherit","border-right-style":"<border-style>","border-right-width":"<border-width>","border-spacing":{multi:"<length> | inherit",max:2},"border-style":{multi:"<border-style>",max:4},"border-top":"<border-width> || <border-style> || <color>","border-top-color":"<color> | inherit","border-top-left-radius":"<x-one-radius>","border-top-right-radius":"<x-one-radius>","border-top-style":"<border-style>","border-top-width":"<border-width>","border-width":{multi:"<border-width>",max:4},"bottom":"<margin-width> | inherit","box-align":"start | end | center | baseline | stretch","box-decoration-break":"slice |clone","box-direction":"normal | reverse | inherit","box-flex":"<number>","box-flex-group":"<integer>","box-lines":"single | multiple","box-ordinal-group":"<integer>","box-orient":"horizontal | vertical | inline-axis | block-axis | inherit","box-pack":"start | end | center | justify","box-shadow":function(expression){var result=false,part;if(!ValidationTypes.isAny(expression,"none")){Validation.multiProperty("<shadow>",expression,true,Infinity);}else{if(expression.hasNext()){part=expression.next();throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}}},"box-sizing":"content-box | border-box | inherit","break-after":"auto | always | avoid | left | right | page | column | avoid-page | avoid-column","break-before":"auto | always | avoid | left | right | page | column | avoid-page | avoid-column","break-inside":"auto | avoid | avoid-page | avoid-column","caption-side":"top | bottom | inherit","clear":"none | right | left | both | inherit","clip":1,"color":"<color> | inherit","color-profile":1,"column-count":"<integer> | auto","column-fill":"auto | balance","column-gap":"<length> | normal","column-rule":"<border-width> || <border-style> || <color>","column-rule-color":"<color>","column-rule-style":"<border-style>","column-rule-width":"<border-width>","column-span":"none | all","column-width":"<length> | auto","columns":1,"content":1,"counter-increment":1,"counter-reset":1,"crop":"<shape> | auto","cue":"cue-after | cue-before | inherit","cue-after":1,"cue-before":1,"cursor":1,"direction":"ltr | rtl | inherit","display":"inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | box | inline-box | grid | inline-grid | none | inherit | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box","dominant-baseline":1,"drop-initial-after-adjust":"central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>","drop-initial-after-align":"baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical","drop-initial-before-adjust":"before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length>","drop-initial-before-align":"caps-height | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical","drop-initial-size":"auto | line | <length> | <percentage>","drop-initial-value":"initial | <integer>","elevation":"<angle> | below | level | above | higher | lower | inherit","empty-cells":"show | hide | inherit","filter":1,"fit":"fill | hidden | meet | slice","fit-position":1,"float":"left | right | none | inherit","float-offset":1,"font":1,"font-family":1,"font-size":"<absolute-size> | <relative-size> | <length> | <percentage> | inherit","font-size-adjust":"<number> | none | inherit","font-stretch":"normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | inherit","font-style":"normal | italic | oblique | inherit","font-variant":"normal | small-caps | inherit","font-weight":"normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit","grid-cell-stacking":"columns | rows | layer","grid-column":1,"grid-columns":1,"grid-column-align":"start | end | center | stretch","grid-column-sizing":1,"grid-column-span":"<integer>","grid-flow":"none | rows | columns","grid-layer":"<integer>","grid-row":1,"grid-rows":1,"grid-row-align":"start | end | center | stretch","grid-row-span":"<integer>","grid-row-sizing":1,"hanging-punctuation":1,"height":"<margin-width> | inherit","hyphenate-after":"<integer> | auto","hyphenate-before":"<integer> | auto","hyphenate-character":"<string> | auto","hyphenate-lines":"no-limit | <integer>","hyphenate-resource":1,"hyphens":"none | manual | auto","icon":1,"image-orientation":"angle | auto","image-rendering":1,"image-resolution":1,"inline-box-align":"initial | last | <integer>","left":"<margin-width> | inherit","letter-spacing":"<length> | normal | inherit","line-height":"<number> | <length> | <percentage> | normal | inherit","line-break":"auto | loose | normal | strict","line-stacking":1,"line-stacking-ruby":"exclude-ruby | include-ruby","line-stacking-shift":"consider-shifts | disregard-shifts","line-stacking-strategy":"inline-line-height | block-line-height | max-height | grid-height","list-style":1,"list-style-image":"<uri> | none | inherit","list-style-position":"inside | outside | inherit","list-style-type":"disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none | inherit","margin":{multi:"<margin-width> | inherit",max:4},"margin-bottom":"<margin-width> | inherit","margin-left":"<margin-width> | inherit","margin-right":"<margin-width> | inherit","margin-top":"<margin-width> | inherit","mark":1,"mark-after":1,"mark-before":1,"marks":1,"marquee-direction":1,"marquee-play-count":1,"marquee-speed":1,"marquee-style":1,"max-height":"<length> | <percentage> | none | inherit","max-width":"<length> | <percentage> | none | inherit","min-height":"<length> | <percentage> | inherit","min-width":"<length> | <percentage> | inherit","move-to":1,"nav-down":1,"nav-index":1,"nav-left":1,"nav-right":1,"nav-up":1,"opacity":"<number> | inherit","orphans":"<integer> | inherit","outline":1,"outline-color":"<color> | invert | inherit","outline-offset":1,"outline-style":"<border-style> | inherit","outline-width":"<border-width> | inherit","overflow":"visible | hidden | scroll | auto | inherit","overflow-style":1,"overflow-x":1,"overflow-y":1,"padding":{multi:"<padding-width> | inherit",max:4},"padding-bottom":"<padding-width> | inherit","padding-left":"<padding-width> | inherit","padding-right":"<padding-width> | inherit","padding-top":"<padding-width> | inherit","page":1,"page-break-after":"auto | always | avoid | left | right | inherit","page-break-before":"auto | always | avoid | left | right | inherit","page-break-inside":"auto | avoid | inherit","page-policy":1,"pause":1,"pause-after":1,"pause-before":1,"perspective":1,"perspective-origin":1,"phonemes":1,"pitch":1,"pitch-range":1,"play-during":1,"pointer-events":"auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | inherit","position":"static | relative | absolute | fixed | inherit","presentation-level":1,"punctuation-trim":1,"quotes":1,"rendering-intent":1,"resize":1,"rest":1,"rest-after":1,"rest-before":1,"richness":1,"right":"<margin-width> | inherit","rotation":1,"rotation-point":1,"ruby-align":1,"ruby-overhang":1,"ruby-position":1,"ruby-span":1,"size":1,"speak":"normal | none | spell-out | inherit","speak-header":"once | always | inherit","speak-numeral":"digits | continuous | inherit","speak-punctuation":"code | none | inherit","speech-rate":1,"src":1,"stress":1,"string-set":1,"table-layout":"auto | fixed | inherit","tab-size":"<integer> | <length>","target":1,"target-name":1,"target-new":1,"target-position":1,"text-align":"left | right | center | justify | inherit","text-align-last":1,"text-decoration":1,"text-emphasis":1,"text-height":1,"text-indent":"<length> | <percentage> | inherit","text-justify":"auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida","text-outline":1,"text-overflow":1,"text-rendering":"auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit","text-shadow":1,"text-transform":"capitalize | uppercase | lowercase | none | inherit","text-wrap":"normal | none | avoid","top":"<margin-width> | inherit","transform":1,"transform-origin":1,"transform-style":1,"transition":1,"transition-delay":1,"transition-duration":1,"transition-property":1,"transition-timing-function":1,"unicode-bidi":"normal | embed | bidi-override | inherit","user-modify":"read-only | read-write | write-only | inherit","user-select":"none | text | toggle | element | elements | all | inherit","vertical-align":"auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length>","visibility":"visible | hidden | collapse | inherit","voice-balance":1,"voice-duration":1,"voice-family":1,"voice-pitch":1,"voice-pitch-range":1,"voice-rate":1,"voice-stress":1,"voice-volume":1,"volume":1,"white-space":"normal | pre | nowrap | pre-wrap | pre-line | inherit | -pre-wrap | -o-pre-wrap | -moz-pre-wrap | -hp-pre-wrap","white-space-collapse":1,"widows":"<integer> | inherit","width":"<length> | <percentage> | auto | inherit","word-break":"normal | keep-all | break-all","word-spacing":"<length> | normal | inherit","word-wrap":1,"z-index":"<integer> | auto | inherit","zoom":"<number> | <percentage> | normal"};function PropertyName(text,hack,line,col){SyntaxUnit.call(this,text,line,col,Parser.PROPERTY_NAME_TYPE);this.hack=hack;}
|
125 |
-
PropertyName.prototype=new SyntaxUnit();PropertyName.prototype.constructor=PropertyName;PropertyName.prototype.toString=function(){return(this.hack?this.hack:"")+this.text;};function PropertyValue(parts,line,col){SyntaxUnit.call(this,parts.join(" "),line,col,Parser.PROPERTY_VALUE_TYPE);this.parts=parts;}
|
126 |
-
PropertyValue.prototype=new SyntaxUnit();PropertyValue.prototype.constructor=PropertyValue;function PropertyValueIterator(value){this._i=0;this._parts=value.parts;this._marks=[];this.value=value;}
|
127 |
-
PropertyValueIterator.prototype.count=function(){return this._parts.length;};PropertyValueIterator.prototype.isFirst=function(){return this._i===0;};PropertyValueIterator.prototype.hasNext=function(){return(this._i<this._parts.length);};PropertyValueIterator.prototype.mark=function(){this._marks.push(this._i);};PropertyValueIterator.prototype.peek=function(count){return this.hasNext()?this._parts[this._i+(count||0)]:null;};PropertyValueIterator.prototype.next=function(){return this.hasNext()?this._parts[this._i++]:null;};PropertyValueIterator.prototype.previous=function(){return this._i>0?this._parts[--this._i]:null;};PropertyValueIterator.prototype.restore=function(){if(this._marks.length){this._i=this._marks.pop();}};function PropertyValuePart(text,line,col){SyntaxUnit.call(this,text,line,col,Parser.PROPERTY_VALUE_PART_TYPE);this.type="unknown";var temp;if(/^([+\-]?[\d\.]+)([a-z]+)$/i.test(text)){this.type="dimension";this.value=+RegExp.$1;this.units=RegExp.$2;switch(this.units.toLowerCase()){case"em":case"rem":case"ex":case"px":case"cm":case"mm":case"in":case"pt":case"pc":case"ch":case"vh":case"vw":case"vm":this.type="length";break;case"deg":case"rad":case"grad":this.type="angle";break;case"ms":case"s":this.type="time";break;case"hz":case"khz":this.type="frequency";break;case"dpi":case"dpcm":this.type="resolution";break;}}else if(/^([+\-]?[\d\.]+)%$/i.test(text)){this.type="percentage";this.value=+RegExp.$1;}else if(/^([+\-]?[\d\.]+)%$/i.test(text)){this.type="percentage";this.value=+RegExp.$1;}else if(/^([+\-]?\d+)$/i.test(text)){this.type="integer";this.value=+RegExp.$1;}else if(/^([+\-]?[\d\.]+)$/i.test(text)){this.type="number";this.value=+RegExp.$1;}else if(/^#([a-f0-9]{3,6})/i.test(text)){this.type="color";temp=RegExp.$1;if(temp.length==3){this.red=parseInt(temp.charAt(0)+temp.charAt(0),16);this.green=parseInt(temp.charAt(1)+temp.charAt(1),16);this.blue=parseInt(temp.charAt(2)+temp.charAt(2),16);}else{this.red=parseInt(temp.substring(0,2),16);this.green=parseInt(temp.substring(2,4),16);this.blue=parseInt(temp.substring(4,6),16);}}else if(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i.test(text)){this.type="color";this.red=+RegExp.$1;this.green=+RegExp.$2;this.blue=+RegExp.$3;}else if(/^rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)){this.type="color";this.red=+RegExp.$1*255/100;this.green=+RegExp.$2*255/100;this.blue=+RegExp.$3*255/100;}else if(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\s*\)/i.test(text)){this.type="color";this.red=+RegExp.$1;this.green=+RegExp.$2;this.blue=+RegExp.$3;this.alpha=+RegExp.$4;}else if(/^rgba\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)){this.type="color";this.red=+RegExp.$1*255/100;this.green=+RegExp.$2*255/100;this.blue=+RegExp.$3*255/100;this.alpha=+RegExp.$4;}else if(/^hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)){this.type="color";this.hue=+RegExp.$1;this.saturation=+RegExp.$2/100;this.lightness=+RegExp.$3/100;}else if(/^hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)){this.type="color";this.hue=+RegExp.$1;this.saturation=+RegExp.$2/100;this.lightness=+RegExp.$3/100;this.alpha=+RegExp.$4;}else if(/^url\(["']?([^\)"']+)["']?\)/i.test(text)){this.type="uri";this.uri=RegExp.$1;}else if(/^([^\(]+)\(/i.test(text)){this.type="function";this.name=RegExp.$1;this.value=text;}else if(/^["'][^"']*["']/.test(text)){this.type="string";this.value=eval(text);}else if(Colors[text.toLowerCase()]){this.type="color";temp=Colors[text.toLowerCase()].substring(1);this.red=parseInt(temp.substring(0,2),16);this.green=parseInt(temp.substring(2,4),16);this.blue=parseInt(temp.substring(4,6),16);}else if(/^[\,\/]$/.test(text)){this.type="operator";this.value=text;}else if(/^[a-z\-\u0080-\uFFFF][a-z0-9\-\u0080-\uFFFF]*$/i.test(text)){this.type="identifier";this.value=text;}}
|
128 |
-
PropertyValuePart.prototype=new SyntaxUnit();PropertyValuePart.prototype.constructor=PropertyValuePart;PropertyValuePart.fromToken=function(token){return new PropertyValuePart(token.value,token.startLine,token.startCol);};var Pseudos={":first-letter":1,":first-line":1,":before":1,":after":1};Pseudos.ELEMENT=1;Pseudos.CLASS=2;Pseudos.isElement=function(pseudo){return pseudo.indexOf("::")===0||Pseudos[pseudo.toLowerCase()]==Pseudos.ELEMENT;};function Selector(parts,line,col){SyntaxUnit.call(this,parts.join(" "),line,col,Parser.SELECTOR_TYPE);this.parts=parts;this.specificity=Specificity.calculate(this);}
|
129 |
-
Selector.prototype=new SyntaxUnit();Selector.prototype.constructor=Selector;function SelectorPart(elementName,modifiers,text,line,col){SyntaxUnit.call(this,text,line,col,Parser.SELECTOR_PART_TYPE);this.elementName=elementName;this.modifiers=modifiers;}
|
130 |
-
SelectorPart.prototype=new SyntaxUnit();SelectorPart.prototype.constructor=SelectorPart;function SelectorSubPart(text,type,line,col){SyntaxUnit.call(this,text,line,col,Parser.SELECTOR_SUB_PART_TYPE);this.type=type;this.args=[];}
|
131 |
-
SelectorSubPart.prototype=new SyntaxUnit();SelectorSubPart.prototype.constructor=SelectorSubPart;function Specificity(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d;}
|
132 |
-
Specificity.prototype={constructor:Specificity,compare:function(other){var comps=["a","b","c","d"],i,len;for(i=0,len=comps.length;i<len;i++){if(this[comps[i]]<other[comps[i]]){return-1;}else if(this[comps[i]]>other[comps[i]]){return 1;}}
|
133 |
-
return 0;},valueOf:function(){return(this.a*1000)+(this.b*100)+(this.c*10)+this.d;},toString:function(){return this.a+","+this.b+","+this.c+","+this.d;}};Specificity.calculate=function(selector){var i,len,part,b=0,c=0,d=0;function updateValues(part){var i,j,len,num,elementName=part.elementName?part.elementName.text:"",modifier;if(elementName&&elementName.charAt(elementName.length-1)!="*"){d++;}
|
134 |
-
for(i=0,len=part.modifiers.length;i<len;i++){modifier=part.modifiers[i];switch(modifier.type){case"class":case"attribute":c++;break;case"id":b++;break;case"pseudo":if(Pseudos.isElement(modifier.text)){d++;}else{c++;}
|
135 |
-
break;case"not":for(j=0,num=modifier.args.length;j<num;j++){updateValues(modifier.args[j]);}}}}
|
136 |
-
for(i=0,len=selector.parts.length;i<len;i++){part=selector.parts[i];if(part instanceof SelectorPart){updateValues(part);}}
|
137 |
-
return new Specificity(0,b,c,d);};var h=/^[0-9a-fA-F]$/,nonascii=/^[\u0080-\uFFFF]$/,nl=/\n|\r\n|\r|\f/;function isHexDigit(c){return c!==null&&h.test(c);}
|
138 |
-
function isDigit(c){return c!==null&&/\d/.test(c);}
|
139 |
-
function isWhitespace(c){return c!==null&&/\s/.test(c);}
|
140 |
-
function isNewLine(c){return c!==null&&nl.test(c);}
|
141 |
-
function isNameStart(c){return c!==null&&(/[a-z_\u0080-\uFFFF\\]/i.test(c));}
|
142 |
-
function isNameChar(c){return c!==null&&(isNameStart(c)||/[0-9\-\\]/.test(c));}
|
143 |
-
function isIdentStart(c){return c!==null&&(isNameStart(c)||/\-\\/.test(c));}
|
144 |
-
function mix(receiver,supplier){for(var prop in supplier){if(supplier.hasOwnProperty(prop)){receiver[prop]=supplier[prop];}}
|
145 |
-
return receiver;}
|
146 |
-
function TokenStream(input){TokenStreamBase.call(this,input,Tokens);}
|
147 |
-
TokenStream.prototype=mix(new TokenStreamBase(),{_getToken:function(channel){var c,reader=this._reader,token=null,startLine=reader.getLine(),startCol=reader.getCol();c=reader.read();while(c){switch(c){case"/":if(reader.peek()=="*"){token=this.commentToken(c,startLine,startCol);}else{token=this.charToken(c,startLine,startCol);}
|
148 |
-
break;case"|":case"~":case"^":case"$":case"*":if(reader.peek()=="="){token=this.comparisonToken(c,startLine,startCol);}else{token=this.charToken(c,startLine,startCol);}
|
149 |
-
break;case"\"":case"'":token=this.stringToken(c,startLine,startCol);break;case"#":if(isNameChar(reader.peek())){token=this.hashToken(c,startLine,startCol);}else{token=this.charToken(c,startLine,startCol);}
|
150 |
-
break;case".":if(isDigit(reader.peek())){token=this.numberToken(c,startLine,startCol);}else{token=this.charToken(c,startLine,startCol);}
|
151 |
-
break;case"-":if(reader.peek()=="-"){token=this.htmlCommentEndToken(c,startLine,startCol);}else if(isNameStart(reader.peek())){token=this.identOrFunctionToken(c,startLine,startCol);}else{token=this.charToken(c,startLine,startCol);}
|
152 |
-
break;case"!":token=this.importantToken(c,startLine,startCol);break;case"@":token=this.atRuleToken(c,startLine,startCol);break;case":":token=this.notToken(c,startLine,startCol);break;case"<":token=this.htmlCommentStartToken(c,startLine,startCol);break;case"U":case"u":if(reader.peek()=="+"){token=this.unicodeRangeToken(c,startLine,startCol);break;}
|
153 |
-
default:if(isDigit(c)){token=this.numberToken(c,startLine,startCol);}else
|
154 |
-
if(isWhitespace(c)){token=this.whitespaceToken(c,startLine,startCol);}else
|
155 |
-
if(isIdentStart(c)){token=this.identOrFunctionToken(c,startLine,startCol);}else
|
156 |
-
{token=this.charToken(c,startLine,startCol);}}
|
157 |
-
break;}
|
158 |
-
if(!token&&c===null){token=this.createToken(Tokens.EOF,null,startLine,startCol);}
|
159 |
-
return token;},createToken:function(tt,value,startLine,startCol,options){var reader=this._reader;options=options||{};return{value:value,type:tt,channel:options.channel,hide:options.hide||false,startLine:startLine,startCol:startCol,endLine:reader.getLine(),endCol:reader.getCol()};},atRuleToken:function(first,startLine,startCol){var rule=first,reader=this._reader,tt=Tokens.CHAR,valid=false,ident,c;reader.mark();ident=this.readName();rule=first+ident;tt=Tokens.type(rule.toLowerCase());if(tt==Tokens.CHAR||tt==Tokens.UNKNOWN){if(rule.length>1){tt=Tokens.UNKNOWN_SYM;}else{tt=Tokens.CHAR;rule=first;reader.reset();}}
|
160 |
-
return this.createToken(tt,rule,startLine,startCol);},charToken:function(c,startLine,startCol){var tt=Tokens.type(c);if(tt==-1){tt=Tokens.CHAR;}
|
161 |
-
return this.createToken(tt,c,startLine,startCol);},commentToken:function(first,startLine,startCol){var reader=this._reader,comment=this.readComment(first);return this.createToken(Tokens.COMMENT,comment,startLine,startCol);},comparisonToken:function(c,startLine,startCol){var reader=this._reader,comparison=c+reader.read(),tt=Tokens.type(comparison)||Tokens.CHAR;return this.createToken(tt,comparison,startLine,startCol);},hashToken:function(first,startLine,startCol){var reader=this._reader,name=this.readName(first);return this.createToken(Tokens.HASH,name,startLine,startCol);},htmlCommentStartToken:function(first,startLine,startCol){var reader=this._reader,text=first;reader.mark();text+=reader.readCount(3);if(text=="<!--"){return this.createToken(Tokens.CDO,text,startLine,startCol);}else{reader.reset();return this.charToken(first,startLine,startCol);}},htmlCommentEndToken:function(first,startLine,startCol){var reader=this._reader,text=first;reader.mark();text+=reader.readCount(2);if(text=="-->"){return this.createToken(Tokens.CDC,text,startLine,startCol);}else{reader.reset();return this.charToken(first,startLine,startCol);}},identOrFunctionToken:function(first,startLine,startCol){var reader=this._reader,ident=this.readName(first),tt=Tokens.IDENT;if(reader.peek()=="("){ident+=reader.read();if(ident.toLowerCase()=="url("){tt=Tokens.URI;ident=this.readURI(ident);if(ident.toLowerCase()=="url("){tt=Tokens.FUNCTION;}}else{tt=Tokens.FUNCTION;}}else if(reader.peek()==":"){if(ident.toLowerCase()=="progid"){ident+=reader.readTo("(");tt=Tokens.IE_FUNCTION;}}
|
162 |
-
return this.createToken(tt,ident,startLine,startCol);},importantToken:function(first,startLine,startCol){var reader=this._reader,important=first,tt=Tokens.CHAR,temp,c;reader.mark();c=reader.read();while(c){if(c=="/"){if(reader.peek()!="*"){break;}else{temp=this.readComment(c);if(temp===""){break;}}}else if(isWhitespace(c)){important+=c+this.readWhitespace();}else if(/i/i.test(c)){temp=reader.readCount(8);if(/mportant/i.test(temp)){important+=c+temp;tt=Tokens.IMPORTANT_SYM;}
|
163 |
-
break;}else{break;}
|
164 |
-
c=reader.read();}
|
165 |
-
if(tt==Tokens.CHAR){reader.reset();return this.charToken(first,startLine,startCol);}else{return this.createToken(tt,important,startLine,startCol);}},notToken:function(first,startLine,startCol){var reader=this._reader,text=first;reader.mark();text+=reader.readCount(4);if(text.toLowerCase()==":not("){return this.createToken(Tokens.NOT,text,startLine,startCol);}else{reader.reset();return this.charToken(first,startLine,startCol);}},numberToken:function(first,startLine,startCol){var reader=this._reader,value=this.readNumber(first),ident,tt=Tokens.NUMBER,c=reader.peek();if(isIdentStart(c)){ident=this.readName(reader.read());value+=ident;if(/^em$|^ex$|^px$|^gd$|^rem$|^vw$|^vh$|^vm$|^ch$|^cm$|^mm$|^in$|^pt$|^pc$/i.test(ident)){tt=Tokens.LENGTH;}else if(/^deg|^rad$|^grad$/i.test(ident)){tt=Tokens.ANGLE;}else if(/^ms$|^s$/i.test(ident)){tt=Tokens.TIME;}else if(/^hz$|^khz$/i.test(ident)){tt=Tokens.FREQ;}else if(/^dpi$|^dpcm$/i.test(ident)){tt=Tokens.RESOLUTION;}else{tt=Tokens.DIMENSION;}}else if(c=="%"){value+=reader.read();tt=Tokens.PERCENTAGE;}
|
166 |
-
return this.createToken(tt,value,startLine,startCol);},stringToken:function(first,startLine,startCol){var delim=first,string=first,reader=this._reader,prev=first,tt=Tokens.STRING,c=reader.read();while(c){string+=c;if(c==delim&&prev!="\\"){break;}
|
167 |
-
if(isNewLine(reader.peek())&&c!="\\"){tt=Tokens.INVALID;break;}
|
168 |
-
prev=c;c=reader.read();}
|
169 |
-
if(c===null){tt=Tokens.INVALID;}
|
170 |
-
return this.createToken(tt,string,startLine,startCol);},unicodeRangeToken:function(first,startLine,startCol){var reader=this._reader,value=first,temp,tt=Tokens.CHAR;if(reader.peek()=="+"){reader.mark();value+=reader.read();value+=this.readUnicodeRangePart(true);if(value.length==2){reader.reset();}else{tt=Tokens.UNICODE_RANGE;if(value.indexOf("?")==-1){if(reader.peek()=="-"){reader.mark();temp=reader.read();temp+=this.readUnicodeRangePart(false);if(temp.length==1){reader.reset();}else{value+=temp;}}}}}
|
171 |
-
return this.createToken(tt,value,startLine,startCol);},whitespaceToken:function(first,startLine,startCol){var reader=this._reader,value=first+this.readWhitespace();return this.createToken(Tokens.S,value,startLine,startCol);},readUnicodeRangePart:function(allowQuestionMark){var reader=this._reader,part="",c=reader.peek();while(isHexDigit(c)&&part.length<6){reader.read();part+=c;c=reader.peek();}
|
172 |
-
if(allowQuestionMark){while(c=="?"&&part.length<6){reader.read();part+=c;c=reader.peek();}}
|
173 |
-
return part;},readWhitespace:function(){var reader=this._reader,whitespace="",c=reader.peek();while(isWhitespace(c)){reader.read();whitespace+=c;c=reader.peek();}
|
174 |
-
return whitespace;},readNumber:function(first){var reader=this._reader,number=first,hasDot=(first=="."),c=reader.peek();while(c){if(isDigit(c)){number+=reader.read();}else if(c=="."){if(hasDot){break;}else{hasDot=true;number+=reader.read();}}else{break;}
|
175 |
-
c=reader.peek();}
|
176 |
-
return number;},readString:function(){var reader=this._reader,delim=reader.read(),string=delim,prev=delim,c=reader.peek();while(c){c=reader.read();string+=c;if(c==delim&&prev!="\\"){break;}
|
177 |
-
if(isNewLine(reader.peek())&&c!="\\"){string="";break;}
|
178 |
-
prev=c;c=reader.peek();}
|
179 |
-
if(c===null){string="";}
|
180 |
-
return string;},readURI:function(first){var reader=this._reader,uri=first,inner="",c=reader.peek();reader.mark();while(c&&isWhitespace(c)){reader.read();c=reader.peek();}
|
181 |
-
if(c=="'"||c=="\""){inner=this.readString();}else{inner=this.readURL();}
|
182 |
-
c=reader.peek();while(c&&isWhitespace(c)){reader.read();c=reader.peek();}
|
183 |
-
if(inner===""||c!=")"){uri=first;reader.reset();}else{uri+=inner+reader.read();}
|
184 |
-
return uri;},readURL:function(){var reader=this._reader,url="",c=reader.peek();while(/^[!#$%&\\*-~]$/.test(c)){url+=reader.read();c=reader.peek();}
|
185 |
-
return url;},readName:function(first){var reader=this._reader,ident=first||"",c=reader.peek();while(true){if(c=="\\"){ident+=this.readEscape(reader.read());c=reader.peek();}else if(c&&isNameChar(c)){ident+=reader.read();c=reader.peek();}else{break;}}
|
186 |
-
return ident;},readEscape:function(first){var reader=this._reader,cssEscape=first||"",i=0,c=reader.peek();if(isHexDigit(c)){do{cssEscape+=reader.read();c=reader.peek();}while(c&&isHexDigit(c)&&++i<6);}
|
187 |
-
if(cssEscape.length==3&&/\s/.test(c)||cssEscape.length==7||cssEscape.length==1){reader.read();}else{c="";}
|
188 |
-
return cssEscape+c;},readComment:function(first){var reader=this._reader,comment=first||"",c=reader.read();if(c=="*"){while(c){comment+=c;if(comment.length>2&&c=="*"&&reader.peek()=="/"){comment+=reader.read();break;}
|
189 |
-
c=reader.read();}
|
190 |
-
return comment;}else{return"";}}});var Tokens=[{name:"CDO"},{name:"CDC"},{name:"S",whitespace:true},{name:"COMMENT",comment:true,hide:true,channel:"comment"},{name:"INCLUDES",text:"~="},{name:"DASHMATCH",text:"|="},{name:"PREFIXMATCH",text:"^="},{name:"SUFFIXMATCH",text:"$="},{name:"SUBSTRINGMATCH",text:"*="},{name:"STRING"},{name:"IDENT"},{name:"HASH"},{name:"IMPORT_SYM",text:"@import"},{name:"PAGE_SYM",text:"@page"},{name:"MEDIA_SYM",text:"@media"},{name:"FONT_FACE_SYM",text:"@font-face"},{name:"CHARSET_SYM",text:"@charset"},{name:"NAMESPACE_SYM",text:"@namespace"},{name:"VIEWPORT_SYM",text:"@viewport"},{name:"UNKNOWN_SYM"},{name:"KEYFRAMES_SYM",text:["@keyframes","@-webkit-keyframes","@-moz-keyframes","@-o-keyframes"]},{name:"IMPORTANT_SYM"},{name:"LENGTH"},{name:"ANGLE"},{name:"TIME"},{name:"FREQ"},{name:"DIMENSION"},{name:"PERCENTAGE"},{name:"NUMBER"},{name:"URI"},{name:"FUNCTION"},{name:"UNICODE_RANGE"},{name:"INVALID"},{name:"PLUS",text:"+"},{name:"GREATER",text:">"},{name:"COMMA",text:","},{name:"TILDE",text:"~"},{name:"NOT"},{name:"TOPLEFTCORNER_SYM",text:"@top-left-corner"},{name:"TOPLEFT_SYM",text:"@top-left"},{name:"TOPCENTER_SYM",text:"@top-center"},{name:"TOPRIGHT_SYM",text:"@top-right"},{name:"TOPRIGHTCORNER_SYM",text:"@top-right-corner"},{name:"BOTTOMLEFTCORNER_SYM",text:"@bottom-left-corner"},{name:"BOTTOMLEFT_SYM",text:"@bottom-left"},{name:"BOTTOMCENTER_SYM",text:"@bottom-center"},{name:"BOTTOMRIGHT_SYM",text:"@bottom-right"},{name:"BOTTOMRIGHTCORNER_SYM",text:"@bottom-right-corner"},{name:"LEFTTOP_SYM",text:"@left-top"},{name:"LEFTMIDDLE_SYM",text:"@left-middle"},{name:"LEFTBOTTOM_SYM",text:"@left-bottom"},{name:"RIGHTTOP_SYM",text:"@right-top"},{name:"RIGHTMIDDLE_SYM",text:"@right-middle"},{name:"RIGHTBOTTOM_SYM",text:"@right-bottom"},{name:"RESOLUTION",state:"media"},{name:"IE_FUNCTION"},{name:"CHAR"},{name:"PIPE",text:"|"},{name:"SLASH",text:"/"},{name:"MINUS",text:"-"},{name:"STAR",text:"*"},{name:"LBRACE",text:"{"},{name:"RBRACE",text:"}"},{name:"LBRACKET",text:"["},{name:"RBRACKET",text:"]"},{name:"EQUALS",text:"="},{name:"COLON",text:":"},{name:"SEMICOLON",text:";"},{name:"LPAREN",text:"("},{name:"RPAREN",text:")"},{name:"DOT",text:"."}];(function(){var nameMap=[],typeMap={};Tokens.UNKNOWN=-1;Tokens.unshift({name:"EOF"});for(var i=0,len=Tokens.length;i<len;i++){nameMap.push(Tokens[i].name);Tokens[Tokens[i].name]=i;if(Tokens[i].text){if(Tokens[i].text instanceof Array){for(var j=0;j<Tokens[i].text.length;j++){typeMap[Tokens[i].text[j]]=i;}}else{typeMap[Tokens[i].text]=i;}}}
|
191 |
-
Tokens.name=function(tt){return nameMap[tt];};Tokens.type=function(c){return typeMap[c]||-1;};})();var Validation={validate:function(property,value){var name=property.toString().toLowerCase(),parts=value.parts,expression=new PropertyValueIterator(value),spec=Properties[name],part,valid,j,count,msg,types,last,literals,max,multi,group;if(!spec){if(name.indexOf("-")!==0){throw new ValidationError("Unknown property '"+property+"'.",property.line,property.col);}}else if(typeof spec!="number"){if(typeof spec=="string"){if(spec.indexOf("||")>-1){this.groupProperty(spec,expression);}else{this.singleProperty(spec,expression,1);}}else if(spec.multi){this.multiProperty(spec.multi,expression,spec.comma,spec.max||Infinity);}else if(typeof spec=="function"){spec(expression);}}},singleProperty:function(types,expression,max,partial){var result=false,value=expression.value,count=0,part;while(expression.hasNext()&&count<max){result=ValidationTypes.isAny(expression,types);if(!result){break;}
|
192 |
-
count++;}
|
193 |
-
if(!result){if(expression.hasNext()&&!expression.isFirst()){part=expression.peek();throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}else{throw new ValidationError("Expected ("+types+") but found '"+value+"'.",value.line,value.col);}}else if(expression.hasNext()){part=expression.next();throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}},multiProperty:function(types,expression,comma,max){var result=false,value=expression.value,count=0,sep=false,part;while(expression.hasNext()&&!result&&count<max){if(ValidationTypes.isAny(expression,types)){count++;if(!expression.hasNext()){result=true;}else if(comma){if(expression.peek()==","){part=expression.next();}else{break;}}}else{break;}}
|
194 |
-
if(!result){if(expression.hasNext()&&!expression.isFirst()){part=expression.peek();throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}else{part=expression.previous();if(comma&&part==","){throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}else{throw new ValidationError("Expected ("+types+") but found '"+value+"'.",value.line,value.col);}}}else if(expression.hasNext()){part=expression.next();throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}},groupProperty:function(types,expression,comma){var result=false,value=expression.value,typeCount=types.split("||").length,groups={count:0},partial=false,name,part;while(expression.hasNext()&&!result){name=ValidationTypes.isAnyOfGroup(expression,types);if(name){if(groups[name]){break;}else{groups[name]=1;groups.count++;partial=true;if(groups.count==typeCount||!expression.hasNext()){result=true;}}}else{break;}}
|
195 |
-
if(!result){if(partial&&expression.hasNext()){part=expression.peek();throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}else{throw new ValidationError("Expected ("+types+") but found '"+value+"'.",value.line,value.col);}}else if(expression.hasNext()){part=expression.next();throw new ValidationError("Expected end of value but found '"+part+"'.",part.line,part.col);}}};function ValidationError(message,line,col){this.col=col;this.line=line;this.message=message;}
|
196 |
-
ValidationError.prototype=new Error();var ValidationTypes={isLiteral:function(part,literals){var text=part.text.toString().toLowerCase(),args=literals.split(" | "),i,len,found=false;for(i=0,len=args.length;i<len&&!found;i++){if(text==args[i].toLowerCase()){found=true;}}
|
197 |
-
return found;},isSimple:function(type){return!!this.simple[type];},isComplex:function(type){return!!this.complex[type];},isAny:function(expression,types){var args=types.split(" | "),i,len,found=false;for(i=0,len=args.length;i<len&&!found&&expression.hasNext();i++){found=this.isType(expression,args[i]);}
|
198 |
-
return found;},isAnyOfGroup:function(expression,types){var args=types.split(" || "),i,len,found=false;for(i=0,len=args.length;i<len&&!found;i++){found=this.isType(expression,args[i]);}
|
199 |
-
return found?args[i-1]:false;},isType:function(expression,type){var part=expression.peek(),result=false;if(type.charAt(0)!="<"){result=this.isLiteral(part,type);if(result){expression.next();}}else if(this.simple[type]){result=this.simple[type](part);if(result){expression.next();}}else{result=this.complex[type](expression);}
|
200 |
-
return result;},simple:{"<absolute-size>":function(part){return ValidationTypes.isLiteral(part,"xx-small | x-small | small | medium | large | x-large | xx-large");},"<attachment>":function(part){return ValidationTypes.isLiteral(part,"scroll | fixed | local");},"<attr>":function(part){return part.type=="function"&&part.name=="attr";},"<bg-image>":function(part){return this["<image>"](part)||this["<gradient>"](part)||part=="none";},"<gradient>":function(part){return part.type=="function"&&/^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(part);},"<box>":function(part){return ValidationTypes.isLiteral(part,"padding-box | border-box | content-box");},"<content>":function(part){return part.type=="function"&&part.name=="content";},"<relative-size>":function(part){return ValidationTypes.isLiteral(part,"smaller | larger");},"<ident>":function(part){return part.type=="identifier";},"<length>":function(part){if(part.type=="function"&&/^(?:\-(?:ms|moz|o|webkit)\-)?calc/i.test(part)){return true;}else{return part.type=="length"||part.type=="number"||part.type=="integer"||part=="0";}},"<color>":function(part){return part.type=="color"||part=="transparent";},"<number>":function(part){return part.type=="number"||this["<integer>"](part);},"<integer>":function(part){return part.type=="integer";},"<line>":function(part){return part.type=="integer";},"<angle>":function(part){return part.type=="angle";},"<uri>":function(part){return part.type=="uri";},"<image>":function(part){return this["<uri>"](part);},"<percentage>":function(part){return part.type=="percentage"||part=="0";},"<border-width>":function(part){return this["<length>"](part)||ValidationTypes.isLiteral(part,"thin | medium | thick");},"<border-style>":function(part){return ValidationTypes.isLiteral(part,"none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset");},"<margin-width>":function(part){return this["<length>"](part)||this["<percentage>"](part)||ValidationTypes.isLiteral(part,"auto");},"<padding-width>":function(part){return this["<length>"](part)||this["<percentage>"](part);},"<shape>":function(part){return part.type=="function"&&(part.name=="rect"||part.name=="inset-rect");},"<time>":function(part){return part.type=="time";}},complex:{"<bg-position>":function(expression){var types=this,result=false,numeric="<percentage> | <length>",xDir="left | right",yDir="top | bottom",count=0,hasNext=function(){return expression.hasNext()&&expression.peek()!=",";};while(expression.peek(count)&&expression.peek(count)!=","){count++;}
|
201 |
-
if(count<3){if(ValidationTypes.isAny(expression,xDir+" | center | "+numeric)){result=true;ValidationTypes.isAny(expression,yDir+" | center | "+numeric);}else if(ValidationTypes.isAny(expression,yDir)){result=true;ValidationTypes.isAny(expression,xDir+" | center");}}else{if(ValidationTypes.isAny(expression,xDir)){if(ValidationTypes.isAny(expression,yDir)){result=true;ValidationTypes.isAny(expression,numeric);}else if(ValidationTypes.isAny(expression,numeric)){if(ValidationTypes.isAny(expression,yDir)){result=true;ValidationTypes.isAny(expression,numeric);}else if(ValidationTypes.isAny(expression,"center")){result=true;}}}else if(ValidationTypes.isAny(expression,yDir)){if(ValidationTypes.isAny(expression,xDir)){result=true;ValidationTypes.isAny(expression,numeric);}else if(ValidationTypes.isAny(expression,numeric)){if(ValidationTypes.isAny(expression,xDir)){result=true;ValidationTypes.isAny(expression,numeric);}else if(ValidationTypes.isAny(expression,"center")){result=true;}}}else if(ValidationTypes.isAny(expression,"center")){if(ValidationTypes.isAny(expression,xDir+" | "+yDir)){result=true;ValidationTypes.isAny(expression,numeric);}}}
|
202 |
-
return result;},"<bg-size>":function(expression){var types=this,result=false,numeric="<percentage> | <length> | auto",part,i,len;if(ValidationTypes.isAny(expression,"cover | contain")){result=true;}else if(ValidationTypes.isAny(expression,numeric)){result=true;ValidationTypes.isAny(expression,numeric);}
|
203 |
-
return result;},"<repeat-style>":function(expression){var result=false,values="repeat | space | round | no-repeat",part;if(expression.hasNext()){part=expression.next();if(ValidationTypes.isLiteral(part,"repeat-x | repeat-y")){result=true;}else if(ValidationTypes.isLiteral(part,values)){result=true;if(expression.hasNext()&&ValidationTypes.isLiteral(expression.peek(),values)){expression.next();}}}
|
204 |
-
return result;},"<shadow>":function(expression){var result=false,count=0,inset=false,color=false,part;if(expression.hasNext()){if(ValidationTypes.isAny(expression,"inset")){inset=true;}
|
205 |
-
if(ValidationTypes.isAny(expression,"<color>")){color=true;}
|
206 |
-
while(ValidationTypes.isAny(expression,"<length>")&&count<4){count++;}
|
207 |
-
if(expression.hasNext()){if(!color){ValidationTypes.isAny(expression,"<color>");}
|
208 |
-
if(!inset){ValidationTypes.isAny(expression,"inset");}}
|
209 |
-
result=(count>=2&&count<=4);}
|
210 |
-
return result;},"<x-one-radius>":function(expression){var result=false,simple="<length> | <percentage> | inherit";if(ValidationTypes.isAny(expression,simple)){result=true;ValidationTypes.isAny(expression,simple);}
|
211 |
-
return result;}}};parserlib.css={Colors:Colors,Combinator:Combinator,Parser:Parser,PropertyName:PropertyName,PropertyValue:PropertyValue,PropertyValuePart:PropertyValuePart,MediaFeature:MediaFeature,MediaQuery:MediaQuery,Selector:Selector,SelectorPart:SelectorPart,SelectorSubPart:SelectorSubPart,Specificity:Specificity,TokenStream:TokenStream,Tokens:Tokens,ValidationError:ValidationError};})();(function(){for(var prop in parserlib){exports[prop]=parserlib[prop];}})();var CSSLint=(function(){var rules=[],formatters=[],embeddedRuleset=/\/\*csslint([^\*]*)\*\//,api=new parserlib.util.EventTarget();api.version="0.10.0";api.addRule=function(rule){rules.push(rule);rules[rule.id]=rule;};api.clearRules=function(){rules=[];};api.getRules=function(){return[].concat(rules).sort(function(a,b){return a.id>b.id?1:0;});};api.getRuleset=function(){var ruleset={},i=0,len=rules.length;while(i<len){ruleset[rules[i++].id]=1;}
|
212 |
-
return ruleset;};function applyEmbeddedRuleset(text,ruleset){var valueMap,embedded=text&&text.match(embeddedRuleset),rules=embedded&&embedded[1];if(rules){valueMap={"true":2,"":1,"false":0,"2":2,"1":1,"0":0};rules.toLowerCase().split(",").forEach(function(rule){var pair=rule.split(":"),property=pair[0]||"",value=pair[1]||"";ruleset[property.trim()]=valueMap[value.trim()];});}
|
213 |
-
return ruleset;}
|
214 |
-
api.addFormatter=function(formatter){formatters[formatter.id]=formatter;};api.getFormatter=function(formatId){return formatters[formatId];};api.format=function(results,filename,formatId,options){var formatter=this.getFormatter(formatId),result=null;if(formatter){result=formatter.startFormat();result+=formatter.formatResults(results,filename,options||{});result+=formatter.endFormat();}
|
215 |
-
return result;};api.hasFormat=function(formatId){return formatters.hasOwnProperty(formatId);};api.verify=function(text,ruleset){var i=0,len=rules.length,reporter,lines,report,parser=new parserlib.css.Parser({starHack:true,ieFilters:true,underscoreHack:true,strict:false});lines=text.replace(/\n\r?/g,"$split$").split('$split$');if(!ruleset){ruleset=this.getRuleset();}
|
216 |
-
if(embeddedRuleset.test(text)){ruleset=applyEmbeddedRuleset(text,ruleset);}
|
217 |
-
reporter=new Reporter(lines,ruleset);ruleset.errors=2;for(i in ruleset){if(ruleset.hasOwnProperty(i)&&ruleset[i]){if(rules[i]){rules[i].init(parser,reporter);}}}
|
218 |
-
try{parser.parse(text);}catch(ex){reporter.error("Fatal error, cannot continue: "+ex.message,ex.line,ex.col,{});}
|
219 |
-
report={messages:reporter.messages,stats:reporter.stats,ruleset:reporter.ruleset};report.messages.sort(function(a,b){if(a.rollup&&!b.rollup){return 1;}else if(!a.rollup&&b.rollup){return-1;}else{return a.line-b.line;}});return report;};return api;})();function Reporter(lines,ruleset){this.messages=[];this.stats=[];this.lines=lines;this.ruleset=ruleset;}
|
220 |
-
Reporter.prototype={constructor:Reporter,error:function(message,line,col,rule){this.messages.push({type:"error",line:line,col:col,message:message,evidence:this.lines[line-1],rule:rule||{}});},warn:function(message,line,col,rule){this.report(message,line,col,rule);},report:function(message,line,col,rule){this.messages.push({type:this.ruleset[rule.id]==2?"error":"warning",line:line,col:col,message:message,evidence:this.lines[line-1],rule:rule});},info:function(message,line,col,rule){this.messages.push({type:"info",line:line,col:col,message:message,evidence:this.lines[line-1],rule:rule});},rollupError:function(message,rule){this.messages.push({type:"error",rollup:true,message:message,rule:rule});},rollupWarn:function(message,rule){this.messages.push({type:"warning",rollup:true,message:message,rule:rule});},stat:function(name,value){this.stats[name]=value;}};CSSLint._Reporter=Reporter;CSSLint.Util={mix:function(receiver,supplier){var prop;for(prop in supplier){if(supplier.hasOwnProperty(prop)){receiver[prop]=supplier[prop];}}
|
221 |
-
return prop;},indexOf:function(values,value){if(values.indexOf){return values.indexOf(value);}else{for(var i=0,len=values.length;i<len;i++){if(values[i]===value){return i;}}
|
222 |
-
return-1;}},forEach:function(values,func){if(values.forEach){return values.forEach(func);}else{for(var i=0,len=values.length;i<len;i++){func(values[i],i,values);}}}};CSSLint.addRule({id:"adjoining-classes",name:"Disallow adjoining classes",desc:"Don't use adjoining classes.",browsers:"IE6",init:function(parser,reporter){var rule=this;parser.addListener("startrule",function(event){var selectors=event.selectors,selector,part,modifier,classCount,i,j,k;for(i=0;i<selectors.length;i++){selector=selectors[i];for(j=0;j<selector.parts.length;j++){part=selector.parts[j];if(part.type==parser.SELECTOR_PART_TYPE){classCount=0;for(k=0;k<part.modifiers.length;k++){modifier=part.modifiers[k];if(modifier.type=="class"){classCount++;}
|
223 |
-
if(classCount>1){reporter.report("Don't use adjoining classes.",part.line,part.col,rule);}}}}}});}});CSSLint.addRule({id:"box-model",name:"Beware of broken box size",desc:"Don't use width or height when using padding or border.",browsers:"All",init:function(parser,reporter){var rule=this,widthProperties={border:1,"border-left":1,"border-right":1,padding:1,"padding-left":1,"padding-right":1},heightProperties={border:1,"border-bottom":1,"border-top":1,padding:1,"padding-bottom":1,"padding-top":1},properties,boxSizing=false;function startRule(){properties={};boxSizing=false;}
|
224 |
-
function endRule(){var prop,value;if(!boxSizing){if(properties.height){for(prop in heightProperties){if(heightProperties.hasOwnProperty(prop)&&properties[prop]){value=properties[prop].value;if(!(prop=="padding"&&value.parts.length===2&&value.parts[0].value===0)){reporter.report("Using height with "+prop+" can sometimes make elements larger than you expect.",properties[prop].line,properties[prop].col,rule);}}}}
|
225 |
-
if(properties.width){for(prop in widthProperties){if(widthProperties.hasOwnProperty(prop)&&properties[prop]){value=properties[prop].value;if(!(prop=="padding"&&value.parts.length===2&&value.parts[1].value===0)){reporter.report("Using width with "+prop+" can sometimes make elements larger than you expect.",properties[prop].line,properties[prop].col,rule);}}}}}}
|
226 |
-
parser.addListener("startrule",startRule);parser.addListener("startfontface",startRule);parser.addListener("startpage",startRule);parser.addListener("startpagemargin",startRule);parser.addListener("startkeyframerule",startRule);parser.addListener("property",function(event){var name=event.property.text.toLowerCase();if(heightProperties[name]||widthProperties[name]){if(!/^0\S*$/.test(event.value)&&!(name=="border"&&event.value=="none")){properties[name]={line:event.property.line,col:event.property.col,value:event.value};}}else{if(/^(width|height)/i.test(name)&&/^(length|percentage)/.test(event.value.parts[0].type)){properties[name]=1;}else if(name=="box-sizing"){boxSizing=true;}}});parser.addListener("endrule",endRule);parser.addListener("endfontface",endRule);parser.addListener("endpage",endRule);parser.addListener("endpagemargin",endRule);parser.addListener("endkeyframerule",endRule);}});CSSLint.addRule({id:"box-sizing",name:"Disallow use of box-sizing",desc:"The box-sizing properties isn't supported in IE6 and IE7.",browsers:"IE6, IE7",tags:["Compatibility"],init:function(parser,reporter){var rule=this;parser.addListener("property",function(event){var name=event.property.text.toLowerCase();if(name=="box-sizing"){reporter.report("The box-sizing property isn't supported in IE6 and IE7.",event.line,event.col,rule);}});}});CSSLint.addRule({id:"bulletproof-font-face",name:"Use the bulletproof @font-face syntax",desc:"Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax).",browsers:"All",init:function(parser,reporter){var rule=this,count=0,fontFaceRule=false,firstSrc=true,ruleFailed=false,line,col;parser.addListener("startfontface",function(event){fontFaceRule=true;});parser.addListener("property",function(event){if(!fontFaceRule){return;}
|
227 |
-
var propertyName=event.property.toString().toLowerCase(),value=event.value.toString();line=event.line;col=event.col;if(propertyName==='src'){var regex=/^\s?url\(['"].+\.eot\?.*['"]\)\s*format\(['"]embedded-opentype['"]\).*$/i;if(!value.match(regex)&&firstSrc){ruleFailed=true;firstSrc=false;}else if(value.match(regex)&&!firstSrc){ruleFailed=false;}}});parser.addListener("endfontface",function(event){fontFaceRule=false;if(ruleFailed){reporter.report("@font-face declaration doesn't follow the fontspring bulletproof syntax.",line,col,rule);}});}});CSSLint.addRule({id:"compatible-vendor-prefixes",name:"Require compatible vendor prefixes",desc:"Include all compatible vendor prefixes to reach a wider range of users.",browsers:"All",init:function(parser,reporter){var rule=this,compatiblePrefixes,properties,prop,variations,prefixed,i,len,inKeyFrame=false,arrayPush=Array.prototype.push,applyTo=[];compatiblePrefixes={"animation":"webkit moz","animation-delay":"webkit moz","animation-direction":"webkit moz","animation-duration":"webkit moz","animation-fill-mode":"webkit moz","animation-iteration-count":"webkit moz","animation-name":"webkit moz","animation-play-state":"webkit moz","animation-timing-function":"webkit moz","appearance":"webkit moz","border-end":"webkit moz","border-end-color":"webkit moz","border-end-style":"webkit moz","border-end-width":"webkit moz","border-image":"webkit moz o","border-radius":"webkit","border-start":"webkit moz","border-start-color":"webkit moz","border-start-style":"webkit moz","border-start-width":"webkit moz","box-align":"webkit moz ms","box-direction":"webkit moz ms","box-flex":"webkit moz ms","box-lines":"webkit ms","box-ordinal-group":"webkit moz ms","box-orient":"webkit moz ms","box-pack":"webkit moz ms","box-sizing":"webkit moz","box-shadow":"webkit moz","column-count":"webkit moz ms","column-gap":"webkit moz ms","column-rule":"webkit moz ms","column-rule-color":"webkit moz ms","column-rule-style":"webkit moz ms","column-rule-width":"webkit moz ms","column-width":"webkit moz ms","hyphens":"epub moz","line-break":"webkit ms","margin-end":"webkit moz","margin-start":"webkit moz","marquee-speed":"webkit wap","marquee-style":"webkit wap","padding-end":"webkit moz","padding-start":"webkit moz","tab-size":"moz o","text-size-adjust":"webkit ms","transform":"webkit moz ms o","transform-origin":"webkit moz ms o","transition":"webkit moz o","transition-delay":"webkit moz o","transition-duration":"webkit moz o","transition-property":"webkit moz o","transition-timing-function":"webkit moz o","user-modify":"webkit moz","user-select":"webkit moz ms","word-break":"epub ms","writing-mode":"epub ms"};for(prop in compatiblePrefixes){if(compatiblePrefixes.hasOwnProperty(prop)){variations=[];prefixed=compatiblePrefixes[prop].split(' ');for(i=0,len=prefixed.length;i<len;i++){variations.push('-'+prefixed[i]+'-'+prop);}
|
228 |
-
compatiblePrefixes[prop]=variations;arrayPush.apply(applyTo,variations);}}
|
229 |
-
parser.addListener("startrule",function(){properties=[];});parser.addListener("startkeyframes",function(event){inKeyFrame=event.prefix||true;});parser.addListener("endkeyframes",function(event){inKeyFrame=false;});parser.addListener("property",function(event){var name=event.property;if(CSSLint.Util.indexOf(applyTo,name.text)>-1){if(!inKeyFrame||typeof inKeyFrame!="string"||name.text.indexOf("-"+inKeyFrame+"-")!==0){properties.push(name);}}});parser.addListener("endrule",function(event){if(!properties.length){return;}
|
230 |
-
var propertyGroups={},i,len,name,prop,variations,value,full,actual,item,propertiesSpecified;for(i=0,len=properties.length;i<len;i++){name=properties[i];for(prop in compatiblePrefixes){if(compatiblePrefixes.hasOwnProperty(prop)){variations=compatiblePrefixes[prop];if(CSSLint.Util.indexOf(variations,name.text)>-1){if(!propertyGroups[prop]){propertyGroups[prop]={full:variations.slice(0),actual:[],actualNodes:[]};}
|
231 |
-
if(CSSLint.Util.indexOf(propertyGroups[prop].actual,name.text)===-1){propertyGroups[prop].actual.push(name.text);propertyGroups[prop].actualNodes.push(name);}}}}}
|
232 |
-
for(prop in propertyGroups){if(propertyGroups.hasOwnProperty(prop)){value=propertyGroups[prop];full=value.full;actual=value.actual;if(full.length>actual.length){for(i=0,len=full.length;i<len;i++){item=full[i];if(CSSLint.Util.indexOf(actual,item)===-1){propertiesSpecified=(actual.length===1)?actual[0]:(actual.length==2)?actual.join(" and "):actual.join(", ");reporter.report("The property "+item+" is compatible with "+propertiesSpecified+" and should be included as well.",value.actualNodes[0].line,value.actualNodes[0].col,rule);}}}}}});}});CSSLint.addRule({id:"display-property-grouping",name:"Require properties appropriate for display",desc:"Certain properties shouldn't be used with certain display property values.",browsers:"All",init:function(parser,reporter){var rule=this;var propertiesToCheck={display:1,"float":"none",height:1,width:1,margin:1,"margin-left":1,"margin-right":1,"margin-bottom":1,"margin-top":1,padding:1,"padding-left":1,"padding-right":1,"padding-bottom":1,"padding-top":1,"vertical-align":1},properties;function reportProperty(name,display,msg){if(properties[name]){if(typeof propertiesToCheck[name]!="string"||properties[name].value.toLowerCase()!=propertiesToCheck[name]){reporter.report(msg||name+" can't be used with display: "+display+".",properties[name].line,properties[name].col,rule);}}}
|
233 |
-
function startRule(){properties={};}
|
234 |
-
function endRule(){var display=properties.display?properties.display.value:null;if(display){switch(display){case"inline":reportProperty("height",display);reportProperty("width",display);reportProperty("margin",display);reportProperty("margin-top",display);reportProperty("margin-bottom",display);reportProperty("float",display,"display:inline has no effect on floated elements (but may be used to fix the IE6 double-margin bug).");break;case"block":reportProperty("vertical-align",display);break;case"inline-block":reportProperty("float",display);break;default:if(display.indexOf("table-")===0){reportProperty("margin",display);reportProperty("margin-left",display);reportProperty("margin-right",display);reportProperty("margin-top",display);reportProperty("margin-bottom",display);reportProperty("float",display);}}}}
|
235 |
-
parser.addListener("startrule",startRule);parser.addListener("startfontface",startRule);parser.addListener("startkeyframerule",startRule);parser.addListener("startpagemargin",startRule);parser.addListener("startpage",startRule);parser.addListener("property",function(event){var name=event.property.text.toLowerCase();if(propertiesToCheck[name]){properties[name]={value:event.value.text,line:event.property.line,col:event.property.col};}});parser.addListener("endrule",endRule);parser.addListener("endfontface",endRule);parser.addListener("endkeyframerule",endRule);parser.addListener("endpagemargin",endRule);parser.addListener("endpage",endRule);}});CSSLint.addRule({id:"duplicate-background-images",name:"Disallow duplicate background images",desc:"Every background-image should be unique. Use a common class for e.g. sprites.",browsers:"All",init:function(parser,reporter){var rule=this,stack={};parser.addListener("property",function(event){var name=event.property.text,value=event.value,i,len;if(name.match(/background/i)){for(i=0,len=value.parts.length;i<len;i++){if(value.parts[i].type=='uri'){if(typeof stack[value.parts[i].uri]==='undefined'){stack[value.parts[i].uri]=event;}
|
236 |
-
else{reporter.report("Background image '"+value.parts[i].uri+"' was used multiple times, first declared at line "+stack[value.parts[i].uri].line+", col "+stack[value.parts[i].uri].col+".",event.line,event.col,rule);}}}}});}});CSSLint.addRule({id:"duplicate-properties",name:"Disallow duplicate properties",desc:"Duplicate properties must appear one after the other.",browsers:"All",init:function(parser,reporter){var rule=this,properties,lastProperty;function startRule(event){properties={};}
|
237 |
-
parser.addListener("startrule",startRule);parser.addListener("startfontface",startRule);parser.addListener("startpage",startRule);parser.addListener("startpagemargin",startRule);parser.addListener("startkeyframerule",startRule);parser.addListener("property",function(event){var property=event.property,name=property.text.toLowerCase();if(properties[name]&&(lastProperty!=name||properties[name]==event.value.text)){reporter.report("Duplicate property '"+event.property+"' found.",event.line,event.col,rule);}
|
238 |
-
properties[name]=event.value.text;lastProperty=name;});}});CSSLint.addRule({id:"empty-rules",name:"Disallow empty rules",desc:"Rules without any properties specified should be removed.",browsers:"All",init:function(parser,reporter){var rule=this,count=0;parser.addListener("startrule",function(){count=0;});parser.addListener("property",function(){count++;});parser.addListener("endrule",function(event){var selectors=event.selectors;if(count===0){reporter.report("Rule is empty.",selectors[0].line,selectors[0].col,rule);}});}});CSSLint.addRule({id:"errors",name:"Parsing Errors",desc:"This rule looks for recoverable syntax errors.",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("error",function(event){reporter.error(event.message,event.line,event.col,rule);});}});CSSLint.addRule({id:"fallback-colors",name:"Require fallback colors",desc:"For older browsers that don't support RGBA, HSL, or HSLA, provide a fallback color.",browsers:"IE6,IE7,IE8",init:function(parser,reporter){var rule=this,lastProperty,propertiesToCheck={color:1,background:1,"border-color":1,"border-top-color":1,"border-right-color":1,"border-bottom-color":1,"border-left-color":1,border:1,"border-top":1,"border-right":1,"border-bottom":1,"border-left":1,"background-color":1},properties;function startRule(event){properties={};lastProperty=null;}
|
239 |
-
parser.addListener("startrule",startRule);parser.addListener("startfontface",startRule);parser.addListener("startpage",startRule);parser.addListener("startpagemargin",startRule);parser.addListener("startkeyframerule",startRule);parser.addListener("property",function(event){var property=event.property,name=property.text.toLowerCase(),parts=event.value.parts,i=0,colorType="",len=parts.length;if(propertiesToCheck[name]){while(i<len){if(parts[i].type=="color"){if("alpha"in parts[i]||"hue"in parts[i]){if(/([^\)]+)\(/.test(parts[i])){colorType=RegExp.$1.toUpperCase();}
|
240 |
-
if(!lastProperty||(lastProperty.property.text.toLowerCase()!=name||lastProperty.colorType!="compat")){reporter.report("Fallback "+name+" (hex or RGB) should precede "+colorType+" "+name+".",event.line,event.col,rule);}}else{event.colorType="compat";}}
|
241 |
-
i++;}}
|
242 |
-
lastProperty=event;});}});CSSLint.addRule({id:"floats",name:"Disallow too many floats",desc:"This rule tests if the float property is used too many times",browsers:"All",init:function(parser,reporter){var rule=this;var count=0;parser.addListener("property",function(event){if(event.property.text.toLowerCase()=="float"&&event.value.text.toLowerCase()!="none"){count++;}});parser.addListener("endstylesheet",function(){reporter.stat("floats",count);if(count>=10){reporter.rollupWarn("Too many floats ("+count+"), you're probably using them for layout. Consider using a grid system instead.",rule);}});}});CSSLint.addRule({id:"font-faces",name:"Don't use too many web fonts",desc:"Too many different web fonts in the same stylesheet.",browsers:"All",init:function(parser,reporter){var rule=this,count=0;parser.addListener("startfontface",function(){count++;});parser.addListener("endstylesheet",function(){if(count>5){reporter.rollupWarn("Too many @font-face declarations ("+count+").",rule);}});}});CSSLint.addRule({id:"font-sizes",name:"Disallow too many font sizes",desc:"Checks the number of font-size declarations.",browsers:"All",init:function(parser,reporter){var rule=this,count=0;parser.addListener("property",function(event){if(event.property=="font-size"){count++;}});parser.addListener("endstylesheet",function(){reporter.stat("font-sizes",count);if(count>=10){reporter.rollupWarn("Too many font-size declarations ("+count+"), abstraction needed.",rule);}});}});CSSLint.addRule({id:"gradients",name:"Require all gradient definitions",desc:"When using a vendor-prefixed gradient, make sure to use them all.",browsers:"All",init:function(parser,reporter){var rule=this,gradients;parser.addListener("startrule",function(){gradients={moz:0,webkit:0,oldWebkit:0,o:0};});parser.addListener("property",function(event){if(/\-(moz|o|webkit)(?:\-(?:linear|radial))\-gradient/i.test(event.value)){gradients[RegExp.$1]=1;}else if(/\-webkit\-gradient/i.test(event.value)){gradients.oldWebkit=1;}});parser.addListener("endrule",function(event){var missing=[];if(!gradients.moz){missing.push("Firefox 3.6+");}
|
243 |
-
if(!gradients.webkit){missing.push("Webkit (Safari 5+, Chrome)");}
|
244 |
-
if(!gradients.oldWebkit){missing.push("Old Webkit (Safari 4+, Chrome)");}
|
245 |
-
if(!gradients.o){missing.push("Opera 11.1+");}
|
246 |
-
if(missing.length&&missing.length<4){reporter.report("Missing vendor-prefixed CSS gradients for "+missing.join(", ")+".",event.selectors[0].line,event.selectors[0].col,rule);}});}});CSSLint.addRule({id:"ids",name:"Disallow IDs in selectors",desc:"Selectors should not contain IDs.",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("startrule",function(event){var selectors=event.selectors,selector,part,modifier,idCount,i,j,k;for(i=0;i<selectors.length;i++){selector=selectors[i];idCount=0;for(j=0;j<selector.parts.length;j++){part=selector.parts[j];if(part.type==parser.SELECTOR_PART_TYPE){for(k=0;k<part.modifiers.length;k++){modifier=part.modifiers[k];if(modifier.type=="id"){idCount++;}}}}
|
247 |
-
if(idCount==1){reporter.report("Don't use IDs in selectors.",selector.line,selector.col,rule);}else if(idCount>1){reporter.report(idCount+" IDs in the selector, really?",selector.line,selector.col,rule);}}});}});CSSLint.addRule({id:"import",name:"Disallow @import",desc:"Don't use @import, use <link> instead.",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("import",function(event){reporter.report("@import prevents parallel downloads, use <link> instead.",event.line,event.col,rule);});}});CSSLint.addRule({id:"important",name:"Disallow !important",desc:"Be careful when using !important declaration",browsers:"All",init:function(parser,reporter){var rule=this,count=0;parser.addListener("property",function(event){if(event.important===true){count++;reporter.report("Use of !important",event.line,event.col,rule);}});parser.addListener("endstylesheet",function(){reporter.stat("important",count);if(count>=10){reporter.rollupWarn("Too many !important declarations ("+count+"), try to use less than 10 to avoid specificity issues.",rule);}});}});CSSLint.addRule({id:"known-properties",name:"Require use of known properties",desc:"Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property.",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("property",function(event){var name=event.property.text.toLowerCase();if(event.invalid){reporter.report(event.invalid.message,event.line,event.col,rule);}});}});CSSLint.addRule({id:"outline-none",name:"Disallow outline: none",desc:"Use of outline: none or outline: 0 should be limited to :focus rules.",browsers:"All",tags:["Accessibility"],init:function(parser,reporter){var rule=this,lastRule;function startRule(event){if(event.selectors){lastRule={line:event.line,col:event.col,selectors:event.selectors,propCount:0,outline:false};}else{lastRule=null;}}
|
248 |
-
function endRule(event){if(lastRule){if(lastRule.outline){if(lastRule.selectors.toString().toLowerCase().indexOf(":focus")==-1){reporter.report("Outlines should only be modified using :focus.",lastRule.line,lastRule.col,rule);}else if(lastRule.propCount==1){reporter.report("Outlines shouldn't be hidden unless other visual changes are made.",lastRule.line,lastRule.col,rule);}}}}
|
249 |
-
parser.addListener("startrule",startRule);parser.addListener("startfontface",startRule);parser.addListener("startpage",startRule);parser.addListener("startpagemargin",startRule);parser.addListener("startkeyframerule",startRule);parser.addListener("property",function(event){var name=event.property.text.toLowerCase(),value=event.value;if(lastRule){lastRule.propCount++;if(name=="outline"&&(value=="none"||value=="0")){lastRule.outline=true;}}});parser.addListener("endrule",endRule);parser.addListener("endfontface",endRule);parser.addListener("endpage",endRule);parser.addListener("endpagemargin",endRule);parser.addListener("endkeyframerule",endRule);}});CSSLint.addRule({id:"overqualified-elements",name:"Disallow overqualified elements",desc:"Don't use classes or IDs with elements (a.foo or a#foo).",browsers:"All",init:function(parser,reporter){var rule=this,classes={};parser.addListener("startrule",function(event){var selectors=event.selectors,selector,part,modifier,i,j,k;for(i=0;i<selectors.length;i++){selector=selectors[i];for(j=0;j<selector.parts.length;j++){part=selector.parts[j];if(part.type==parser.SELECTOR_PART_TYPE){for(k=0;k<part.modifiers.length;k++){modifier=part.modifiers[k];if(part.elementName&&modifier.type=="id"){reporter.report("Element ("+part+") is overqualified, just use "+modifier+" without element name.",part.line,part.col,rule);}else if(modifier.type=="class"){if(!classes[modifier]){classes[modifier]=[];}
|
250 |
-
classes[modifier].push({modifier:modifier,part:part});}}}}}});parser.addListener("endstylesheet",function(){var prop;for(prop in classes){if(classes.hasOwnProperty(prop)){if(classes[prop].length==1&&classes[prop][0].part.elementName){reporter.report("Element ("+classes[prop][0].part+") is overqualified, just use "+classes[prop][0].modifier+" without element name.",classes[prop][0].part.line,classes[prop][0].part.col,rule);}}}});}});CSSLint.addRule({id:"qualified-headings",name:"Disallow qualified headings",desc:"Headings should not be qualified (namespaced).",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("startrule",function(event){var selectors=event.selectors,selector,part,i,j;for(i=0;i<selectors.length;i++){selector=selectors[i];for(j=0;j<selector.parts.length;j++){part=selector.parts[j];if(part.type==parser.SELECTOR_PART_TYPE){if(part.elementName&&/h[1-6]/.test(part.elementName.toString())&&j>0){reporter.report("Heading ("+part.elementName+") should not be qualified.",part.line,part.col,rule);}}}}});}});CSSLint.addRule({id:"regex-selectors",name:"Disallow selectors that look like regexs",desc:"Selectors that look like regular expressions are slow and should be avoided.",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("startrule",function(event){var selectors=event.selectors,selector,part,modifier,i,j,k;for(i=0;i<selectors.length;i++){selector=selectors[i];for(j=0;j<selector.parts.length;j++){part=selector.parts[j];if(part.type==parser.SELECTOR_PART_TYPE){for(k=0;k<part.modifiers.length;k++){modifier=part.modifiers[k];if(modifier.type=="attribute"){if(/([\~\|\^\$\*]=)/.test(modifier)){reporter.report("Attribute selectors with "+RegExp.$1+" are slow!",modifier.line,modifier.col,rule);}}}}}}});}});CSSLint.addRule({id:"rules-count",name:"Rules Count",desc:"Track how many rules there are.",browsers:"All",init:function(parser,reporter){var rule=this,count=0;parser.addListener("startrule",function(){count++;});parser.addListener("endstylesheet",function(){reporter.stat("rule-count",count);});}});CSSLint.addRule({id:"selector-max-approaching",name:"Warn when approaching the 4095 selector limit for IE",desc:"Will warn when selector count is >= 3800 selectors.",browsers:"IE",init:function(parser,reporter){var rule=this,count=0;parser.addListener('startrule',function(event){count+=event.selectors.length;});parser.addListener("endstylesheet",function(){if(count>=3800){reporter.report("You have "+count+" selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,rule);}});}});CSSLint.addRule({id:"selector-max",name:"Error when past the 4095 selector limit for IE",desc:"Will error when selector count is > 4095.",browsers:"IE",init:function(parser,reporter){var rule=this,count=0;parser.addListener('startrule',function(event){count+=event.selectors.length;});parser.addListener("endstylesheet",function(){if(count>4095){reporter.report("You have "+count+" selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,rule);}});}});CSSLint.addRule({id:"shorthand",name:"Require shorthand properties",desc:"Use shorthand properties where possible.",browsers:"All",init:function(parser,reporter){var rule=this,prop,i,len,propertiesToCheck={},properties,mapping={"margin":["margin-top","margin-bottom","margin-left","margin-right"],"padding":["padding-top","padding-bottom","padding-left","padding-right"]};for(prop in mapping){if(mapping.hasOwnProperty(prop)){for(i=0,len=mapping[prop].length;i<len;i++){propertiesToCheck[mapping[prop][i]]=prop;}}}
|
251 |
-
function startRule(event){properties={};}
|
252 |
-
function endRule(event){var prop,i,len,total;for(prop in mapping){if(mapping.hasOwnProperty(prop)){total=0;for(i=0,len=mapping[prop].length;i<len;i++){total+=properties[mapping[prop][i]]?1:0;}
|
253 |
-
if(total==mapping[prop].length){reporter.report("The properties "+mapping[prop].join(", ")+" can be replaced by "+prop+".",event.line,event.col,rule);}}}}
|
254 |
-
parser.addListener("startrule",startRule);parser.addListener("startfontface",startRule);parser.addListener("property",function(event){var name=event.property.toString().toLowerCase(),value=event.value.parts[0].value;if(propertiesToCheck[name]){properties[name]=1;}});parser.addListener("endrule",endRule);parser.addListener("endfontface",endRule);}});CSSLint.addRule({id:"star-property-hack",name:"Disallow properties with a star prefix",desc:"Checks for the star property hack (targets IE6/7)",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("property",function(event){var property=event.property;if(property.hack=="*"){reporter.report("Property with star prefix found.",event.property.line,event.property.col,rule);}});}});CSSLint.addRule({id:"text-indent",name:"Disallow negative text-indent",desc:"Checks for text indent less than -99px",browsers:"All",init:function(parser,reporter){var rule=this,textIndent,direction;function startRule(event){textIndent=false;direction="inherit";}
|
255 |
-
function endRule(event){if(textIndent&&direction!="ltr"){reporter.report("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.",textIndent.line,textIndent.col,rule);}}
|
256 |
-
parser.addListener("startrule",startRule);parser.addListener("startfontface",startRule);parser.addListener("property",function(event){var name=event.property.toString().toLowerCase(),value=event.value;if(name=="text-indent"&&value.parts[0].value<-99){textIndent=event.property;}else if(name=="direction"&&value=="ltr"){direction="ltr";}});parser.addListener("endrule",endRule);parser.addListener("endfontface",endRule);}});CSSLint.addRule({id:"underscore-property-hack",name:"Disallow properties with an underscore prefix",desc:"Checks for the underscore property hack (targets IE6)",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("property",function(event){var property=event.property;if(property.hack=="_"){reporter.report("Property with underscore prefix found.",event.property.line,event.property.col,rule);}});}});CSSLint.addRule({id:"unique-headings",name:"Headings should only be defined once",desc:"Headings should be defined only once.",browsers:"All",init:function(parser,reporter){var rule=this;var headings={h1:0,h2:0,h3:0,h4:0,h5:0,h6:0};parser.addListener("startrule",function(event){var selectors=event.selectors,selector,part,pseudo,i,j;for(i=0;i<selectors.length;i++){selector=selectors[i];part=selector.parts[selector.parts.length-1];if(part.elementName&&/(h[1-6])/i.test(part.elementName.toString())){for(j=0;j<part.modifiers.length;j++){if(part.modifiers[j].type=="pseudo"){pseudo=true;break;}}
|
257 |
-
if(!pseudo){headings[RegExp.$1]++;if(headings[RegExp.$1]>1){reporter.report("Heading ("+part.elementName+") has already been defined.",part.line,part.col,rule);}}}}});parser.addListener("endstylesheet",function(event){var prop,messages=[];for(prop in headings){if(headings.hasOwnProperty(prop)){if(headings[prop]>1){messages.push(headings[prop]+" "+prop+"s");}}}
|
258 |
-
if(messages.length){reporter.rollupWarn("You have "+messages.join(", ")+" defined in this stylesheet.",rule);}});}});CSSLint.addRule({id:"universal-selector",name:"Disallow universal selector",desc:"The universal selector (*) is known to be slow.",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("startrule",function(event){var selectors=event.selectors,selector,part,modifier,i,j,k;for(i=0;i<selectors.length;i++){selector=selectors[i];part=selector.parts[selector.parts.length-1];if(part.elementName=="*"){reporter.report(rule.desc,part.line,part.col,rule);}}});}});CSSLint.addRule({id:"unqualified-attributes",name:"Disallow unqualified attribute selectors",desc:"Unqualified attribute selectors are known to be slow.",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("startrule",function(event){var selectors=event.selectors,selector,part,modifier,i,j,k;for(i=0;i<selectors.length;i++){selector=selectors[i];part=selector.parts[selector.parts.length-1];if(part.type==parser.SELECTOR_PART_TYPE){for(k=0;k<part.modifiers.length;k++){modifier=part.modifiers[k];if(modifier.type=="attribute"&&(!part.elementName||part.elementName=="*")){reporter.report(rule.desc,part.line,part.col,rule);}}}}});}});CSSLint.addRule({id:"vendor-prefix",name:"Require standard property with vendor prefix",desc:"When using a vendor-prefixed property, make sure to include the standard one.",browsers:"All",init:function(parser,reporter){var rule=this,properties,num,propertiesToCheck={"-webkit-border-radius":"border-radius","-webkit-border-top-left-radius":"border-top-left-radius","-webkit-border-top-right-radius":"border-top-right-radius","-webkit-border-bottom-left-radius":"border-bottom-left-radius","-webkit-border-bottom-right-radius":"border-bottom-right-radius","-o-border-radius":"border-radius","-o-border-top-left-radius":"border-top-left-radius","-o-border-top-right-radius":"border-top-right-radius","-o-border-bottom-left-radius":"border-bottom-left-radius","-o-border-bottom-right-radius":"border-bottom-right-radius","-moz-border-radius":"border-radius","-moz-border-radius-topleft":"border-top-left-radius","-moz-border-radius-topright":"border-top-right-radius","-moz-border-radius-bottomleft":"border-bottom-left-radius","-moz-border-radius-bottomright":"border-bottom-right-radius","-moz-column-count":"column-count","-webkit-column-count":"column-count","-moz-column-gap":"column-gap","-webkit-column-gap":"column-gap","-moz-column-rule":"column-rule","-webkit-column-rule":"column-rule","-moz-column-rule-style":"column-rule-style","-webkit-column-rule-style":"column-rule-style","-moz-column-rule-color":"column-rule-color","-webkit-column-rule-color":"column-rule-color","-moz-column-rule-width":"column-rule-width","-webkit-column-rule-width":"column-rule-width","-moz-column-width":"column-width","-webkit-column-width":"column-width","-webkit-column-span":"column-span","-webkit-columns":"columns","-moz-box-shadow":"box-shadow","-webkit-box-shadow":"box-shadow","-moz-transform":"transform","-webkit-transform":"transform","-o-transform":"transform","-ms-transform":"transform","-moz-transform-origin":"transform-origin","-webkit-transform-origin":"transform-origin","-o-transform-origin":"transform-origin","-ms-transform-origin":"transform-origin","-moz-box-sizing":"box-sizing","-webkit-box-sizing":"box-sizing","-moz-user-select":"user-select","-khtml-user-select":"user-select","-webkit-user-select":"user-select"};function startRule(){properties={};num=1;}
|
259 |
-
function endRule(event){var prop,i,len,standard,needed,actual,needsStandard=[];for(prop in properties){if(propertiesToCheck[prop]){needsStandard.push({actual:prop,needed:propertiesToCheck[prop]});}}
|
260 |
-
for(i=0,len=needsStandard.length;i<len;i++){needed=needsStandard[i].needed;actual=needsStandard[i].actual;if(!properties[needed]){reporter.report("Missing standard property '"+needed+"' to go along with '"+actual+"'.",properties[actual][0].name.line,properties[actual][0].name.col,rule);}else{if(properties[needed][0].pos<properties[actual][0].pos){reporter.report("Standard property '"+needed+"' should come after vendor-prefixed property '"+actual+"'.",properties[actual][0].name.line,properties[actual][0].name.col,rule);}}}}
|
261 |
-
parser.addListener("startrule",startRule);parser.addListener("startfontface",startRule);parser.addListener("startpage",startRule);parser.addListener("startpagemargin",startRule);parser.addListener("startkeyframerule",startRule);parser.addListener("property",function(event){var name=event.property.text.toLowerCase();if(!properties[name]){properties[name]=[];}
|
262 |
-
properties[name].push({name:event.property,value:event.value,pos:num++});});parser.addListener("endrule",endRule);parser.addListener("endfontface",endRule);parser.addListener("endpage",endRule);parser.addListener("endpagemargin",endRule);parser.addListener("endkeyframerule",endRule);}});CSSLint.addRule({id:"zero-units",name:"Disallow units for 0 values",desc:"You don't need to specify units when a value is 0.",browsers:"All",init:function(parser,reporter){var rule=this;parser.addListener("property",function(event){var parts=event.value.parts,i=0,len=parts.length;while(i<len){if((parts[i].units||parts[i].type=="percentage")&&parts[i].value===0&&parts[i].type!="time"){reporter.report("Values of 0 shouldn't have units specified.",parts[i].line,parts[i].col,rule);}
|
263 |
-
i++;}});}});(function(){var xmlEscape=function(str){if(!str||str.constructor!==String){return"";}
|
264 |
-
return str.replace(/[\"&><]/g,function(match){switch(match){case"\"":return""";case"&":return"&";case"<":return"<";case">":return">";}});};CSSLint.addFormatter({id:"checkstyle-xml",name:"Checkstyle XML format",startFormat:function(){return"<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>";},endFormat:function(){return"</checkstyle>";},readError:function(filename,message){return"<file name=\""+xmlEscape(filename)+"\"><error line=\"0\" column=\"0\" severty=\"error\" message=\""+xmlEscape(message)+"\"></error></file>";},formatResults:function(results,filename,options){var messages=results.messages,output=[];var generateSource=function(rule){if(!rule||!('name'in rule)){return"";}
|
265 |
-
return'net.csslint.'+rule.name.replace(/\s/g,'');};if(messages.length>0){output.push("<file name=\""+filename+"\">");CSSLint.Util.forEach(messages,function(message,i){if(!message.rollup){output.push("<error line=\""+message.line+"\" column=\""+message.col+"\" severity=\""+message.type+"\""+" message=\""+xmlEscape(message.message)+"\" source=\""+generateSource(message.rule)+"\"/>");}});output.push("</file>");}
|
266 |
-
return output.join("");}});}());CSSLint.addFormatter({id:"compact",name:"Compact, 'porcelain' format",startFormat:function(){return"";},endFormat:function(){return"";},formatResults:function(results,filename,options){var messages=results.messages,output="";options=options||{};var capitalize=function(str){return str.charAt(0).toUpperCase()+str.slice(1);};if(messages.length===0){return options.quiet?"":filename+": Lint Free!";}
|
267 |
-
CSSLint.Util.forEach(messages,function(message,i){if(message.rollup){output+=filename+": "+capitalize(message.type)+" - "+message.message+"\n";}else{output+=filename+": "+"line "+message.line+", col "+message.col+", "+capitalize(message.type)+" - "+message.message+"\n";}});return output;}});CSSLint.addFormatter({id:"csslint-xml",name:"CSSLint XML format",startFormat:function(){return"<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint>";},endFormat:function(){return"</csslint>";},formatResults:function(results,filename,options){var messages=results.messages,output=[];var escapeSpecialCharacters=function(str){if(!str||str.constructor!==String){return"";}
|
268 |
-
return str.replace(/\"/g,"'").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");};if(messages.length>0){output.push("<file name=\""+filename+"\">");CSSLint.Util.forEach(messages,function(message,i){if(message.rollup){output.push("<issue severity=\""+message.type+"\" reason=\""+escapeSpecialCharacters(message.message)+"\" evidence=\""+escapeSpecialCharacters(message.evidence)+"\"/>");}else{output.push("<issue line=\""+message.line+"\" char=\""+message.col+"\" severity=\""+message.type+"\""+" reason=\""+escapeSpecialCharacters(message.message)+"\" evidence=\""+escapeSpecialCharacters(message.evidence)+"\"/>");}});output.push("</file>");}
|
269 |
-
return output.join("");}});CSSLint.addFormatter({id:"junit-xml",name:"JUNIT XML format",startFormat:function(){return"<?xml version=\"1.0\" encoding=\"utf-8\"?><testsuites>";},endFormat:function(){return"</testsuites>";},formatResults:function(results,filename,options){var messages=results.messages,output=[],tests={'error':0,'failure':0};var generateSource=function(rule){if(!rule||!('name'in rule)){return"";}
|
270 |
-
return'net.csslint.'+rule.name.replace(/\s/g,'');};var escapeSpecialCharacters=function(str){if(!str||str.constructor!==String){return"";}
|
271 |
-
return str.replace(/\"/g,"'").replace(/</g,"<").replace(/>/g,">");};if(messages.length>0){messages.forEach(function(message,i){var type=message.type==='warning'?'error':message.type;if(!message.rollup){output.push("<testcase time=\"0\" name=\""+generateSource(message.rule)+"\">");output.push("<"+type+" message=\""+escapeSpecialCharacters(message.message)+"\"><![CDATA["+message.line+':'+message.col+':'+escapeSpecialCharacters(message.evidence)+"]]></"+type+">");output.push("</testcase>");tests[type]+=1;}});output.unshift("<testsuite time=\"0\" tests=\""+messages.length+"\" skipped=\"0\" errors=\""+tests.error+"\" failures=\""+tests.failure+"\" package=\"net.csslint\" name=\""+filename+"\">");output.push("</testsuite>");}
|
272 |
-
return output.join("");}});CSSLint.addFormatter({id:"lint-xml",name:"Lint XML format",startFormat:function(){return"<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>";},endFormat:function(){return"</lint>";},formatResults:function(results,filename,options){var messages=results.messages,output=[];var escapeSpecialCharacters=function(str){if(!str||str.constructor!==String){return"";}
|
273 |
-
return str.replace(/\"/g,"'").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");};if(messages.length>0){output.push("<file name=\""+filename+"\">");CSSLint.Util.forEach(messages,function(message,i){if(message.rollup){output.push("<issue severity=\""+message.type+"\" reason=\""+escapeSpecialCharacters(message.message)+"\" evidence=\""+escapeSpecialCharacters(message.evidence)+"\"/>");}else{output.push("<issue line=\""+message.line+"\" char=\""+message.col+"\" severity=\""+message.type+"\""+" reason=\""+escapeSpecialCharacters(message.message)+"\" evidence=\""+escapeSpecialCharacters(message.evidence)+"\"/>");}});output.push("</file>");}
|
274 |
-
return output.join("");}});CSSLint.addFormatter({id:"text",name:"Plain Text",startFormat:function(){return"";},endFormat:function(){return"";},formatResults:function(results,filename,options){var messages=results.messages,output="";options=options||{};if(messages.length===0){return options.quiet?"":"\n\ncsslint: No errors in "+filename+".";}
|
275 |
-
output="\n\ncsslint: There are "+messages.length+" problems in "+filename+".";var pos=filename.lastIndexOf("/"),shortFilename=filename;if(pos===-1){pos=filename.lastIndexOf("\\");}
|
276 |
-
if(pos>-1){shortFilename=filename.substring(pos+1);}
|
277 |
-
CSSLint.Util.forEach(messages,function(message,i){output=output+"\n\n"+shortFilename;if(message.rollup){output+="\n"+(i+1)+": "+message.type;output+="\n"+message.message;}else{output+="\n"+(i+1)+": "+message.type+" at line "+message.line+", col "+message.col;output+="\n"+message.message;output+="\n"+message.evidence;}});return output;}});return CSSLint;})();
|
1 |
+
var exports=exports||{},CSSLint=function(){function Reporter(e,t){this.messages=[],this.stats=[],this.lines=e,this.ruleset=t}var parserlib={};!function(){function e(){this._listeners={}}function t(e){this._input=e.replace(/\n\r?/g,"\n"),this._line=1,this._col=1,this._cursor=0}function r(e,t,r){this.col=r,this.line=t,this.message=e}function n(e,t,r,n){this.col=r,this.line=t,this.text=e,this.type=n}function i(e,r){this._reader=e?new t(e.toString()):null,this._token=null,this._tokenData=r,this._lt=[],this._ltIndex=0,this._ltIndexCache=[]}e.prototype={constructor:e,addListener:function(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)},fire:function(e){if("string"==typeof e&&(e={type:e}),"undefined"!=typeof e.target&&(e.target=this),"undefined"==typeof e.type)throw new Error("Event object missing 'type' property.");if(this._listeners[e.type])for(var t=this._listeners[e.type].concat(),r=0,n=t.length;n>r;r++)t[r].call(this,e)},removeListener:function(e,t){if(this._listeners[e])for(var r=this._listeners[e],n=0,i=r.length;i>n;n++)if(r[n]===t){r.splice(n,1);break}}},t.prototype={constructor:t,getCol:function(){return this._col},getLine:function(){return this._line},eof:function(){return this._cursor==this._input.length},peek:function(e){var t=null;return e="undefined"==typeof e?1:e,this._cursor<this._input.length&&(t=this._input.charAt(this._cursor+e-1)),t},read:function(){var e=null;return this._cursor<this._input.length&&("\n"==this._input.charAt(this._cursor)?(this._line++,this._col=1):this._col++,e=this._input.charAt(this._cursor++)),e},mark:function(){this._bookmark={cursor:this._cursor,line:this._line,col:this._col}},reset:function(){this._bookmark&&(this._cursor=this._bookmark.cursor,this._line=this._bookmark.line,this._col=this._bookmark.col,delete this._bookmark)},readTo:function(e){for(var t,r="";r.length<e.length||r.lastIndexOf(e)!=r.length-e.length;){if(t=this.read(),!t)throw new Error('Expected "'+e+'" at line '+this._line+", col "+this._col+".");r+=t}return r},readWhile:function(e){for(var t="",r=this.read();null!==r&&e(r);)t+=r,r=this.read();return t},readMatch:function(e){var t=this._input.substring(this._cursor),r=null;return"string"==typeof e?0===t.indexOf(e)&&(r=this.readCount(e.length)):e instanceof RegExp&&e.test(t)&&(r=this.readCount(RegExp.lastMatch.length)),r},readCount:function(e){for(var t="";e--;)t+=this.read();return t}},r.prototype=new Error,n.fromToken=function(e){return new n(e.value,e.startLine,e.startCol)},n.prototype={constructor:n,valueOf:function(){return this.toString()},toString:function(){return this.text}},i.createTokenData=function(e){var t=[],r={},n=e.concat([]),i=0,o=n.length+1;for(n.UNKNOWN=-1,n.unshift({name:"EOF"});o>i;i++)t.push(n[i].name),n[n[i].name]=i,n[i].text&&(r[n[i].text]=i);return n.name=function(e){return t[e]},n.type=function(e){return r[e]},n},i.prototype={constructor:i,match:function(e,t){e instanceof Array||(e=[e]);for(var r=this.get(t),n=0,i=e.length;i>n;)if(r==e[n++])return!0;return this.unget(),!1},mustMatch:function(e,t){var n;if(e instanceof Array||(e=[e]),!this.match.apply(this,arguments))throw n=this.LT(1),new r("Expected "+this._tokenData[e[0]].name+" at line "+n.startLine+", col "+n.startCol+".",n.startLine,n.startCol)},advance:function(e,t){for(;0!==this.LA(0)&&!this.match(e,t);)this.get();return this.LA(0)},get:function(e){var t,r,n=this._tokenData,i=(this._reader,0);n.length;if(this._lt.length&&this._ltIndex>=0&&this._ltIndex<this._lt.length){for(i++,this._token=this._lt[this._ltIndex++],r=n[this._token.type];void 0!==r.channel&&e!==r.channel&&this._ltIndex<this._lt.length;)this._token=this._lt[this._ltIndex++],r=n[this._token.type],i++;if((void 0===r.channel||e===r.channel)&&this._ltIndex<=this._lt.length)return this._ltIndexCache.push(i),this._token.type}return t=this._getToken(),t.type>-1&&!n[t.type].hide&&(t.channel=n[t.type].channel,this._token=t,this._lt.push(t),this._ltIndexCache.push(this._lt.length-this._ltIndex+i),this._lt.length>5&&this._lt.shift(),this._ltIndexCache.length>5&&this._ltIndexCache.shift(),this._ltIndex=this._lt.length),r=n[t.type],r&&(r.hide||void 0!==r.channel&&e!==r.channel)?this.get(e):t.type},LA:function(e){var t,r=e;if(e>0){if(e>5)throw new Error("Too much lookahead.");for(;r;)t=this.get(),r--;for(;e>r;)this.unget(),r++}else if(0>e){if(!this._lt[this._ltIndex+e])throw new Error("Too much lookbehind.");t=this._lt[this._ltIndex+e].type}else t=this._token.type;return t},LT:function(e){return this.LA(e),this._lt[this._ltIndex+e-1]},peek:function(){return this.LA(1)},token:function(){return this._token},tokenName:function(e){return 0>e||e>this._tokenData.length?"UNKNOWN_TOKEN":this._tokenData[e].name},tokenType:function(e){return this._tokenData[e]||-1},unget:function(){if(!this._ltIndexCache.length)throw new Error("Too much lookahead.");this._ltIndex-=this._ltIndexCache.pop(),this._token=this._lt[this._ltIndex-1]}},parserlib.util={StringReader:t,SyntaxError:r,SyntaxUnit:n,EventTarget:e,TokenStreamBase:i}}(),function(){function Combinator(e,t,r){SyntaxUnit.call(this,e,t,r,Parser.COMBINATOR_TYPE),this.type="unknown",/^\s+$/.test(e)?this.type="descendant":">"==e?this.type="child":"+"==e?this.type="adjacent-sibling":"~"==e&&(this.type="sibling")}function MediaFeature(e,t){SyntaxUnit.call(this,"("+e+(null!==t?":"+t:"")+")",e.startLine,e.startCol,Parser.MEDIA_FEATURE_TYPE),this.name=e,this.value=t}function MediaQuery(e,t,r,n,i){SyntaxUnit.call(this,(e?e+" ":"")+(t?t:"")+(t&&r.length>0?" and ":"")+r.join(" and "),n,i,Parser.MEDIA_QUERY_TYPE),this.modifier=e,this.mediaType=t,this.features=r}function Parser(e){EventTarget.call(this),this.options=e||{},this._tokenStream=null}function PropertyName(e,t,r,n){SyntaxUnit.call(this,e,r,n,Parser.PROPERTY_NAME_TYPE),this.hack=t}function PropertyValue(e,t,r){SyntaxUnit.call(this,e.join(" "),t,r,Parser.PROPERTY_VALUE_TYPE),this.parts=e}function PropertyValueIterator(e){this._i=0,this._parts=e.parts,this._marks=[],this.value=e}function PropertyValuePart(text,line,col){SyntaxUnit.call(this,text,line,col,Parser.PROPERTY_VALUE_PART_TYPE),this.type="unknown";var temp;if(/^([+\-]?[\d\.]+)([a-z]+)$/i.test(text))switch(this.type="dimension",this.value=+RegExp.$1,this.units=RegExp.$2,this.units.toLowerCase()){case"em":case"rem":case"ex":case"px":case"cm":case"mm":case"in":case"pt":case"pc":case"ch":case"vh":case"vw":case"vm":this.type="length";break;case"deg":case"rad":case"grad":this.type="angle";break;case"ms":case"s":this.type="time";break;case"hz":case"khz":this.type="frequency";break;case"dpi":case"dpcm":this.type="resolution"}else/^([+\-]?[\d\.]+)%$/i.test(text)?(this.type="percentage",this.value=+RegExp.$1):/^([+\-]?[\d\.]+)%$/i.test(text)?(this.type="percentage",this.value=+RegExp.$1):/^([+\-]?\d+)$/i.test(text)?(this.type="integer",this.value=+RegExp.$1):/^([+\-]?[\d\.]+)$/i.test(text)?(this.type="number",this.value=+RegExp.$1):/^#([a-f0-9]{3,6})/i.test(text)?(this.type="color",temp=RegExp.$1,3==temp.length?(this.red=parseInt(temp.charAt(0)+temp.charAt(0),16),this.green=parseInt(temp.charAt(1)+temp.charAt(1),16),this.blue=parseInt(temp.charAt(2)+temp.charAt(2),16)):(this.red=parseInt(temp.substring(0,2),16),this.green=parseInt(temp.substring(2,4),16),this.blue=parseInt(temp.substring(4,6),16))):/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i.test(text)?(this.type="color",this.red=+RegExp.$1,this.green=+RegExp.$2,this.blue=+RegExp.$3):/^rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)?(this.type="color",this.red=255*+RegExp.$1/100,this.green=255*+RegExp.$2/100,this.blue=255*+RegExp.$3/100):/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\s*\)/i.test(text)?(this.type="color",this.red=+RegExp.$1,this.green=+RegExp.$2,this.blue=+RegExp.$3,this.alpha=+RegExp.$4):/^rgba\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)?(this.type="color",this.red=255*+RegExp.$1/100,this.green=255*+RegExp.$2/100,this.blue=255*+RegExp.$3/100,this.alpha=+RegExp.$4):/^hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)?(this.type="color",this.hue=+RegExp.$1,this.saturation=+RegExp.$2/100,this.lightness=+RegExp.$3/100):/^hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)?(this.type="color",this.hue=+RegExp.$1,this.saturation=+RegExp.$2/100,this.lightness=+RegExp.$3/100,this.alpha=+RegExp.$4):/^url\(["']?([^\)"']+)["']?\)/i.test(text)?(this.type="uri",this.uri=RegExp.$1):/^([^\(]+)\(/i.test(text)?(this.type="function",this.name=RegExp.$1,this.value=text):/^["'][^"']*["']/.test(text)?(this.type="string",this.value=eval(text)):Colors[text.toLowerCase()]?(this.type="color",temp=Colors[text.toLowerCase()].substring(1),this.red=parseInt(temp.substring(0,2),16),this.green=parseInt(temp.substring(2,4),16),this.blue=parseInt(temp.substring(4,6),16)):/^[\,\/]$/.test(text)?(this.type="operator",this.value=text):/^[a-z\-\u0080-\uFFFF][a-z0-9\-\u0080-\uFFFF]*$/i.test(text)&&(this.type="identifier",this.value=text)}function Selector(e,t,r){SyntaxUnit.call(this,e.join(" "),t,r,Parser.SELECTOR_TYPE),this.parts=e,this.specificity=Specificity.calculate(this)}function SelectorPart(e,t,r,n,i){SyntaxUnit.call(this,r,n,i,Parser.SELECTOR_PART_TYPE),this.elementName=e,this.modifiers=t}function SelectorSubPart(e,t,r,n){SyntaxUnit.call(this,e,r,n,Parser.SELECTOR_SUB_PART_TYPE),this.type=t,this.args=[]}function Specificity(e,t,r,n){this.a=e,this.b=t,this.c=r,this.d=n}function isHexDigit(e){return null!==e&&h.test(e)}function isDigit(e){return null!==e&&/\d/.test(e)}function isWhitespace(e){return null!==e&&/\s/.test(e)}function isNewLine(e){return null!==e&&nl.test(e)}function isNameStart(e){return null!==e&&/[a-z_\u0080-\uFFFF\\]/i.test(e)}function isNameChar(e){return null!==e&&(isNameStart(e)||/[0-9\-\\]/.test(e))}function isIdentStart(e){return null!==e&&(isNameStart(e)||/\-\\/.test(e))}function mix(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e}function TokenStream(e){TokenStreamBase.call(this,e,Tokens)}function ValidationError(e,t,r){this.col=r,this.line=t,this.message=e}var EventTarget=parserlib.util.EventTarget,TokenStreamBase=parserlib.util.TokenStreamBase,StringReader=parserlib.util.StringReader,SyntaxError=parserlib.util.SyntaxError,SyntaxUnit=parserlib.util.SyntaxUnit,Colors={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",activeBorder:"Active window border.",activecaption:"Active window caption.",appworkspace:"Background color of multiple document interface.",background:"Desktop background.",buttonface:"The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.",buttonhighlight:"The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",buttonshadow:"The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",buttontext:"Text on push buttons.",captiontext:"Text in caption, size box, and scrollbar arrow box.",graytext:"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",highlight:"Item(s) selected in a control.",highlighttext:"Text of item(s) selected in a control.",inactiveborder:"Inactive window border.",inactivecaption:"Inactive window caption.",inactivecaptiontext:"Color of text in an inactive caption.",infobackground:"Background color for tooltip controls.",infotext:"Text color for tooltip controls.",menu:"Menu background.",menutext:"Text in menus.",scrollbar:"Scroll bar gray area.",threeddarkshadow:"The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedface:"The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedhighlight:"The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedlightshadow:"The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedshadow:"The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",window:"Window background.",windowframe:"Window frame.",windowtext:"Text in windows."};Combinator.prototype=new SyntaxUnit,Combinator.prototype.constructor=Combinator,MediaFeature.prototype=new SyntaxUnit,MediaFeature.prototype.constructor=MediaFeature,MediaQuery.prototype=new SyntaxUnit,MediaQuery.prototype.constructor=MediaQuery,Parser.DEFAULT_TYPE=0,Parser.COMBINATOR_TYPE=1,Parser.MEDIA_FEATURE_TYPE=2,Parser.MEDIA_QUERY_TYPE=3,Parser.PROPERTY_NAME_TYPE=4,Parser.PROPERTY_VALUE_TYPE=5,Parser.PROPERTY_VALUE_PART_TYPE=6,Parser.SELECTOR_TYPE=7,Parser.SELECTOR_PART_TYPE=8,Parser.SELECTOR_SUB_PART_TYPE=9,Parser.prototype=function(){var e,t=new EventTarget,r={constructor:Parser,DEFAULT_TYPE:0,COMBINATOR_TYPE:1,MEDIA_FEATURE_TYPE:2,MEDIA_QUERY_TYPE:3,PROPERTY_NAME_TYPE:4,PROPERTY_VALUE_TYPE:5,PROPERTY_VALUE_PART_TYPE:6,SELECTOR_TYPE:7,SELECTOR_PART_TYPE:8,SELECTOR_SUB_PART_TYPE:9,_stylesheet:function(){var e,t,r,n=this._tokenStream;for(this.fire("startstylesheet"),this._charset(),this._skipCruft();n.peek()==Tokens.IMPORT_SYM;)this._import(),this._skipCruft();for(;n.peek()==Tokens.NAMESPACE_SYM;)this._namespace(),this._skipCruft();for(r=n.peek();r>Tokens.EOF;){try{switch(r){case Tokens.MEDIA_SYM:this._media(),this._skipCruft();break;case Tokens.PAGE_SYM:this._page(),this._skipCruft();break;case Tokens.FONT_FACE_SYM:this._font_face(),this._skipCruft();break;case Tokens.KEYFRAMES_SYM:this._keyframes(),this._skipCruft();break;case Tokens.VIEWPORT_SYM:this._viewport(),this._skipCruft();break;case Tokens.UNKNOWN_SYM:if(n.get(),this.options.strict)throw new SyntaxError("Unknown @ rule.",n.LT(0).startLine,n.LT(0).startCol);for(this.fire({type:"error",error:null,message:"Unknown @ rule: "+n.LT(0).value+".",line:n.LT(0).startLine,col:n.LT(0).startCol}),e=0;n.advance([Tokens.LBRACE,Tokens.RBRACE])==Tokens.LBRACE;)e++;for(;e;)n.advance([Tokens.RBRACE]),e--;break;case Tokens.S:this._readWhitespace();break;default:if(!this._ruleset())switch(r){case Tokens.CHARSET_SYM:throw t=n.LT(1),this._charset(!1),new SyntaxError("@charset not allowed here.",t.startLine,t.startCol);case Tokens.IMPORT_SYM:throw t=n.LT(1),this._import(!1),new SyntaxError("@import not allowed here.",t.startLine,t.startCol);case Tokens.NAMESPACE_SYM:throw t=n.LT(1),this._namespace(!1),new SyntaxError("@namespace not allowed here.",t.startLine,t.startCol);default:n.get(),this._unexpectedToken(n.token())}}}catch(i){if(!(i instanceof SyntaxError)||this.options.strict)throw i;this.fire({type:"error",error:i,message:i.message,line:i.line,col:i.col})}r=n.peek()}r!=Tokens.EOF&&this._unexpectedToken(n.token()),this.fire("endstylesheet")},_charset:function(e){var t,r,n,i,o=this._tokenStream;o.match(Tokens.CHARSET_SYM)&&(n=o.token().startLine,i=o.token().startCol,this._readWhitespace(),o.mustMatch(Tokens.STRING),r=o.token(),t=r.value,this._readWhitespace(),o.mustMatch(Tokens.SEMICOLON),e!==!1&&this.fire({type:"charset",charset:t,line:n,col:i}))},_import:function(e){var t,r,n=this._tokenStream,i=[];n.mustMatch(Tokens.IMPORT_SYM),r=n.token(),this._readWhitespace(),n.mustMatch([Tokens.STRING,Tokens.URI]),t=n.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/,"$1"),this._readWhitespace(),i=this._media_query_list(),n.mustMatch(Tokens.SEMICOLON),this._readWhitespace(),e!==!1&&this.fire({type:"import",uri:t,media:i,line:r.startLine,col:r.startCol})},_namespace:function(e){var t,r,n,i,o=this._tokenStream;o.mustMatch(Tokens.NAMESPACE_SYM),t=o.token().startLine,r=o.token().startCol,this._readWhitespace(),o.match(Tokens.IDENT)&&(n=o.token().value,this._readWhitespace()),o.mustMatch([Tokens.STRING,Tokens.URI]),i=o.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/,"$1"),this._readWhitespace(),o.mustMatch(Tokens.SEMICOLON),this._readWhitespace(),e!==!1&&this.fire({type:"namespace",prefix:n,uri:i,line:t,col:r})},_media:function(){var e,t,r,n=this._tokenStream;for(n.mustMatch(Tokens.MEDIA_SYM),e=n.token().startLine,t=n.token().startCol,this._readWhitespace(),r=this._media_query_list(),n.mustMatch(Tokens.LBRACE),this._readWhitespace(),this.fire({type:"startmedia",media:r,line:e,col:t});;)if(n.peek()==Tokens.PAGE_SYM)this._page();else if(n.peek()==Tokens.FONT_FACE_SYM)this._font_face();else if(!this._ruleset())break;n.mustMatch(Tokens.RBRACE),this._readWhitespace(),this.fire({type:"endmedia",media:r,line:e,col:t})},_media_query_list:function(){var e=this._tokenStream,t=[];for(this._readWhitespace(),(e.peek()==Tokens.IDENT||e.peek()==Tokens.LPAREN)&&t.push(this._media_query());e.match(Tokens.COMMA);)this._readWhitespace(),t.push(this._media_query());return t},_media_query:function(){var e=this._tokenStream,t=null,r=null,n=null,i=[];if(e.match(Tokens.IDENT)&&(r=e.token().value.toLowerCase(),"only"!=r&&"not"!=r?(e.unget(),r=null):n=e.token()),this._readWhitespace(),e.peek()==Tokens.IDENT?(t=this._media_type(),null===n&&(n=e.token())):e.peek()==Tokens.LPAREN&&(null===n&&(n=e.LT(1)),i.push(this._media_expression())),null===t&&0===i.length)return null;for(this._readWhitespace();e.match(Tokens.IDENT);)"and"!=e.token().value.toLowerCase()&&this._unexpectedToken(e.token()),this._readWhitespace(),i.push(this._media_expression());return new MediaQuery(r,t,i,n.startLine,n.startCol)},_media_type:function(){return this._media_feature()},_media_expression:function(){var e,t=this._tokenStream,r=null,n=null;return t.mustMatch(Tokens.LPAREN),r=this._media_feature(),this._readWhitespace(),t.match(Tokens.COLON)&&(this._readWhitespace(),e=t.LT(1),n=this._expression()),t.mustMatch(Tokens.RPAREN),this._readWhitespace(),new MediaFeature(r,n?new SyntaxUnit(n,e.startLine,e.startCol):null)},_media_feature:function(){var e=this._tokenStream;return e.mustMatch(Tokens.IDENT),SyntaxUnit.fromToken(e.token())},_page:function(){var e,t,r=this._tokenStream,n=null,i=null;r.mustMatch(Tokens.PAGE_SYM),e=r.token().startLine,t=r.token().startCol,this._readWhitespace(),r.match(Tokens.IDENT)&&(n=r.token().value,"auto"===n.toLowerCase()&&this._unexpectedToken(r.token())),r.peek()==Tokens.COLON&&(i=this._pseudo_page()),this._readWhitespace(),this.fire({type:"startpage",id:n,pseudo:i,line:e,col:t}),this._readDeclarations(!0,!0),this.fire({type:"endpage",id:n,pseudo:i,line:e,col:t})},_margin:function(){var e,t,r=this._tokenStream,n=this._margin_sym();return n?(e=r.token().startLine,t=r.token().startCol,this.fire({type:"startpagemargin",margin:n,line:e,col:t}),this._readDeclarations(!0),this.fire({type:"endpagemargin",margin:n,line:e,col:t}),!0):!1},_margin_sym:function(){var e=this._tokenStream;return e.match([Tokens.TOPLEFTCORNER_SYM,Tokens.TOPLEFT_SYM,Tokens.TOPCENTER_SYM,Tokens.TOPRIGHT_SYM,Tokens.TOPRIGHTCORNER_SYM,Tokens.BOTTOMLEFTCORNER_SYM,Tokens.BOTTOMLEFT_SYM,Tokens.BOTTOMCENTER_SYM,Tokens.BOTTOMRIGHT_SYM,Tokens.BOTTOMRIGHTCORNER_SYM,Tokens.LEFTTOP_SYM,Tokens.LEFTMIDDLE_SYM,Tokens.LEFTBOTTOM_SYM,Tokens.RIGHTTOP_SYM,Tokens.RIGHTMIDDLE_SYM,Tokens.RIGHTBOTTOM_SYM])?SyntaxUnit.fromToken(e.token()):null},_pseudo_page:function(){var e=this._tokenStream;return e.mustMatch(Tokens.COLON),e.mustMatch(Tokens.IDENT),e.token().value},_font_face:function(){var e,t,r=this._tokenStream;r.mustMatch(Tokens.FONT_FACE_SYM),e=r.token().startLine,t=r.token().startCol,this._readWhitespace(),this.fire({type:"startfontface",line:e,col:t}),this._readDeclarations(!0),this.fire({type:"endfontface",line:e,col:t})},_viewport:function(){var e,t,r=this._tokenStream;r.mustMatch(Tokens.VIEWPORT_SYM),e=r.token().startLine,t=r.token().startCol,this._readWhitespace(),this.fire({type:"startviewport",line:e,col:t}),this._readDeclarations(!0),this.fire({type:"endviewport",line:e,col:t})},_operator:function(e){var t=this._tokenStream,r=null;return(t.match([Tokens.SLASH,Tokens.COMMA])||e&&t.match([Tokens.PLUS,Tokens.STAR,Tokens.MINUS]))&&(r=t.token(),this._readWhitespace()),r?PropertyValuePart.fromToken(r):null},_combinator:function(){var e,t=this._tokenStream,r=null;return t.match([Tokens.PLUS,Tokens.GREATER,Tokens.TILDE])&&(e=t.token(),r=new Combinator(e.value,e.startLine,e.startCol),this._readWhitespace()),r},_unary_operator:function(){var e=this._tokenStream;return e.match([Tokens.MINUS,Tokens.PLUS])?e.token().value:null},_property:function(){var e,t,r,n,i=this._tokenStream,o=null,a=null;return i.peek()==Tokens.STAR&&this.options.starHack&&(i.get(),t=i.token(),a=t.value,r=t.startLine,n=t.startCol),i.match(Tokens.IDENT)&&(t=i.token(),e=t.value,"_"==e.charAt(0)&&this.options.underscoreHack&&(a="_",e=e.substring(1)),o=new PropertyName(e,a,r||t.startLine,n||t.startCol),this._readWhitespace()),o},_ruleset:function(){var e,t,r=this._tokenStream;try{t=this._selectors_group()}catch(n){if(!(n instanceof SyntaxError)||this.options.strict)throw n;if(this.fire({type:"error",error:n,message:n.message,line:n.line,col:n.col}),e=r.advance([Tokens.RBRACE]),e!=Tokens.RBRACE)throw n;return!0}return t&&(this.fire({type:"startrule",selectors:t,line:t[0].line,col:t[0].col}),this._readDeclarations(!0),this.fire({type:"endrule",selectors:t,line:t[0].line,col:t[0].col})),t},_selectors_group:function(){var e,t=this._tokenStream,r=[];if(e=this._selector(),null!==e)for(r.push(e);t.match(Tokens.COMMA);)this._readWhitespace(),e=this._selector(),null!==e?r.push(e):this._unexpectedToken(t.LT(1));return r.length?r:null},_selector:function(){var e=this._tokenStream,t=[],r=null,n=null,i=null;if(r=this._simple_selector_sequence(),null===r)return null;for(t.push(r);;)if(n=this._combinator(),null!==n)t.push(n),r=this._simple_selector_sequence(),null===r?this._unexpectedToken(e.LT(1)):t.push(r);else{if(!this._readWhitespace())break;i=new Combinator(e.token().value,e.token().startLine,e.token().startCol),n=this._combinator(),r=this._simple_selector_sequence(),null===r?null!==n&&this._unexpectedToken(e.LT(1)):(null!==n?t.push(n):t.push(i),t.push(r))}return new Selector(t,t[0].line,t[0].col)},_simple_selector_sequence:function(){var e,t,r=this._tokenStream,n=null,i=[],o="",a=[function(){return r.match(Tokens.HASH)?new SelectorSubPart(r.token().value,"id",r.token().startLine,r.token().startCol):null},this._class,this._attrib,this._pseudo,this._negation],s=0,l=a.length,u=null;for(e=r.LT(1).startLine,t=r.LT(1).startCol,n=this._type_selector(),n||(n=this._universal()),null!==n&&(o+=n);;){if(r.peek()===Tokens.S)break;for(;l>s&&null===u;)u=a[s++].call(this);if(null===u){if(""===o)return null;break}s=0,i.push(u),o+=u.toString(),u=null}return""!==o?new SelectorPart(n,i,o,e,t):null},_type_selector:function(){var e=this._tokenStream,t=this._namespace_prefix(),r=this._element_name();return r?(t&&(r.text=t+r.text,r.col-=t.length),r):(t&&(e.unget(),t.length>1&&e.unget()),null)},_class:function(){var e,t=this._tokenStream;return t.match(Tokens.DOT)?(t.mustMatch(Tokens.IDENT),e=t.token(),new SelectorSubPart("."+e.value,"class",e.startLine,e.startCol-1)):null},_element_name:function(){var e,t=this._tokenStream;return t.match(Tokens.IDENT)?(e=t.token(),new SelectorSubPart(e.value,"elementName",e.startLine,e.startCol)):null},_namespace_prefix:function(){var e=this._tokenStream,t="";return(e.LA(1)===Tokens.PIPE||e.LA(2)===Tokens.PIPE)&&(e.match([Tokens.IDENT,Tokens.STAR])&&(t+=e.token().value),e.mustMatch(Tokens.PIPE),t+="|"),t.length?t:null},_universal:function(){var e,t=this._tokenStream,r="";return e=this._namespace_prefix(),e&&(r+=e),t.match(Tokens.STAR)&&(r+="*"),r.length?r:null},_attrib:function(){var e,t,r=this._tokenStream,n=null;return r.match(Tokens.LBRACKET)?(t=r.token(),n=t.value,n+=this._readWhitespace(),e=this._namespace_prefix(),e&&(n+=e),r.mustMatch(Tokens.IDENT),n+=r.token().value,n+=this._readWhitespace(),r.match([Tokens.PREFIXMATCH,Tokens.SUFFIXMATCH,Tokens.SUBSTRINGMATCH,Tokens.EQUALS,Tokens.INCLUDES,Tokens.DASHMATCH])&&(n+=r.token().value,n+=this._readWhitespace(),r.mustMatch([Tokens.IDENT,Tokens.STRING]),n+=r.token().value,n+=this._readWhitespace()),r.mustMatch(Tokens.RBRACKET),new SelectorSubPart(n+"]","attribute",t.startLine,t.startCol)):null},_pseudo:function(){var e,t,r=this._tokenStream,n=null,i=":";return r.match(Tokens.COLON)&&(r.match(Tokens.COLON)&&(i+=":"),r.match(Tokens.IDENT)?(n=r.token().value,e=r.token().startLine,t=r.token().startCol-i.length):r.peek()==Tokens.FUNCTION&&(e=r.LT(1).startLine,t=r.LT(1).startCol-i.length,n=this._functional_pseudo()),n&&(n=new SelectorSubPart(i+n,"pseudo",e,t))),n},_functional_pseudo:function(){var e=this._tokenStream,t=null;return e.match(Tokens.FUNCTION)&&(t=e.token().value,t+=this._readWhitespace(),t+=this._expression(),e.mustMatch(Tokens.RPAREN),t+=")"),t},_expression:function(){for(var e=this._tokenStream,t="";e.match([Tokens.PLUS,Tokens.MINUS,Tokens.DIMENSION,Tokens.NUMBER,Tokens.STRING,Tokens.IDENT,Tokens.LENGTH,Tokens.FREQ,Tokens.ANGLE,Tokens.TIME,Tokens.RESOLUTION,Tokens.SLASH]);)t+=e.token().value,t+=this._readWhitespace();return t.length?t:null},_negation:function(){var e,t,r,n=this._tokenStream,i="",o=null;return n.match(Tokens.NOT)&&(i=n.token().value,e=n.token().startLine,t=n.token().startCol,i+=this._readWhitespace(),r=this._negation_arg(),i+=r,i+=this._readWhitespace(),n.match(Tokens.RPAREN),i+=n.token().value,o=new SelectorSubPart(i,"not",e,t),o.args.push(r)),o},_negation_arg:function(){var e,t,r,n=this._tokenStream,i=[this._type_selector,this._universal,function(){return n.match(Tokens.HASH)?new SelectorSubPart(n.token().value,"id",n.token().startLine,n.token().startCol):null},this._class,this._attrib,this._pseudo],o=null,a=0,s=i.length;for(e=n.LT(1).startLine,t=n.LT(1).startCol;s>a&&null===o;)o=i[a].call(this),a++;return null===o&&this._unexpectedToken(n.LT(1)),r="elementName"==o.type?new SelectorPart(o,[],o.toString(),e,t):new SelectorPart(null,[o],o.toString(),e,t)},_declaration:function(){var e=this._tokenStream,t=null,r=null,n=null,i=null,o="";if(t=this._property(),null!==t){e.mustMatch(Tokens.COLON),this._readWhitespace(),r=this._expr(),r&&0!==r.length||this._unexpectedToken(e.LT(1)),n=this._prio(),o=t.toString(),(this.options.starHack&&"*"==t.hack||this.options.underscoreHack&&"_"==t.hack)&&(o=t.text);try{this._validateProperty(o,r)}catch(a){i=a}return this.fire({type:"property",property:t,value:r,important:n,line:t.line,col:t.col,invalid:i}),!0}return!1},_prio:function(){var e=this._tokenStream,t=e.match(Tokens.IMPORTANT_SYM);return this._readWhitespace(),t},_expr:function(e){var t=(this._tokenStream,[]),r=null,n=null;if(r=this._term(),null!==r)for(t.push(r);;){if(n=this._operator(e),n&&t.push(n),r=this._term(),null===r)break;t.push(r)}return t.length>0?new PropertyValue(t,t[0].line,t[0].col):null},_term:function(){var e,t,r,n=this._tokenStream,i=null,o=null;return i=this._unary_operator(),null!==i&&(t=n.token().startLine,r=n.token().startCol),n.peek()==Tokens.IE_FUNCTION&&this.options.ieFilters?(o=this._ie_function(),null===i&&(t=n.token().startLine,r=n.token().startCol)):n.match([Tokens.NUMBER,Tokens.PERCENTAGE,Tokens.LENGTH,Tokens.ANGLE,Tokens.TIME,Tokens.FREQ,Tokens.STRING,Tokens.IDENT,Tokens.URI,Tokens.UNICODE_RANGE])?(o=n.token().value,null===i&&(t=n.token().startLine,r=n.token().startCol),this._readWhitespace()):(e=this._hexcolor(),null===e?(null===i&&(t=n.LT(1).startLine,r=n.LT(1).startCol),null===o&&(o=n.LA(3)==Tokens.EQUALS&&this.options.ieFilters?this._ie_function():this._function())):(o=e.value,null===i&&(t=e.startLine,r=e.startCol))),null!==o?new PropertyValuePart(null!==i?i+o:o,t,r):null},_function:function(){var e,t=this._tokenStream,r=null,n=null;if(t.match(Tokens.FUNCTION)){if(r=t.token().value,this._readWhitespace(),n=this._expr(!0),r+=n,this.options.ieFilters&&t.peek()==Tokens.EQUALS)do for(this._readWhitespace()&&(r+=t.token().value),t.LA(0)==Tokens.COMMA&&(r+=t.token().value),t.match(Tokens.IDENT),r+=t.token().value,t.match(Tokens.EQUALS),r+=t.token().value,e=t.peek();e!=Tokens.COMMA&&e!=Tokens.S&&e!=Tokens.RPAREN;)t.get(),r+=t.token().value,e=t.peek();while(t.match([Tokens.COMMA,Tokens.S]));t.match(Tokens.RPAREN),r+=")",this._readWhitespace()}return r},_ie_function:function(){var e,t=this._tokenStream,r=null;if(t.match([Tokens.IE_FUNCTION,Tokens.FUNCTION])){r=t.token().value;do for(this._readWhitespace()&&(r+=t.token().value),t.LA(0)==Tokens.COMMA&&(r+=t.token().value),t.match(Tokens.IDENT),r+=t.token().value,t.match(Tokens.EQUALS),r+=t.token().value,e=t.peek();e!=Tokens.COMMA&&e!=Tokens.S&&e!=Tokens.RPAREN;)t.get(),r+=t.token().value,e=t.peek();while(t.match([Tokens.COMMA,Tokens.S]));t.match(Tokens.RPAREN),r+=")",this._readWhitespace()}return r},_hexcolor:function(){var e,t=this._tokenStream,r=null;if(t.match(Tokens.HASH)){if(r=t.token(),e=r.value,!/#[a-f0-9]{3,6}/i.test(e))throw new SyntaxError("Expected a hex color but found '"+e+"' at line "+r.startLine+", col "+r.startCol+".",r.startLine,r.startCol);this._readWhitespace()}return r},_keyframes:function(){var e,t,r,n=this._tokenStream,i="";for(n.mustMatch(Tokens.KEYFRAMES_SYM),e=n.token(),/^@\-([^\-]+)\-/.test(e.value)&&(i=RegExp.$1),this._readWhitespace(),r=this._keyframe_name(),
|
2 |
+
this._readWhitespace(),n.mustMatch(Tokens.LBRACE),this.fire({type:"startkeyframes",name:r,prefix:i,line:e.startLine,col:e.startCol}),this._readWhitespace(),t=n.peek();t==Tokens.IDENT||t==Tokens.PERCENTAGE;)this._keyframe_rule(),this._readWhitespace(),t=n.peek();this.fire({type:"endkeyframes",name:r,prefix:i,line:e.startLine,col:e.startCol}),this._readWhitespace(),n.mustMatch(Tokens.RBRACE)},_keyframe_name:function(){var e=this._tokenStream;return e.mustMatch([Tokens.IDENT,Tokens.STRING]),SyntaxUnit.fromToken(e.token())},_keyframe_rule:function(){var e=(this._tokenStream,this._key_list());this.fire({type:"startkeyframerule",keys:e,line:e[0].line,col:e[0].col}),this._readDeclarations(!0),this.fire({type:"endkeyframerule",keys:e,line:e[0].line,col:e[0].col})},_key_list:function(){var e=this._tokenStream,t=[];for(t.push(this._key()),this._readWhitespace();e.match(Tokens.COMMA);)this._readWhitespace(),t.push(this._key()),this._readWhitespace();return t},_key:function(){var e,t=this._tokenStream;if(t.match(Tokens.PERCENTAGE))return SyntaxUnit.fromToken(t.token());if(t.match(Tokens.IDENT)){if(e=t.token(),/from|to/i.test(e.value))return SyntaxUnit.fromToken(e);t.unget()}this._unexpectedToken(t.LT(1))},_skipCruft:function(){for(;this._tokenStream.match([Tokens.S,Tokens.CDO,Tokens.CDC]););},_readDeclarations:function(e,t){var r,n=this._tokenStream;this._readWhitespace(),e&&n.mustMatch(Tokens.LBRACE),this._readWhitespace();try{for(;;){if(n.match(Tokens.SEMICOLON)||t&&this._margin());else{if(!this._declaration())break;if(!n.match(Tokens.SEMICOLON))break}this._readWhitespace()}n.mustMatch(Tokens.RBRACE),this._readWhitespace()}catch(i){if(!(i instanceof SyntaxError)||this.options.strict)throw i;if(this.fire({type:"error",error:i,message:i.message,line:i.line,col:i.col}),r=n.advance([Tokens.SEMICOLON,Tokens.RBRACE]),r==Tokens.SEMICOLON)this._readDeclarations(!1,t);else if(r!=Tokens.RBRACE)throw i}},_readWhitespace:function(){for(var e=this._tokenStream,t="";e.match(Tokens.S);)t+=e.token().value;return t},_unexpectedToken:function(e){throw new SyntaxError("Unexpected token '"+e.value+"' at line "+e.startLine+", col "+e.startCol+".",e.startLine,e.startCol)},_verifyEnd:function(){this._tokenStream.LA(1)!=Tokens.EOF&&this._unexpectedToken(this._tokenStream.LT(1))},_validateProperty:function(e,t){Validation.validate(e,t)},parse:function(e){this._tokenStream=new TokenStream(e,Tokens),this._stylesheet()},parseStyleSheet:function(e){return this.parse(e)},parseMediaQuery:function(e){this._tokenStream=new TokenStream(e,Tokens);var t=this._media_query();return this._verifyEnd(),t},parsePropertyValue:function(e){this._tokenStream=new TokenStream(e,Tokens),this._readWhitespace();var t=this._expr();return this._readWhitespace(),this._verifyEnd(),t},parseRule:function(e){this._tokenStream=new TokenStream(e,Tokens),this._readWhitespace();var t=this._ruleset();return this._readWhitespace(),this._verifyEnd(),t},parseSelector:function(e){this._tokenStream=new TokenStream(e,Tokens),this._readWhitespace();var t=this._selector();return this._readWhitespace(),this._verifyEnd(),t},parseStyleAttribute:function(e){e+="}",this._tokenStream=new TokenStream(e,Tokens),this._readDeclarations()}};for(e in r)r.hasOwnProperty(e)&&(t[e]=r[e]);return t}();var Properties={"alignment-adjust":"auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>","alignment-baseline":"baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",animation:1,"animation-delay":{multi:"<time>",comma:!0},"animation-direction":{multi:"normal | alternate",comma:!0},"animation-duration":{multi:"<time>",comma:!0},"animation-iteration-count":{multi:"<number> | infinite",comma:!0},"animation-name":{multi:"none | <ident>",comma:!0},"animation-play-state":{multi:"running | paused",comma:!0},"animation-timing-function":1,"-moz-animation-delay":{multi:"<time>",comma:!0},"-moz-animation-direction":{multi:"normal | alternate",comma:!0},"-moz-animation-duration":{multi:"<time>",comma:!0},"-moz-animation-iteration-count":{multi:"<number> | infinite",comma:!0},"-moz-animation-name":{multi:"none | <ident>",comma:!0},"-moz-animation-play-state":{multi:"running | paused",comma:!0},"-ms-animation-delay":{multi:"<time>",comma:!0},"-ms-animation-direction":{multi:"normal | alternate",comma:!0},"-ms-animation-duration":{multi:"<time>",comma:!0},"-ms-animation-iteration-count":{multi:"<number> | infinite",comma:!0},"-ms-animation-name":{multi:"none | <ident>",comma:!0},"-ms-animation-play-state":{multi:"running | paused",comma:!0},"-webkit-animation-delay":{multi:"<time>",comma:!0},"-webkit-animation-direction":{multi:"normal | alternate",comma:!0},"-webkit-animation-duration":{multi:"<time>",comma:!0},"-webkit-animation-iteration-count":{multi:"<number> | infinite",comma:!0},"-webkit-animation-name":{multi:"none | <ident>",comma:!0},"-webkit-animation-play-state":{multi:"running | paused",comma:!0},"-o-animation-delay":{multi:"<time>",comma:!0},"-o-animation-direction":{multi:"normal | alternate",comma:!0},"-o-animation-duration":{multi:"<time>",comma:!0},"-o-animation-iteration-count":{multi:"<number> | infinite",comma:!0},"-o-animation-name":{multi:"none | <ident>",comma:!0},"-o-animation-play-state":{multi:"running | paused",comma:!0},appearance:"icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal | none | inherit",azimuth:function(e){var t,r="<angle> | leftwards | rightwards | inherit",n="left-side | far-left | left | center-left | center | center-right | right | far-right | right-side",i=!1,o=!1;if(ValidationTypes.isAny(e,r)||(ValidationTypes.isAny(e,"behind")&&(i=!0,o=!0),ValidationTypes.isAny(e,n)&&(o=!0,i||ValidationTypes.isAny(e,"behind"))),e.hasNext())throw t=e.next(),o?new ValidationError("Expected end of value but found '"+t+"'.",t.line,t.col):new ValidationError("Expected (<'azimuth'>) but found '"+t+"'.",t.line,t.col)},"backface-visibility":"visible | hidden",background:1,"background-attachment":{multi:"<attachment>",comma:!0},"background-clip":{multi:"<box>",comma:!0},"background-color":"<color> | inherit","background-image":{multi:"<bg-image>",comma:!0},"background-origin":{multi:"<box>",comma:!0},"background-position":{multi:"<bg-position>",comma:!0},"background-repeat":{multi:"<repeat-style>"},"background-size":{multi:"<bg-size>",comma:!0},"baseline-shift":"baseline | sub | super | <percentage> | <length>",behavior:1,binding:1,bleed:"<length>","bookmark-label":"<content> | <attr> | <string>","bookmark-level":"none | <integer>","bookmark-state":"open | closed","bookmark-target":"none | <uri> | <attr>",border:"<border-width> || <border-style> || <color>","border-bottom":"<border-width> || <border-style> || <color>","border-bottom-color":"<color> | inherit","border-bottom-left-radius":"<x-one-radius>","border-bottom-right-radius":"<x-one-radius>","border-bottom-style":"<border-style>","border-bottom-width":"<border-width>","border-collapse":"collapse | separate | inherit","border-color":{multi:"<color> | inherit",max:4},"border-image":1,"border-image-outset":{multi:"<length> | <number>",max:4},"border-image-repeat":{multi:"stretch | repeat | round",max:2},"border-image-slice":function(e){var t,r=!1,n="<number> | <percentage>",i=!1,o=0,a=4;for(ValidationTypes.isAny(e,"fill")&&(i=!0,r=!0);e.hasNext()&&a>o&&(r=ValidationTypes.isAny(e,n));)o++;if(i?r=!0:ValidationTypes.isAny(e,"fill"),e.hasNext())throw t=e.next(),r?new ValidationError("Expected end of value but found '"+t+"'.",t.line,t.col):new ValidationError("Expected ([<number> | <percentage>]{1,4} && fill?) but found '"+t+"'.",t.line,t.col)},"border-image-source":"<image> | none","border-image-width":{multi:"<length> | <percentage> | <number> | auto",max:4},"border-left":"<border-width> || <border-style> || <color>","border-left-color":"<color> | inherit","border-left-style":"<border-style>","border-left-width":"<border-width>","border-radius":function(e){for(var t,r=!1,n="<length> | <percentage> | inherit",i=!1,o=0,a=8;e.hasNext()&&a>o;){if(r=ValidationTypes.isAny(e,n),!r){if(!("/"==e.peek()&&o>0)||i)break;i=!0,a=o+5,e.next()}o++}if(e.hasNext())throw t=e.next(),r?new ValidationError("Expected end of value but found '"+t+"'.",t.line,t.col):new ValidationError("Expected (<'border-radius'>) but found '"+t+"'.",t.line,t.col)},"border-right":"<border-width> || <border-style> || <color>","border-right-color":"<color> | inherit","border-right-style":"<border-style>","border-right-width":"<border-width>","border-spacing":{multi:"<length> | inherit",max:2},"border-style":{multi:"<border-style>",max:4},"border-top":"<border-width> || <border-style> || <color>","border-top-color":"<color> | inherit","border-top-left-radius":"<x-one-radius>","border-top-right-radius":"<x-one-radius>","border-top-style":"<border-style>","border-top-width":"<border-width>","border-width":{multi:"<border-width>",max:4},bottom:"<margin-width> | inherit","box-align":"start | end | center | baseline | stretch","box-decoration-break":"slice |clone","box-direction":"normal | reverse | inherit","box-flex":"<number>","box-flex-group":"<integer>","box-lines":"single | multiple","box-ordinal-group":"<integer>","box-orient":"horizontal | vertical | inline-axis | block-axis | inherit","box-pack":"start | end | center | justify","box-shadow":function(e){var t;if(ValidationTypes.isAny(e,"none")){if(e.hasNext())throw t=e.next(),new ValidationError("Expected end of value but found '"+t+"'.",t.line,t.col)}else Validation.multiProperty("<shadow>",e,!0,1/0)},"box-sizing":"content-box | border-box | inherit","break-after":"auto | always | avoid | left | right | page | column | avoid-page | avoid-column","break-before":"auto | always | avoid | left | right | page | column | avoid-page | avoid-column","break-inside":"auto | avoid | avoid-page | avoid-column","caption-side":"top | bottom | inherit",clear:"none | right | left | both | inherit",clip:1,color:"<color> | inherit","color-profile":1,"column-count":"<integer> | auto","column-fill":"auto | balance","column-gap":"<length> | normal","column-rule":"<border-width> || <border-style> || <color>","column-rule-color":"<color>","column-rule-style":"<border-style>","column-rule-width":"<border-width>","column-span":"none | all","column-width":"<length> | auto",columns:1,content:1,"counter-increment":1,"counter-reset":1,crop:"<shape> | auto",cue:"cue-after | cue-before | inherit","cue-after":1,"cue-before":1,cursor:1,direction:"ltr | rtl | inherit",display:"inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | box | inline-box | grid | inline-grid | none | inherit | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box","dominant-baseline":1,"drop-initial-after-adjust":"central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>","drop-initial-after-align":"baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical","drop-initial-before-adjust":"before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length>","drop-initial-before-align":"caps-height | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical","drop-initial-size":"auto | line | <length> | <percentage>","drop-initial-value":"initial | <integer>",elevation:"<angle> | below | level | above | higher | lower | inherit","empty-cells":"show | hide | inherit",filter:1,fit:"fill | hidden | meet | slice","fit-position":1,"float":"left | right | none | inherit","float-offset":1,font:1,"font-family":1,"font-size":"<absolute-size> | <relative-size> | <length> | <percentage> | inherit","font-size-adjust":"<number> | none | inherit","font-stretch":"normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | inherit","font-style":"normal | italic | oblique | inherit","font-variant":"normal | small-caps | inherit","font-weight":"normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit","grid-cell-stacking":"columns | rows | layer","grid-column":1,"grid-columns":1,"grid-column-align":"start | end | center | stretch","grid-column-sizing":1,"grid-column-span":"<integer>","grid-flow":"none | rows | columns","grid-layer":"<integer>","grid-row":1,"grid-rows":1,"grid-row-align":"start | end | center | stretch","grid-row-span":"<integer>","grid-row-sizing":1,"hanging-punctuation":1,height:"<margin-width> | inherit","hyphenate-after":"<integer> | auto","hyphenate-before":"<integer> | auto","hyphenate-character":"<string> | auto","hyphenate-lines":"no-limit | <integer>","hyphenate-resource":1,hyphens:"none | manual | auto",icon:1,"image-orientation":"angle | auto","image-rendering":1,"image-resolution":1,"inline-box-align":"initial | last | <integer>",left:"<margin-width> | inherit","letter-spacing":"<length> | normal | inherit","line-height":"<number> | <length> | <percentage> | normal | inherit","line-break":"auto | loose | normal | strict","line-stacking":1,"line-stacking-ruby":"exclude-ruby | include-ruby","line-stacking-shift":"consider-shifts | disregard-shifts","line-stacking-strategy":"inline-line-height | block-line-height | max-height | grid-height","list-style":1,"list-style-image":"<uri> | none | inherit","list-style-position":"inside | outside | inherit","list-style-type":"disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none | inherit",margin:{multi:"<margin-width> | inherit",max:4},"margin-bottom":"<margin-width> | inherit","margin-left":"<margin-width> | inherit","margin-right":"<margin-width> | inherit","margin-top":"<margin-width> | inherit",mark:1,"mark-after":1,"mark-before":1,marks:1,"marquee-direction":1,"marquee-play-count":1,"marquee-speed":1,"marquee-style":1,"max-height":"<length> | <percentage> | none | inherit","max-width":"<length> | <percentage> | none | inherit","min-height":"<length> | <percentage> | inherit","min-width":"<length> | <percentage> | inherit","move-to":1,"nav-down":1,"nav-index":1,"nav-left":1,"nav-right":1,"nav-up":1,opacity:"<number> | inherit",orphans:"<integer> | inherit",outline:1,"outline-color":"<color> | invert | inherit","outline-offset":1,"outline-style":"<border-style> | inherit","outline-width":"<border-width> | inherit",overflow:"visible | hidden | scroll | auto | inherit","overflow-style":1,"overflow-x":1,"overflow-y":1,padding:{multi:"<padding-width> | inherit",max:4},"padding-bottom":"<padding-width> | inherit","padding-left":"<padding-width> | inherit","padding-right":"<padding-width> | inherit","padding-top":"<padding-width> | inherit",page:1,"page-break-after":"auto | always | avoid | left | right | inherit","page-break-before":"auto | always | avoid | left | right | inherit","page-break-inside":"auto | avoid | inherit","page-policy":1,pause:1,"pause-after":1,"pause-before":1,perspective:1,"perspective-origin":1,phonemes:1,pitch:1,"pitch-range":1,"play-during":1,"pointer-events":"auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | inherit",position:"static | relative | absolute | fixed | inherit","presentation-level":1,"punctuation-trim":1,quotes:1,"rendering-intent":1,resize:1,rest:1,"rest-after":1,"rest-before":1,richness:1,right:"<margin-width> | inherit",rotation:1,"rotation-point":1,"ruby-align":1,"ruby-overhang":1,"ruby-position":1,"ruby-span":1,size:1,speak:"normal | none | spell-out | inherit","speak-header":"once | always | inherit","speak-numeral":"digits | continuous | inherit","speak-punctuation":"code | none | inherit","speech-rate":1,src:1,stress:1,"string-set":1,"table-layout":"auto | fixed | inherit","tab-size":"<integer> | <length>",target:1,"target-name":1,"target-new":1,"target-position":1,"text-align":"left | right | center | justify | inherit","text-align-last":1,"text-decoration":1,"text-emphasis":1,"text-height":1,"text-indent":"<length> | <percentage> | inherit","text-justify":"auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida","text-outline":1,"text-overflow":1,"text-rendering":"auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit","text-shadow":1,"text-transform":"capitalize | uppercase | lowercase | none | inherit","text-wrap":"normal | none | avoid",top:"<margin-width> | inherit",transform:1,"transform-origin":1,"transform-style":1,transition:1,"transition-delay":1,"transition-duration":1,"transition-property":1,"transition-timing-function":1,"unicode-bidi":"normal | embed | bidi-override | inherit","user-modify":"read-only | read-write | write-only | inherit","user-select":"none | text | toggle | element | elements | all | inherit","vertical-align":"auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length>",visibility:"visible | hidden | collapse | inherit","voice-balance":1,"voice-duration":1,"voice-family":1,"voice-pitch":1,"voice-pitch-range":1,"voice-rate":1,"voice-stress":1,"voice-volume":1,volume:1,"white-space":"normal | pre | nowrap | pre-wrap | pre-line | inherit | -pre-wrap | -o-pre-wrap | -moz-pre-wrap | -hp-pre-wrap","white-space-collapse":1,widows:"<integer> | inherit",width:"<length> | <percentage> | auto | inherit","word-break":"normal | keep-all | break-all","word-spacing":"<length> | normal | inherit","word-wrap":1,"z-index":"<integer> | auto | inherit",zoom:"<number> | <percentage> | normal"};PropertyName.prototype=new SyntaxUnit,PropertyName.prototype.constructor=PropertyName,PropertyName.prototype.toString=function(){return(this.hack?this.hack:"")+this.text},PropertyValue.prototype=new SyntaxUnit,PropertyValue.prototype.constructor=PropertyValue,PropertyValueIterator.prototype.count=function(){return this._parts.length},PropertyValueIterator.prototype.isFirst=function(){return 0===this._i},PropertyValueIterator.prototype.hasNext=function(){return this._i<this._parts.length},PropertyValueIterator.prototype.mark=function(){this._marks.push(this._i)},PropertyValueIterator.prototype.peek=function(e){return this.hasNext()?this._parts[this._i+(e||0)]:null},PropertyValueIterator.prototype.next=function(){return this.hasNext()?this._parts[this._i++]:null},PropertyValueIterator.prototype.previous=function(){return this._i>0?this._parts[--this._i]:null},PropertyValueIterator.prototype.restore=function(){this._marks.length&&(this._i=this._marks.pop())},PropertyValuePart.prototype=new SyntaxUnit,PropertyValuePart.prototype.constructor=PropertyValuePart,PropertyValuePart.fromToken=function(e){return new PropertyValuePart(e.value,e.startLine,e.startCol)};var Pseudos={":first-letter":1,":first-line":1,":before":1,":after":1};Pseudos.ELEMENT=1,Pseudos.CLASS=2,Pseudos.isElement=function(e){return 0===e.indexOf("::")||Pseudos[e.toLowerCase()]==Pseudos.ELEMENT},Selector.prototype=new SyntaxUnit,Selector.prototype.constructor=Selector,SelectorPart.prototype=new SyntaxUnit,SelectorPart.prototype.constructor=SelectorPart,SelectorSubPart.prototype=new SyntaxUnit,SelectorSubPart.prototype.constructor=SelectorSubPart,Specificity.prototype={constructor:Specificity,compare:function(e){var t,r,n=["a","b","c","d"];for(t=0,r=n.length;r>t;t++){if(this[n[t]]<e[n[t]])return-1;if(this[n[t]]>e[n[t]])return 1}return 0},valueOf:function(){return 1e3*this.a+100*this.b+10*this.c+this.d},toString:function(){return this.a+","+this.b+","+this.c+","+this.d}},Specificity.calculate=function(e){function t(e){var r,n,i,l,u,d=e.elementName?e.elementName.text:"";for(d&&"*"!=d.charAt(d.length-1)&&s++,r=0,i=e.modifiers.length;i>r;r++)switch(u=e.modifiers[r],u.type){case"class":case"attribute":a++;break;case"id":o++;break;case"pseudo":Pseudos.isElement(u.text)?s++:a++;break;case"not":for(n=0,l=u.args.length;l>n;n++)t(u.args[n])}}var r,n,i,o=0,a=0,s=0;for(r=0,n=e.parts.length;n>r;r++)i=e.parts[r],i instanceof SelectorPart&&t(i);return new Specificity(0,o,a,s)};var h=/^[0-9a-fA-F]$/,nonascii=/^[\u0080-\uFFFF]$/,nl=/\n|\r\n|\r|\f/;TokenStream.prototype=mix(new TokenStreamBase,{_getToken:function(e){var t,r=this._reader,n=null,i=r.getLine(),o=r.getCol();for(t=r.read();t;){switch(t){case"/":n="*"==r.peek()?this.commentToken(t,i,o):this.charToken(t,i,o);break;case"|":case"~":case"^":case"$":case"*":n="="==r.peek()?this.comparisonToken(t,i,o):this.charToken(t,i,o);break;case'"':case"'":n=this.stringToken(t,i,o);break;case"#":n=isNameChar(r.peek())?this.hashToken(t,i,o):this.charToken(t,i,o);break;case".":n=isDigit(r.peek())?this.numberToken(t,i,o):this.charToken(t,i,o);break;case"-":n="-"==r.peek()?this.htmlCommentEndToken(t,i,o):isNameStart(r.peek())?this.identOrFunctionToken(t,i,o):this.charToken(t,i,o);break;case"!":n=this.importantToken(t,i,o);break;case"@":n=this.atRuleToken(t,i,o);break;case":":n=this.notToken(t,i,o);break;case"<":n=this.htmlCommentStartToken(t,i,o);break;case"U":case"u":if("+"==r.peek()){n=this.unicodeRangeToken(t,i,o);break}default:n=isDigit(t)?this.numberToken(t,i,o):isWhitespace(t)?this.whitespaceToken(t,i,o):isIdentStart(t)?this.identOrFunctionToken(t,i,o):this.charToken(t,i,o)}break}return n||null!==t||(n=this.createToken(Tokens.EOF,null,i,o)),n},createToken:function(e,t,r,n,i){var o=this._reader;return i=i||{},{value:t,type:e,channel:i.channel,hide:i.hide||!1,startLine:r,startCol:n,endLine:o.getLine(),endCol:o.getCol()}},atRuleToken:function(e,t,r){var n,i=e,o=this._reader,a=Tokens.CHAR;return o.mark(),n=this.readName(),i=e+n,a=Tokens.type(i.toLowerCase()),(a==Tokens.CHAR||a==Tokens.UNKNOWN)&&(i.length>1?a=Tokens.UNKNOWN_SYM:(a=Tokens.CHAR,i=e,o.reset())),this.createToken(a,i,t,r)},charToken:function(e,t,r){var n=Tokens.type(e);return-1==n&&(n=Tokens.CHAR),this.createToken(n,e,t,r)},commentToken:function(e,t,r){var n=(this._reader,this.readComment(e));return this.createToken(Tokens.COMMENT,n,t,r)},comparisonToken:function(e,t,r){var n=this._reader,i=e+n.read(),o=Tokens.type(i)||Tokens.CHAR;return this.createToken(o,i,t,r)},hashToken:function(e,t,r){var n=(this._reader,this.readName(e));return this.createToken(Tokens.HASH,n,t,r)},htmlCommentStartToken:function(e,t,r){var n=this._reader,i=e;return n.mark(),i+=n.readCount(3),"<!--"==i?this.createToken(Tokens.CDO,i,t,r):(n.reset(),this.charToken(e,t,r))},htmlCommentEndToken:function(e,t,r){var n=this._reader,i=e;return n.mark(),i+=n.readCount(2),"-->"==i?this.createToken(Tokens.CDC,i,t,r):(n.reset(),this.charToken(e,t,r))},identOrFunctionToken:function(e,t,r){var n=this._reader,i=this.readName(e),o=Tokens.IDENT;return"("==n.peek()?(i+=n.read(),"url("==i.toLowerCase()?(o=Tokens.URI,i=this.readURI(i),"url("==i.toLowerCase()&&(o=Tokens.FUNCTION)):o=Tokens.FUNCTION):":"==n.peek()&&"progid"==i.toLowerCase()&&(i+=n.readTo("("),o=Tokens.IE_FUNCTION),this.createToken(o,i,t,r)},importantToken:function(e,t,r){var n,i,o=this._reader,a=e,s=Tokens.CHAR;for(o.mark(),i=o.read();i;){if("/"==i){if("*"!=o.peek())break;if(n=this.readComment(i),""===n)break}else{if(!isWhitespace(i)){if(/i/i.test(i)){n=o.readCount(8),/mportant/i.test(n)&&(a+=i+n,s=Tokens.IMPORTANT_SYM);break}break}a+=i+this.readWhitespace()}i=o.read()}return s==Tokens.CHAR?(o.reset(),this.charToken(e,t,r)):this.createToken(s,a,t,r)},notToken:function(e,t,r){var n=this._reader,i=e;return n.mark(),i+=n.readCount(4),":not("==i.toLowerCase()?this.createToken(Tokens.NOT,i,t,r):(n.reset(),this.charToken(e,t,r))},numberToken:function(e,t,r){var n,i=this._reader,o=this.readNumber(e),a=Tokens.NUMBER,s=i.peek();return isIdentStart(s)?(n=this.readName(i.read()),o+=n,a=/^em$|^ex$|^px$|^gd$|^rem$|^vw$|^vh$|^vm$|^ch$|^cm$|^mm$|^in$|^pt$|^pc$/i.test(n)?Tokens.LENGTH:/^deg|^rad$|^grad$/i.test(n)?Tokens.ANGLE:/^ms$|^s$/i.test(n)?Tokens.TIME:/^hz$|^khz$/i.test(n)?Tokens.FREQ:/^dpi$|^dpcm$/i.test(n)?Tokens.RESOLUTION:Tokens.DIMENSION):"%"==s&&(o+=i.read(),a=Tokens.PERCENTAGE),this.createToken(a,o,t,r)},stringToken:function(e,t,r){for(var n=e,i=e,o=this._reader,a=e,s=Tokens.STRING,l=o.read();l&&(i+=l,l!=n||"\\"==a);){if(isNewLine(o.peek())&&"\\"!=l){s=Tokens.INVALID;break}a=l,l=o.read()}return null===l&&(s=Tokens.INVALID),this.createToken(s,i,t,r)},unicodeRangeToken:function(e,t,r){var n,i=this._reader,o=e,a=Tokens.CHAR;return"+"==i.peek()&&(i.mark(),o+=i.read(),o+=this.readUnicodeRangePart(!0),2==o.length?i.reset():(a=Tokens.UNICODE_RANGE,-1==o.indexOf("?")&&"-"==i.peek()&&(i.mark(),n=i.read(),n+=this.readUnicodeRangePart(!1),1==n.length?i.reset():o+=n))),this.createToken(a,o,t,r)},whitespaceToken:function(e,t,r){var n=(this._reader,e+this.readWhitespace());return this.createToken(Tokens.S,n,t,r)},readUnicodeRangePart:function(e){for(var t=this._reader,r="",n=t.peek();isHexDigit(n)&&r.length<6;)t.read(),r+=n,n=t.peek();if(e)for(;"?"==n&&r.length<6;)t.read(),r+=n,n=t.peek();return r},readWhitespace:function(){for(var e=this._reader,t="",r=e.peek();isWhitespace(r);)e.read(),t+=r,r=e.peek();return t},readNumber:function(e){for(var t=this._reader,r=e,n="."==e,i=t.peek();i;){if(isDigit(i))r+=t.read();else{if("."!=i)break;if(n)break;n=!0,r+=t.read()}i=t.peek()}return r},readString:function(){for(var e=this._reader,t=e.read(),r=t,n=t,i=e.peek();i&&(i=e.read(),r+=i,i!=t||"\\"==n);){if(isNewLine(e.peek())&&"\\"!=i){r="";break}n=i,i=e.peek()}return null===i&&(r=""),r},readURI:function(e){var t=this._reader,r=e,n="",i=t.peek();for(t.mark();i&&isWhitespace(i);)t.read(),i=t.peek();for(n="'"==i||'"'==i?this.readString():this.readURL(),i=t.peek();i&&isWhitespace(i);)t.read(),i=t.peek();return""===n||")"!=i?(r=e,t.reset()):r+=n+t.read(),r},readURL:function(){for(var e=this._reader,t="",r=e.peek();/^[!#$%&\\*-~]$/.test(r);)t+=e.read(),r=e.peek();return t},readName:function(e){for(var t=this._reader,r=e||"",n=t.peek();;)if("\\"==n)r+=this.readEscape(t.read()),n=t.peek();else{if(!n||!isNameChar(n))break;r+=t.read(),n=t.peek()}return r},readEscape:function(e){var t=this._reader,r=e||"",n=0,i=t.peek();if(isHexDigit(i))do r+=t.read(),i=t.peek();while(i&&isHexDigit(i)&&++n<6);return 3==r.length&&/\s/.test(i)||7==r.length||1==r.length?t.read():i="",r+i},readComment:function(e){var t=this._reader,r=e||"",n=t.read();if("*"==n){for(;n;){if(r+=n,r.length>2&&"*"==n&&"/"==t.peek()){r+=t.read();break}n=t.read()}return r}return""}});var Tokens=[{name:"CDO"},{name:"CDC"},{name:"S",whitespace:!0},{name:"COMMENT",comment:!0,hide:!0,channel:"comment"},{name:"INCLUDES",text:"~="},{name:"DASHMATCH",text:"|="},{name:"PREFIXMATCH",text:"^="},{name:"SUFFIXMATCH",text:"$="},{name:"SUBSTRINGMATCH",text:"*="},{name:"STRING"},{name:"IDENT"},{name:"HASH"},{name:"IMPORT_SYM",text:"@import"},{name:"PAGE_SYM",text:"@page"},{name:"MEDIA_SYM",text:"@media"},{name:"FONT_FACE_SYM",text:"@font-face"},{name:"CHARSET_SYM",text:"@charset"},{name:"NAMESPACE_SYM",text:"@namespace"},{name:"VIEWPORT_SYM",text:"@viewport"},{name:"UNKNOWN_SYM"},{name:"KEYFRAMES_SYM",text:["@keyframes","@-webkit-keyframes","@-moz-keyframes","@-o-keyframes"]},{name:"IMPORTANT_SYM"},{name:"LENGTH"},{name:"ANGLE"},{name:"TIME"},{name:"FREQ"},{name:"DIMENSION"},{name:"PERCENTAGE"},{name:"NUMBER"},{name:"URI"},{name:"FUNCTION"},{name:"UNICODE_RANGE"},{name:"INVALID"},{name:"PLUS",text:"+"},{name:"GREATER",text:">"},{name:"COMMA",text:","},{name:"TILDE",text:"~"},{name:"NOT"},{name:"TOPLEFTCORNER_SYM",text:"@top-left-corner"},{name:"TOPLEFT_SYM",text:"@top-left"},{name:"TOPCENTER_SYM",text:"@top-center"},{name:"TOPRIGHT_SYM",text:"@top-right"},{name:"TOPRIGHTCORNER_SYM",text:"@top-right-corner"},{name:"BOTTOMLEFTCORNER_SYM",text:"@bottom-left-corner"},{name:"BOTTOMLEFT_SYM",text:"@bottom-left"},{name:"BOTTOMCENTER_SYM",text:"@bottom-center"},{name:"BOTTOMRIGHT_SYM",text:"@bottom-right"},{name:"BOTTOMRIGHTCORNER_SYM",text:"@bottom-right-corner"},{name:"LEFTTOP_SYM",text:"@left-top"},{name:"LEFTMIDDLE_SYM",text:"@left-middle"},{name:"LEFTBOTTOM_SYM",text:"@left-bottom"},{name:"RIGHTTOP_SYM",text:"@right-top"},{name:"RIGHTMIDDLE_SYM",text:"@right-middle"},{name:"RIGHTBOTTOM_SYM",text:"@right-bottom"},{name:"RESOLUTION",state:"media"},{name:"IE_FUNCTION"},{name:"CHAR"},{name:"PIPE",text:"|"},{name:"SLASH",text:"/"},{name:"MINUS",text:"-"},{name:"STAR",text:"*"},{name:"LBRACE",text:"{"},{name:"RBRACE",text:"}"},{name:"LBRACKET",text:"["},{name:"RBRACKET",text:"]"},{name:"EQUALS",text:"="},{name:"COLON",text:":"},{name:"SEMICOLON",text:";"},{name:"LPAREN",text:"("},{name:"RPAREN",text:")"},{name:"DOT",text:"."}];!function(){var e=[],t={};Tokens.UNKNOWN=-1,Tokens.unshift({name:"EOF"});for(var r=0,n=Tokens.length;n>r;r++)if(e.push(Tokens[r].name),Tokens[Tokens[r].name]=r,Tokens[r].text)if(Tokens[r].text instanceof Array)for(var i=0;i<Tokens[r].text.length;i++)t[Tokens[r].text[i]]=r;else t[Tokens[r].text]=r;Tokens.name=function(t){return e[t]},Tokens.type=function(e){return t[e]||-1}}();var Validation={validate:function(e,t){var r=e.toString().toLowerCase(),n=(t.parts,new PropertyValueIterator(t)),i=Properties[r];if(i)"number"!=typeof i&&("string"==typeof i?i.indexOf("||")>-1?this.groupProperty(i,n):this.singleProperty(i,n,1):i.multi?this.multiProperty(i.multi,n,i.comma,i.max||1/0):"function"==typeof i&&i(n));else if(0!==r.indexOf("-"))throw new ValidationError("Unknown property '"+e+"'.",e.line,e.col)},singleProperty:function(e,t,r,n){for(var i,o=!1,a=t.value,s=0;t.hasNext()&&r>s&&(o=ValidationTypes.isAny(t,e));)s++;if(!o)throw t.hasNext()&&!t.isFirst()?(i=t.peek(),new ValidationError("Expected end of value but found '"+i+"'.",i.line,i.col)):new ValidationError("Expected ("+e+") but found '"+a+"'.",a.line,a.col);if(t.hasNext())throw i=t.next(),new ValidationError("Expected end of value but found '"+i+"'.",i.line,i.col)},multiProperty:function(e,t,r,n){for(var i,o=!1,a=t.value,s=0;t.hasNext()&&!o&&n>s&&ValidationTypes.isAny(t,e);)if(s++,t.hasNext()){if(r){if(","!=t.peek())break;i=t.next()}}else o=!0;if(!o)throw t.hasNext()&&!t.isFirst()?(i=t.peek(),new ValidationError("Expected end of value but found '"+i+"'.",i.line,i.col)):(i=t.previous(),r&&","==i?new ValidationError("Expected end of value but found '"+i+"'.",i.line,i.col):new ValidationError("Expected ("+e+") but found '"+a+"'.",a.line,a.col));if(t.hasNext())throw i=t.next(),new ValidationError("Expected end of value but found '"+i+"'.",i.line,i.col)},groupProperty:function(e,t,r){for(var n,i,o=!1,a=t.value,s=e.split("||").length,l={count:0},u=!1;t.hasNext()&&!o&&(n=ValidationTypes.isAnyOfGroup(t,e))&&!l[n];)l[n]=1,l.count++,u=!0,l.count!=s&&t.hasNext()||(o=!0);if(!o)throw u&&t.hasNext()?(i=t.peek(),new ValidationError("Expected end of value but found '"+i+"'.",i.line,i.col)):new ValidationError("Expected ("+e+") but found '"+a+"'.",a.line,a.col);if(t.hasNext())throw i=t.next(),new ValidationError("Expected end of value but found '"+i+"'.",i.line,i.col)}};ValidationError.prototype=new Error;var ValidationTypes={isLiteral:function(e,t){var r,n,i=e.text.toString().toLowerCase(),o=t.split(" | "),a=!1;for(r=0,n=o.length;n>r&&!a;r++)i==o[r].toLowerCase()&&(a=!0);return a},isSimple:function(e){return!!this.simple[e]},isComplex:function(e){return!!this.complex[e];
|
3 |
+
},isAny:function(e,t){var r,n,i=t.split(" | "),o=!1;for(r=0,n=i.length;n>r&&!o&&e.hasNext();r++)o=this.isType(e,i[r]);return o},isAnyOfGroup:function(e,t){var r,n,i=t.split(" || "),o=!1;for(r=0,n=i.length;n>r&&!o;r++)o=this.isType(e,i[r]);return o?i[r-1]:!1},isType:function(e,t){var r=e.peek(),n=!1;return"<"!=t.charAt(0)?(n=this.isLiteral(r,t),n&&e.next()):this.simple[t]?(n=this.simple[t](r),n&&e.next()):n=this.complex[t](e),n},simple:{"<absolute-size>":function(e){return ValidationTypes.isLiteral(e,"xx-small | x-small | small | medium | large | x-large | xx-large")},"<attachment>":function(e){return ValidationTypes.isLiteral(e,"scroll | fixed | local")},"<attr>":function(e){return"function"==e.type&&"attr"==e.name},"<bg-image>":function(e){return this["<image>"](e)||this["<gradient>"](e)||"none"==e},"<gradient>":function(e){return"function"==e.type&&/^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(e)},"<box>":function(e){return ValidationTypes.isLiteral(e,"padding-box | border-box | content-box")},"<content>":function(e){return"function"==e.type&&"content"==e.name},"<relative-size>":function(e){return ValidationTypes.isLiteral(e,"smaller | larger")},"<ident>":function(e){return"identifier"==e.type},"<length>":function(e){return"function"==e.type&&/^(?:\-(?:ms|moz|o|webkit)\-)?calc/i.test(e)?!0:"length"==e.type||"number"==e.type||"integer"==e.type||"0"==e},"<color>":function(e){return"color"==e.type||"transparent"==e},"<number>":function(e){return"number"==e.type||this["<integer>"](e)},"<integer>":function(e){return"integer"==e.type},"<line>":function(e){return"integer"==e.type},"<angle>":function(e){return"angle"==e.type},"<uri>":function(e){return"uri"==e.type},"<image>":function(e){return this["<uri>"](e)},"<percentage>":function(e){return"percentage"==e.type||"0"==e},"<border-width>":function(e){return this["<length>"](e)||ValidationTypes.isLiteral(e,"thin | medium | thick")},"<border-style>":function(e){return ValidationTypes.isLiteral(e,"none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset")},"<margin-width>":function(e){return this["<length>"](e)||this["<percentage>"](e)||ValidationTypes.isLiteral(e,"auto")},"<padding-width>":function(e){return this["<length>"](e)||this["<percentage>"](e)},"<shape>":function(e){return"function"==e.type&&("rect"==e.name||"inset-rect"==e.name)},"<time>":function(e){return"time"==e.type}},complex:{"<bg-position>":function(e){for(var t=!1,r="<percentage> | <length>",n="left | right",i="top | bottom",o=0;e.peek(o)&&","!=e.peek(o);)o++;return 3>o?ValidationTypes.isAny(e,n+" | center | "+r)?(t=!0,ValidationTypes.isAny(e,i+" | center | "+r)):ValidationTypes.isAny(e,i)&&(t=!0,ValidationTypes.isAny(e,n+" | center")):ValidationTypes.isAny(e,n)?ValidationTypes.isAny(e,i)?(t=!0,ValidationTypes.isAny(e,r)):ValidationTypes.isAny(e,r)&&(ValidationTypes.isAny(e,i)?(t=!0,ValidationTypes.isAny(e,r)):ValidationTypes.isAny(e,"center")&&(t=!0)):ValidationTypes.isAny(e,i)?ValidationTypes.isAny(e,n)?(t=!0,ValidationTypes.isAny(e,r)):ValidationTypes.isAny(e,r)&&(ValidationTypes.isAny(e,n)?(t=!0,ValidationTypes.isAny(e,r)):ValidationTypes.isAny(e,"center")&&(t=!0)):ValidationTypes.isAny(e,"center")&&ValidationTypes.isAny(e,n+" | "+i)&&(t=!0,ValidationTypes.isAny(e,r)),t},"<bg-size>":function(e){var t=!1,r="<percentage> | <length> | auto";return ValidationTypes.isAny(e,"cover | contain")?t=!0:ValidationTypes.isAny(e,r)&&(t=!0,ValidationTypes.isAny(e,r)),t},"<repeat-style>":function(e){var t,r=!1,n="repeat | space | round | no-repeat";return e.hasNext()&&(t=e.next(),ValidationTypes.isLiteral(t,"repeat-x | repeat-y")?r=!0:ValidationTypes.isLiteral(t,n)&&(r=!0,e.hasNext()&&ValidationTypes.isLiteral(e.peek(),n)&&e.next())),r},"<shadow>":function(e){var t=!1,r=0,n=!1,i=!1;if(e.hasNext()){for(ValidationTypes.isAny(e,"inset")&&(n=!0),ValidationTypes.isAny(e,"<color>")&&(i=!0);ValidationTypes.isAny(e,"<length>")&&4>r;)r++;e.hasNext()&&(i||ValidationTypes.isAny(e,"<color>"),n||ValidationTypes.isAny(e,"inset")),t=r>=2&&4>=r}return t},"<x-one-radius>":function(e){var t=!1,r="<length> | <percentage> | inherit";return ValidationTypes.isAny(e,r)&&(t=!0,ValidationTypes.isAny(e,r)),t}}};parserlib.css={Colors:Colors,Combinator:Combinator,Parser:Parser,PropertyName:PropertyName,PropertyValue:PropertyValue,PropertyValuePart:PropertyValuePart,MediaFeature:MediaFeature,MediaQuery:MediaQuery,Selector:Selector,SelectorPart:SelectorPart,SelectorSubPart:SelectorSubPart,Specificity:Specificity,TokenStream:TokenStream,Tokens:Tokens,ValidationError:ValidationError}}(),function(){for(var e in parserlib)exports[e]=parserlib[e]}();var CSSLint=function(){function e(e,t){var r,i=e&&e.match(n),o=i&&i[1];return o&&(r={"true":2,"":1,"false":0,2:2,1:1,0:0},o.toLowerCase().split(",").forEach(function(e){var n=e.split(":"),i=n[0]||"",o=n[1]||"";t[i.trim()]=r[o.trim()]})),t}var t=[],r=[],n=/\/\*csslint([^\*]*)\*\//,i=new parserlib.util.EventTarget;return i.version="0.10.0",i.addRule=function(e){t.push(e),t[e.id]=e},i.clearRules=function(){t=[]},i.getRules=function(){return[].concat(t).sort(function(e,t){return e.id>t.id?1:0})},i.getRuleset=function(){for(var e={},r=0,n=t.length;n>r;)e[t[r++].id]=1;return e},i.addFormatter=function(e){r[e.id]=e},i.getFormatter=function(e){return r[e]},i.format=function(e,t,r,n){var i=this.getFormatter(r),o=null;return i&&(o=i.startFormat(),o+=i.formatResults(e,t,n||{}),o+=i.endFormat()),o},i.hasFormat=function(e){return r.hasOwnProperty(e)},i.verify=function(r,i){var o,a,s,l=0,u=(t.length,new parserlib.css.Parser({starHack:!0,ieFilters:!0,underscoreHack:!0,strict:!1}));a=r.replace(/\n\r?/g,"$split$").split("$split$"),i||(i=this.getRuleset()),n.test(r)&&(i=e(r,i)),o=new Reporter(a,i),i.errors=2;for(l in i)i.hasOwnProperty(l)&&i[l]&&t[l]&&t[l].init(u,o);try{u.parse(r)}catch(d){o.error("Fatal error, cannot continue: "+d.message,d.line,d.col,{})}return s={messages:o.messages,stats:o.stats,ruleset:o.ruleset},s.messages.sort(function(e,t){return e.rollup&&!t.rollup?1:!e.rollup&&t.rollup?-1:e.line-t.line}),s},i}();return Reporter.prototype={constructor:Reporter,error:function(e,t,r,n){this.messages.push({type:"error",line:t,col:r,message:e,evidence:this.lines[t-1],rule:n||{}})},warn:function(e,t,r,n){this.report(e,t,r,n)},report:function(e,t,r,n){this.messages.push({type:2==this.ruleset[n.id]?"error":"warning",line:t,col:r,message:e,evidence:this.lines[t-1],rule:n})},info:function(e,t,r,n){this.messages.push({type:"info",line:t,col:r,message:e,evidence:this.lines[t-1],rule:n})},rollupError:function(e,t){this.messages.push({type:"error",rollup:!0,message:e,rule:t})},rollupWarn:function(e,t){this.messages.push({type:"warning",rollup:!0,message:e,rule:t})},stat:function(e,t){this.stats[e]=t}},CSSLint._Reporter=Reporter,CSSLint.Util={mix:function(e,t){var r;for(r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return r},indexOf:function(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0,n=e.length;n>r;r++)if(e[r]===t)return r;return-1},forEach:function(e,t){if(e.forEach)return e.forEach(t);for(var r=0,n=e.length;n>r;r++)t(e[r],r,e)}},CSSLint.addRule({id:"adjoining-classes",name:"Disallow adjoining classes",desc:"Don't use adjoining classes.",browsers:"IE6",init:function(e,t){var r=this;e.addListener("startrule",function(n){var i,o,a,s,l,u,d,c=n.selectors;for(l=0;l<c.length;l++)for(i=c[l],u=0;u<i.parts.length;u++)if(o=i.parts[u],o.type==e.SELECTOR_PART_TYPE)for(s=0,d=0;d<o.modifiers.length;d++)a=o.modifiers[d],"class"==a.type&&s++,s>1&&t.report("Don't use adjoining classes.",o.line,o.col,r)})}}),CSSLint.addRule({id:"box-model",name:"Beware of broken box size",desc:"Don't use width or height when using padding or border.",browsers:"All",init:function(e,t){function r(){i={},l=!1}function n(){var e,r;if(!l){if(i.height)for(e in s)s.hasOwnProperty(e)&&i[e]&&(r=i[e].value,("padding"!=e||2!==r.parts.length||0!==r.parts[0].value)&&t.report("Using height with "+e+" can sometimes make elements larger than you expect.",i[e].line,i[e].col,o));if(i.width)for(e in a)a.hasOwnProperty(e)&&i[e]&&(r=i[e].value,("padding"!=e||2!==r.parts.length||0!==r.parts[1].value)&&t.report("Using width with "+e+" can sometimes make elements larger than you expect.",i[e].line,i[e].col,o))}}var i,o=this,a={border:1,"border-left":1,"border-right":1,padding:1,"padding-left":1,"padding-right":1},s={border:1,"border-bottom":1,"border-top":1,padding:1,"padding-bottom":1,"padding-top":1},l=!1;e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("startpage",r),e.addListener("startpagemargin",r),e.addListener("startkeyframerule",r),e.addListener("property",function(e){var t=e.property.text.toLowerCase();s[t]||a[t]?/^0\S*$/.test(e.value)||"border"==t&&"none"==e.value||(i[t]={line:e.property.line,col:e.property.col,value:e.value}):/^(width|height)/i.test(t)&&/^(length|percentage)/.test(e.value.parts[0].type)?i[t]=1:"box-sizing"==t&&(l=!0)}),e.addListener("endrule",n),e.addListener("endfontface",n),e.addListener("endpage",n),e.addListener("endpagemargin",n),e.addListener("endkeyframerule",n)}}),CSSLint.addRule({id:"box-sizing",name:"Disallow use of box-sizing",desc:"The box-sizing properties isn't supported in IE6 and IE7.",browsers:"IE6, IE7",tags:["Compatibility"],init:function(e,t){var r=this;e.addListener("property",function(e){var n=e.property.text.toLowerCase();"box-sizing"==n&&t.report("The box-sizing property isn't supported in IE6 and IE7.",e.line,e.col,r)})}}),CSSLint.addRule({id:"bulletproof-font-face",name:"Use the bulletproof @font-face syntax",desc:"Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax).",browsers:"All",init:function(e,t){var r,n,i=this,o=!1,a=!0,s=!1;e.addListener("startfontface",function(e){o=!0}),e.addListener("property",function(e){if(o){var t=e.property.toString().toLowerCase(),i=e.value.toString();if(r=e.line,n=e.col,"src"===t){var l=/^\s?url\(['"].+\.eot\?.*['"]\)\s*format\(['"]embedded-opentype['"]\).*$/i;!i.match(l)&&a?(s=!0,a=!1):i.match(l)&&!a&&(s=!1)}}}),e.addListener("endfontface",function(e){o=!1,s&&t.report("@font-face declaration doesn't follow the fontspring bulletproof syntax.",r,n,i)})}}),CSSLint.addRule({id:"compatible-vendor-prefixes",name:"Require compatible vendor prefixes",desc:"Include all compatible vendor prefixes to reach a wider range of users.",browsers:"All",init:function(e,t){var r,n,i,o,a,s,l,u=this,d=!1,c=Array.prototype.push,h=[];r={animation:"webkit moz","animation-delay":"webkit moz","animation-direction":"webkit moz","animation-duration":"webkit moz","animation-fill-mode":"webkit moz","animation-iteration-count":"webkit moz","animation-name":"webkit moz","animation-play-state":"webkit moz","animation-timing-function":"webkit moz",appearance:"webkit moz","border-end":"webkit moz","border-end-color":"webkit moz","border-end-style":"webkit moz","border-end-width":"webkit moz","border-image":"webkit moz o","border-radius":"webkit","border-start":"webkit moz","border-start-color":"webkit moz","border-start-style":"webkit moz","border-start-width":"webkit moz","box-align":"webkit moz ms","box-direction":"webkit moz ms","box-flex":"webkit moz ms","box-lines":"webkit ms","box-ordinal-group":"webkit moz ms","box-orient":"webkit moz ms","box-pack":"webkit moz ms","box-sizing":"webkit moz","box-shadow":"webkit moz","column-count":"webkit moz ms","column-gap":"webkit moz ms","column-rule":"webkit moz ms","column-rule-color":"webkit moz ms","column-rule-style":"webkit moz ms","column-rule-width":"webkit moz ms","column-width":"webkit moz ms",hyphens:"epub moz","line-break":"webkit ms","margin-end":"webkit moz","margin-start":"webkit moz","marquee-speed":"webkit wap","marquee-style":"webkit wap","padding-end":"webkit moz","padding-start":"webkit moz","tab-size":"moz o","text-size-adjust":"webkit ms",transform:"webkit moz ms o","transform-origin":"webkit moz ms o",transition:"webkit moz o","transition-delay":"webkit moz o","transition-duration":"webkit moz o","transition-property":"webkit moz o","transition-timing-function":"webkit moz o","user-modify":"webkit moz","user-select":"webkit moz ms","word-break":"epub ms","writing-mode":"epub ms"};for(i in r)if(r.hasOwnProperty(i)){for(o=[],a=r[i].split(" "),s=0,l=a.length;l>s;s++)o.push("-"+a[s]+"-"+i);r[i]=o,c.apply(h,o)}e.addListener("startrule",function(){n=[]}),e.addListener("startkeyframes",function(e){d=e.prefix||!0}),e.addListener("endkeyframes",function(e){d=!1}),e.addListener("property",function(e){var t=e.property;CSSLint.Util.indexOf(h,t.text)>-1&&(d&&"string"==typeof d&&0===t.text.indexOf("-"+d+"-")||n.push(t))}),e.addListener("endrule",function(e){if(n.length){var i,o,a,s,l,d,c,h,p,m,f={};for(i=0,o=n.length;o>i;i++){a=n[i];for(s in r)r.hasOwnProperty(s)&&(l=r[s],CSSLint.Util.indexOf(l,a.text)>-1&&(f[s]||(f[s]={full:l.slice(0),actual:[],actualNodes:[]}),-1===CSSLint.Util.indexOf(f[s].actual,a.text)&&(f[s].actual.push(a.text),f[s].actualNodes.push(a))))}for(s in f)if(f.hasOwnProperty(s)&&(d=f[s],c=d.full,h=d.actual,c.length>h.length))for(i=0,o=c.length;o>i;i++)p=c[i],-1===CSSLint.Util.indexOf(h,p)&&(m=1===h.length?h[0]:2==h.length?h.join(" and "):h.join(", "),t.report("The property "+p+" is compatible with "+m+" and should be included as well.",d.actualNodes[0].line,d.actualNodes[0].col,u))}})}}),CSSLint.addRule({id:"display-property-grouping",name:"Require properties appropriate for display",desc:"Certain properties shouldn't be used with certain display property values.",browsers:"All",init:function(e,t){function r(e,r,n){o[e]&&("string"!=typeof s[e]||o[e].value.toLowerCase()!=s[e])&&t.report(n||e+" can't be used with display: "+r+".",o[e].line,o[e].col,a)}function n(){o={}}function i(){var e=o.display?o.display.value:null;if(e)switch(e){case"inline":r("height",e),r("width",e),r("margin",e),r("margin-top",e),r("margin-bottom",e),r("float",e,"display:inline has no effect on floated elements (but may be used to fix the IE6 double-margin bug).");break;case"block":r("vertical-align",e);break;case"inline-block":r("float",e);break;default:0===e.indexOf("table-")&&(r("margin",e),r("margin-left",e),r("margin-right",e),r("margin-top",e),r("margin-bottom",e),r("float",e))}}var o,a=this,s={display:1,"float":"none",height:1,width:1,margin:1,"margin-left":1,"margin-right":1,"margin-bottom":1,"margin-top":1,padding:1,"padding-left":1,"padding-right":1,"padding-bottom":1,"padding-top":1,"vertical-align":1};e.addListener("startrule",n),e.addListener("startfontface",n),e.addListener("startkeyframerule",n),e.addListener("startpagemargin",n),e.addListener("startpage",n),e.addListener("property",function(e){var t=e.property.text.toLowerCase();s[t]&&(o[t]={value:e.value.text,line:e.property.line,col:e.property.col})}),e.addListener("endrule",i),e.addListener("endfontface",i),e.addListener("endkeyframerule",i),e.addListener("endpagemargin",i),e.addListener("endpage",i)}}),CSSLint.addRule({id:"duplicate-background-images",name:"Disallow duplicate background images",desc:"Every background-image should be unique. Use a common class for e.g. sprites.",browsers:"All",init:function(e,t){var r=this,n={};e.addListener("property",function(e){var i,o,a=e.property.text,s=e.value;if(a.match(/background/i))for(i=0,o=s.parts.length;o>i;i++)"uri"==s.parts[i].type&&("undefined"==typeof n[s.parts[i].uri]?n[s.parts[i].uri]=e:t.report("Background image '"+s.parts[i].uri+"' was used multiple times, first declared at line "+n[s.parts[i].uri].line+", col "+n[s.parts[i].uri].col+".",e.line,e.col,r))})}}),CSSLint.addRule({id:"duplicate-properties",name:"Disallow duplicate properties",desc:"Duplicate properties must appear one after the other.",browsers:"All",init:function(e,t){function r(e){n={}}var n,i,o=this;e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("startpage",r),e.addListener("startpagemargin",r),e.addListener("startkeyframerule",r),e.addListener("property",function(e){var r=e.property,a=r.text.toLowerCase();!n[a]||i==a&&n[a]!=e.value.text||t.report("Duplicate property '"+e.property+"' found.",e.line,e.col,o),n[a]=e.value.text,i=a})}}),CSSLint.addRule({id:"empty-rules",name:"Disallow empty rules",desc:"Rules without any properties specified should be removed.",browsers:"All",init:function(e,t){var r=this,n=0;e.addListener("startrule",function(){n=0}),e.addListener("property",function(){n++}),e.addListener("endrule",function(e){var i=e.selectors;0===n&&t.report("Rule is empty.",i[0].line,i[0].col,r)})}}),CSSLint.addRule({id:"errors",name:"Parsing Errors",desc:"This rule looks for recoverable syntax errors.",browsers:"All",init:function(e,t){var r=this;e.addListener("error",function(e){t.error(e.message,e.line,e.col,r)})}}),CSSLint.addRule({id:"fallback-colors",name:"Require fallback colors",desc:"For older browsers that don't support RGBA, HSL, or HSLA, provide a fallback color.",browsers:"IE6,IE7,IE8",init:function(e,t){function r(e){i={},n=null}var n,i,o=this,a={color:1,background:1,"border-color":1,"border-top-color":1,"border-right-color":1,"border-bottom-color":1,"border-left-color":1,border:1,"border-top":1,"border-right":1,"border-bottom":1,"border-left":1,"background-color":1};e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("startpage",r),e.addListener("startpagemargin",r),e.addListener("startkeyframerule",r),e.addListener("property",function(e){var r=e.property,i=r.text.toLowerCase(),s=e.value.parts,l=0,u="",d=s.length;if(a[i])for(;d>l;)"color"==s[l].type&&("alpha"in s[l]||"hue"in s[l]?(/([^\)]+)\(/.test(s[l])&&(u=RegExp.$1.toUpperCase()),n&&n.property.text.toLowerCase()==i&&"compat"==n.colorType||t.report("Fallback "+i+" (hex or RGB) should precede "+u+" "+i+".",e.line,e.col,o)):e.colorType="compat"),l++;n=e})}}),CSSLint.addRule({id:"floats",name:"Disallow too many floats",desc:"This rule tests if the float property is used too many times",browsers:"All",init:function(e,t){var r=this,n=0;e.addListener("property",function(e){"float"==e.property.text.toLowerCase()&&"none"!=e.value.text.toLowerCase()&&n++}),e.addListener("endstylesheet",function(){t.stat("floats",n),n>=10&&t.rollupWarn("Too many floats ("+n+"), you're probably using them for layout. Consider using a grid system instead.",r)})}}),CSSLint.addRule({id:"font-faces",name:"Don't use too many web fonts",desc:"Too many different web fonts in the same stylesheet.",browsers:"All",init:function(e,t){var r=this,n=0;e.addListener("startfontface",function(){n++}),e.addListener("endstylesheet",function(){n>5&&t.rollupWarn("Too many @font-face declarations ("+n+").",r)})}}),CSSLint.addRule({id:"font-sizes",name:"Disallow too many font sizes",desc:"Checks the number of font-size declarations.",browsers:"All",init:function(e,t){var r=this,n=0;e.addListener("property",function(e){"font-size"==e.property&&n++}),e.addListener("endstylesheet",function(){t.stat("font-sizes",n),n>=10&&t.rollupWarn("Too many font-size declarations ("+n+"), abstraction needed.",r)})}}),CSSLint.addRule({id:"gradients",name:"Require all gradient definitions",desc:"When using a vendor-prefixed gradient, make sure to use them all.",browsers:"All",init:function(e,t){var r,n=this;e.addListener("startrule",function(){r={moz:0,webkit:0,oldWebkit:0,o:0}}),e.addListener("property",function(e){/\-(moz|o|webkit)(?:\-(?:linear|radial))\-gradient/i.test(e.value)?r[RegExp.$1]=1:/\-webkit\-gradient/i.test(e.value)&&(r.oldWebkit=1)}),e.addListener("endrule",function(e){var i=[];r.moz||i.push("Firefox 3.6+"),r.webkit||i.push("Webkit (Safari 5+, Chrome)"),r.oldWebkit||i.push("Old Webkit (Safari 4+, Chrome)"),r.o||i.push("Opera 11.1+"),i.length&&i.length<4&&t.report("Missing vendor-prefixed CSS gradients for "+i.join(", ")+".",e.selectors[0].line,e.selectors[0].col,n)})}}),CSSLint.addRule({id:"ids",name:"Disallow IDs in selectors",desc:"Selectors should not contain IDs.",browsers:"All",init:function(e,t){var r=this;e.addListener("startrule",function(n){var i,o,a,s,l,u,d,c=n.selectors;for(l=0;l<c.length;l++){for(i=c[l],s=0,u=0;u<i.parts.length;u++)if(o=i.parts[u],o.type==e.SELECTOR_PART_TYPE)for(d=0;d<o.modifiers.length;d++)a=o.modifiers[d],"id"==a.type&&s++;1==s?t.report("Don't use IDs in selectors.",i.line,i.col,r):s>1&&t.report(s+" IDs in the selector, really?",i.line,i.col,r)}})}}),CSSLint.addRule({id:"import",name:"Disallow @import",desc:"Don't use @import, use <link> instead.",browsers:"All",init:function(e,t){var r=this;e.addListener("import",function(e){t.report("@import prevents parallel downloads, use <link> instead.",e.line,e.col,r)})}}),CSSLint.addRule({id:"important",name:"Disallow !important",desc:"Be careful when using !important declaration",browsers:"All",init:function(e,t){var r=this,n=0;e.addListener("property",function(e){e.important===!0&&(n++,t.report("Use of !important",e.line,e.col,r))}),e.addListener("endstylesheet",function(){t.stat("important",n),n>=10&&t.rollupWarn("Too many !important declarations ("+n+"), try to use less than 10 to avoid specificity issues.",r)})}}),CSSLint.addRule({id:"known-properties",name:"Require use of known properties",desc:"Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property.",browsers:"All",init:function(e,t){var r=this;e.addListener("property",function(e){e.property.text.toLowerCase();e.invalid&&t.report(e.invalid.message,e.line,e.col,r)})}}),CSSLint.addRule({id:"outline-none",name:"Disallow outline: none",desc:"Use of outline: none or outline: 0 should be limited to :focus rules.",browsers:"All",tags:["Accessibility"],init:function(e,t){function r(e){i=e.selectors?{line:e.line,col:e.col,selectors:e.selectors,propCount:0,outline:!1}:null}function n(e){i&&i.outline&&(-1==i.selectors.toString().toLowerCase().indexOf(":focus")?t.report("Outlines should only be modified using :focus.",i.line,i.col,o):1==i.propCount&&t.report("Outlines shouldn't be hidden unless other visual changes are made.",i.line,i.col,o))}var i,o=this;e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("startpage",r),e.addListener("startpagemargin",r),e.addListener("startkeyframerule",r),e.addListener("property",function(e){var t=e.property.text.toLowerCase(),r=e.value;i&&(i.propCount++,"outline"!=t||"none"!=r&&"0"!=r||(i.outline=!0))}),e.addListener("endrule",n),e.addListener("endfontface",n),e.addListener("endpage",n),e.addListener("endpagemargin",n),e.addListener("endkeyframerule",n)}}),CSSLint.addRule({id:"overqualified-elements",name:"Disallow overqualified elements",desc:"Don't use classes or IDs with elements (a.foo or a#foo).",browsers:"All",init:function(e,t){var r=this,n={};e.addListener("startrule",function(i){var o,a,s,l,u,d,c=i.selectors;for(l=0;l<c.length;l++)for(o=c[l],u=0;u<o.parts.length;u++)if(a=o.parts[u],a.type==e.SELECTOR_PART_TYPE)for(d=0;d<a.modifiers.length;d++)s=a.modifiers[d],a.elementName&&"id"==s.type?t.report("Element ("+a+") is overqualified, just use "+s+" without element name.",a.line,a.col,r):"class"==s.type&&(n[s]||(n[s]=[]),n[s].push({modifier:s,part:a}))}),e.addListener("endstylesheet",function(){var e;for(e in n)n.hasOwnProperty(e)&&1==n[e].length&&n[e][0].part.elementName&&t.report("Element ("+n[e][0].part+") is overqualified, just use "+n[e][0].modifier+" without element name.",n[e][0].part.line,n[e][0].part.col,r)})}}),CSSLint.addRule({id:"qualified-headings",name:"Disallow qualified headings",desc:"Headings should not be qualified (namespaced).",browsers:"All",init:function(e,t){var r=this;e.addListener("startrule",function(n){var i,o,a,s,l=n.selectors;for(a=0;a<l.length;a++)for(i=l[a],s=0;s<i.parts.length;s++)o=i.parts[s],o.type==e.SELECTOR_PART_TYPE&&o.elementName&&/h[1-6]/.test(o.elementName.toString())&&s>0&&t.report("Heading ("+o.elementName+") should not be qualified.",o.line,o.col,r)})}}),CSSLint.addRule({id:"regex-selectors",name:"Disallow selectors that look like regexs",desc:"Selectors that look like regular expressions are slow and should be avoided.",browsers:"All",init:function(e,t){var r=this;e.addListener("startrule",function(n){var i,o,a,s,l,u,d=n.selectors;for(s=0;s<d.length;s++)for(i=d[s],l=0;l<i.parts.length;l++)if(o=i.parts[l],o.type==e.SELECTOR_PART_TYPE)for(u=0;u<o.modifiers.length;u++)a=o.modifiers[u],"attribute"==a.type&&/([\~\|\^\$\*]=)/.test(a)&&t.report("Attribute selectors with "+RegExp.$1+" are slow!",a.line,a.col,r)})}}),CSSLint.addRule({id:"rules-count",name:"Rules Count",desc:"Track how many rules there are.",browsers:"All",init:function(e,t){var r=0;e.addListener("startrule",function(){r++}),e.addListener("endstylesheet",function(){t.stat("rule-count",r)})}}),CSSLint.addRule({id:"selector-max-approaching",name:"Warn when approaching the 4095 selector limit for IE",desc:"Will warn when selector count is >= 3800 selectors.",browsers:"IE",init:function(e,t){var r=this,n=0;e.addListener("startrule",function(e){n+=e.selectors.length}),e.addListener("endstylesheet",function(){n>=3800&&t.report("You have "+n+" selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,r)})}}),CSSLint.addRule({id:"selector-max",name:"Error when past the 4095 selector limit for IE",desc:"Will error when selector count is > 4095.",browsers:"IE",init:function(e,t){var r=this,n=0;e.addListener("startrule",function(e){n+=e.selectors.length}),e.addListener("endstylesheet",function(){n>4095&&t.report("You have "+n+" selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,r)})}}),CSSLint.addRule({id:"shorthand",name:"Require shorthand properties",desc:"Use shorthand properties where possible.",browsers:"All",init:function(e,t){function r(e){s={}}function n(e){var r,n,i,o;for(r in d)if(d.hasOwnProperty(r)){for(o=0,n=0,i=d[r].length;i>n;n++)o+=s[d[r][n]]?1:0;o==d[r].length&&t.report("The properties "+d[r].join(", ")+" can be replaced by "+r+".",e.line,e.col,l)}}var i,o,a,s,l=this,u={},d={margin:["margin-top","margin-bottom","margin-left","margin-right"],padding:["padding-top","padding-bottom","padding-left","padding-right"]};for(i in d)if(d.hasOwnProperty(i))for(o=0,a=d[i].length;a>o;o++)u[d[i][o]]=i;e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("property",function(e){var t=e.property.toString().toLowerCase();e.value.parts[0].value;u[t]&&(s[t]=1)}),e.addListener("endrule",n),e.addListener("endfontface",n)}}),CSSLint.addRule({id:"star-property-hack",name:"Disallow properties with a star prefix",desc:"Checks for the star property hack (targets IE6/7)",browsers:"All",init:function(e,t){var r=this;e.addListener("property",function(e){var n=e.property;"*"==n.hack&&t.report("Property with star prefix found.",e.property.line,e.property.col,r)})}}),CSSLint.addRule({id:"text-indent",name:"Disallow negative text-indent",desc:"Checks for text indent less than -99px",browsers:"All",init:function(e,t){function r(e){i=!1,o="inherit"}function n(e){i&&"ltr"!=o&&t.report("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.",i.line,i.col,a)}var i,o,a=this;e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("property",function(e){var t=e.property.toString().toLowerCase(),r=e.value;"text-indent"==t&&r.parts[0].value<-99?i=e.property:"direction"==t&&"ltr"==r&&(o="ltr")}),e.addListener("endrule",n),e.addListener("endfontface",n)}}),CSSLint.addRule({id:"underscore-property-hack",name:"Disallow properties with an underscore prefix",desc:"Checks for the underscore property hack (targets IE6)",browsers:"All",init:function(e,t){var r=this;e.addListener("property",function(e){var n=e.property;"_"==n.hack&&t.report("Property with underscore prefix found.",e.property.line,e.property.col,r)})}}),CSSLint.addRule({id:"unique-headings",name:"Headings should only be defined once",desc:"Headings should be defined only once.",browsers:"All",init:function(e,t){var r=this,n={h1:0,h2:0,h3:0,h4:0,h5:0,h6:0};e.addListener("startrule",function(e){var i,o,a,s,l,u=e.selectors;for(s=0;s<u.length;s++)if(i=u[s],o=i.parts[i.parts.length-1],o.elementName&&/(h[1-6])/i.test(o.elementName.toString())){for(l=0;l<o.modifiers.length;l++)if("pseudo"==o.modifiers[l].type){a=!0;break}a||(n[RegExp.$1]++,n[RegExp.$1]>1&&t.report("Heading ("+o.elementName+") has already been defined.",o.line,o.col,r))}}),e.addListener("endstylesheet",function(e){var i,o=[];for(i in n)n.hasOwnProperty(i)&&n[i]>1&&o.push(n[i]+" "+i+"s");o.length&&t.rollupWarn("You have "+o.join(", ")+" defined in this stylesheet.",r)})}}),CSSLint.addRule({id:"universal-selector",name:"Disallow universal selector",desc:"The universal selector (*) is known to be slow.",browsers:"All",init:function(e,t){var r=this;e.addListener("startrule",function(e){var n,i,o,a=e.selectors;for(o=0;o<a.length;o++)n=a[o],i=n.parts[n.parts.length-1],"*"==i.elementName&&t.report(r.desc,i.line,i.col,r)})}}),CSSLint.addRule({id:"unqualified-attributes",name:"Disallow unqualified attribute selectors",desc:"Unqualified attribute selectors are known to be slow.",browsers:"All",init:function(e,t){var r=this;e.addListener("startrule",function(n){var i,o,a,s,l,u=n.selectors;for(s=0;s<u.length;s++)if(i=u[s],o=i.parts[i.parts.length-1],o.type==e.SELECTOR_PART_TYPE)for(l=0;l<o.modifiers.length;l++)a=o.modifiers[l],"attribute"!=a.type||o.elementName&&"*"!=o.elementName||t.report(r.desc,o.line,o.col,r)})}}),CSSLint.addRule({id:"vendor-prefix",name:"Require standard property with vendor prefix",desc:"When using a vendor-prefixed property, make sure to include the standard one.",browsers:"All",init:function(e,t){function r(){i={},o=1}function n(e){var r,n,o,l,u,d=[];for(r in i)s[r]&&d.push({actual:r,needed:s[r]});for(n=0,o=d.length;o>n;n++)l=d[n].needed,u=d[n].actual,i[l]?i[l][0].pos<i[u][0].pos&&t.report("Standard property '"+l+"' should come after vendor-prefixed property '"+u+"'.",i[u][0].name.line,i[u][0].name.col,a):t.report("Missing standard property '"+l+"' to go along with '"+u+"'.",i[u][0].name.line,i[u][0].name.col,a)}var i,o,a=this,s={"-webkit-border-radius":"border-radius","-webkit-border-top-left-radius":"border-top-left-radius","-webkit-border-top-right-radius":"border-top-right-radius","-webkit-border-bottom-left-radius":"border-bottom-left-radius","-webkit-border-bottom-right-radius":"border-bottom-right-radius","-o-border-radius":"border-radius","-o-border-top-left-radius":"border-top-left-radius","-o-border-top-right-radius":"border-top-right-radius","-o-border-bottom-left-radius":"border-bottom-left-radius","-o-border-bottom-right-radius":"border-bottom-right-radius","-moz-border-radius":"border-radius","-moz-border-radius-topleft":"border-top-left-radius","-moz-border-radius-topright":"border-top-right-radius","-moz-border-radius-bottomleft":"border-bottom-left-radius","-moz-border-radius-bottomright":"border-bottom-right-radius","-moz-column-count":"column-count","-webkit-column-count":"column-count","-moz-column-gap":"column-gap","-webkit-column-gap":"column-gap","-moz-column-rule":"column-rule","-webkit-column-rule":"column-rule","-moz-column-rule-style":"column-rule-style","-webkit-column-rule-style":"column-rule-style","-moz-column-rule-color":"column-rule-color","-webkit-column-rule-color":"column-rule-color","-moz-column-rule-width":"column-rule-width","-webkit-column-rule-width":"column-rule-width","-moz-column-width":"column-width","-webkit-column-width":"column-width","-webkit-column-span":"column-span","-webkit-columns":"columns","-moz-box-shadow":"box-shadow","-webkit-box-shadow":"box-shadow","-moz-transform":"transform","-webkit-transform":"transform","-o-transform":"transform","-ms-transform":"transform","-moz-transform-origin":"transform-origin","-webkit-transform-origin":"transform-origin","-o-transform-origin":"transform-origin","-ms-transform-origin":"transform-origin","-moz-box-sizing":"box-sizing","-webkit-box-sizing":"box-sizing","-moz-user-select":"user-select",
|
4 |
+
"-khtml-user-select":"user-select","-webkit-user-select":"user-select"};e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("startpage",r),e.addListener("startpagemargin",r),e.addListener("startkeyframerule",r),e.addListener("property",function(e){var t=e.property.text.toLowerCase();i[t]||(i[t]=[]),i[t].push({name:e.property,value:e.value,pos:o++})}),e.addListener("endrule",n),e.addListener("endfontface",n),e.addListener("endpage",n),e.addListener("endpagemargin",n),e.addListener("endkeyframerule",n)}}),CSSLint.addRule({id:"zero-units",name:"Disallow units for 0 values",desc:"You don't need to specify units when a value is 0.",browsers:"All",init:function(e,t){var r=this;e.addListener("property",function(e){for(var n=e.value.parts,i=0,o=n.length;o>i;)!n[i].units&&"percentage"!=n[i].type||0!==n[i].value||"time"==n[i].type||t.report("Values of 0 shouldn't have units specified.",n[i].line,n[i].col,r),i++})}}),function(){var e=function(e){return e&&e.constructor===String?e.replace(/[\"&><]/g,function(e){switch(e){case'"':return""";case"&":return"&";case"<":return"<";case">":return">"}}):""};CSSLint.addFormatter({id:"checkstyle-xml",name:"Checkstyle XML format",startFormat:function(){return'<?xml version="1.0" encoding="utf-8"?><checkstyle>'},endFormat:function(){return"</checkstyle>"},readError:function(t,r){return'<file name="'+e(t)+'"><error line="0" column="0" severty="error" message="'+e(r)+'"></error></file>'},formatResults:function(t,r,n){var i=t.messages,o=[],a=function(e){return e&&"name"in e?"net.csslint."+e.name.replace(/\s/g,""):""};return i.length>0&&(o.push('<file name="'+r+'">'),CSSLint.Util.forEach(i,function(t,r){t.rollup||o.push('<error line="'+t.line+'" column="'+t.col+'" severity="'+t.type+'" message="'+e(t.message)+'" source="'+a(t.rule)+'"/>')}),o.push("</file>")),o.join("")}})}(),CSSLint.addFormatter({id:"compact",name:"Compact, 'porcelain' format",startFormat:function(){return""},endFormat:function(){return""},formatResults:function(e,t,r){var n=e.messages,i="";r=r||{};var o=function(e){return e.charAt(0).toUpperCase()+e.slice(1)};return 0===n.length?r.quiet?"":t+": Lint Free!":(CSSLint.Util.forEach(n,function(e,r){i+=e.rollup?t+": "+o(e.type)+" - "+e.message+"\n":t+": line "+e.line+", col "+e.col+", "+o(e.type)+" - "+e.message+"\n"}),i)}}),CSSLint.addFormatter({id:"csslint-xml",name:"CSSLint XML format",startFormat:function(){return'<?xml version="1.0" encoding="utf-8"?><csslint>'},endFormat:function(){return"</csslint>"},formatResults:function(e,t,r){var n=e.messages,i=[],o=function(e){return e&&e.constructor===String?e.replace(/\"/g,"'").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"):""};return n.length>0&&(i.push('<file name="'+t+'">'),CSSLint.Util.forEach(n,function(e,t){e.rollup?i.push('<issue severity="'+e.type+'" reason="'+o(e.message)+'" evidence="'+o(e.evidence)+'"/>'):i.push('<issue line="'+e.line+'" char="'+e.col+'" severity="'+e.type+'" reason="'+o(e.message)+'" evidence="'+o(e.evidence)+'"/>')}),i.push("</file>")),i.join("")}}),CSSLint.addFormatter({id:"junit-xml",name:"JUNIT XML format",startFormat:function(){return'<?xml version="1.0" encoding="utf-8"?><testsuites>'},endFormat:function(){return"</testsuites>"},formatResults:function(e,t,r){var n=e.messages,i=[],o={error:0,failure:0},a=function(e){return e&&"name"in e?"net.csslint."+e.name.replace(/\s/g,""):""},s=function(e){return e&&e.constructor===String?e.replace(/\"/g,"'").replace(/</g,"<").replace(/>/g,">"):""};return n.length>0&&(n.forEach(function(e,t){var r="warning"===e.type?"error":e.type;e.rollup||(i.push('<testcase time="0" name="'+a(e.rule)+'">'),i.push("<"+r+' message="'+s(e.message)+'"><![CDATA['+e.line+":"+e.col+":"+s(e.evidence)+"]]></"+r+">"),i.push("</testcase>"),o[r]+=1)}),i.unshift('<testsuite time="0" tests="'+n.length+'" skipped="0" errors="'+o.error+'" failures="'+o.failure+'" package="net.csslint" name="'+t+'">'),i.push("</testsuite>")),i.join("")}}),CSSLint.addFormatter({id:"lint-xml",name:"Lint XML format",startFormat:function(){return'<?xml version="1.0" encoding="utf-8"?><lint>'},endFormat:function(){return"</lint>"},formatResults:function(e,t,r){var n=e.messages,i=[],o=function(e){return e&&e.constructor===String?e.replace(/\"/g,"'").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"):""};return n.length>0&&(i.push('<file name="'+t+'">'),CSSLint.Util.forEach(n,function(e,t){e.rollup?i.push('<issue severity="'+e.type+'" reason="'+o(e.message)+'" evidence="'+o(e.evidence)+'"/>'):i.push('<issue line="'+e.line+'" char="'+e.col+'" severity="'+e.type+'" reason="'+o(e.message)+'" evidence="'+o(e.evidence)+'"/>')}),i.push("</file>")),i.join("")}}),CSSLint.addFormatter({id:"text",name:"Plain Text",startFormat:function(){return""},endFormat:function(){return""},formatResults:function(e,t,r){var n=e.messages,i="";if(r=r||{},0===n.length)return r.quiet?"":"\n\ncsslint: No errors in "+t+".";i="\n\ncsslint: There are "+n.length+" problems in "+t+".";var o=t.lastIndexOf("/"),a=t;return-1===o&&(o=t.lastIndexOf("\\")),o>-1&&(a=t.substring(o+1)),CSSLint.Util.forEach(n,function(e,t){i=i+"\n\n"+a,e.rollup?(i+="\n"+(t+1)+": "+e.type,i+="\n"+e.message):(i+="\n"+(t+1)+": "+e.type+" at line "+e.line+", col "+e.col,i+="\n"+e.message,i+="\n"+e.evidence)}),i}}),CSSLint}();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/editor.min.js
CHANGED
@@ -1,63 +1 @@
|
|
1 |
-
|
2 |
-
(function($,_,socssOptions){var socss={model:{},collection:{},view:{},fn:{}};window.socss=socss;socss.view.toolbar=Backbone.View.extend({button:_.template('<li><a href="#" class="toolbar-button socss-button"><%= text %></a></li>'),editor:null,initialize:function(attr){this.editor=attr.editor;var thisView=this;this.$('.editor-expand').click(function(e){e.preventDefault();$(this).blur();thisView.trigger('click_expand');});this.$('.editor-visual').click(function(e){e.preventDefault();$(this).blur();thisView.trigger('click_visual');});},addButton:function(text,action){var thisView=this;var button=$(this.button({text:text})).appendTo(this.$('.toolbar-function-buttons .toolbar-buttons')).click(function(e){e.preventDefault();$(this).blur();thisView.trigger('click_'+action);});return button;}});socss.view.editor=Backbone.View.extend({codeMirror:null,snippets:null,toolbar:null,visualProperties:null,inspector:null,cssSelectors:[],initialize:function(args){this.setupEditor();},render:function(){var thisView=this;this.toolbar=new socss.view.toolbar({editor:this,el:this.$('.custom-css-toolbar')});this.toolbar.editor=this;this.toolbar.render();this.visualProperties=new socss.view.properties({editor:this,el:$('#so-custom-css-properties')});this.visualProperties.render();this.toolbar.on('click_expand',function(){thisView.toggleExpand();});this.toolbar.on('click_visual',function(){thisView.visualProperties.loadCSS(thisView.codeMirror.getValue());thisView.visualProperties.show();});this.preview=new socss.view.preview({editor:this,el:this.$('.custom-css-preview')});this.preview.render();},setupEditor:function(){var thisView=this;this.registerCodeMirrorAutocomplete();this.codeMirror=CodeMirror.fromTextArea(this.$('textarea.css-editor').get(0),{tabSize:2,mode:'css',theme:'neat',gutters:["CodeMirror-lint-markers"],lint:true});var startCss=this.$('textarea.css-editor').val();this.$el.on('submit',function(){startCss=thisView.codeMirror.getValue();});$(window).bind('beforeunload',function(){if(thisView.codeMirror.getValue()!==startCss){return socssOptions.loc.leave;}});this.$el.find('.custom-css-container').css('overflow','visible');this.scaleEditor();$(window).resize(function(){thisView.scaleEditor();});this.setupCodeMirrorExtensions();},registerCodeMirrorAutocomplete:function(){var thisView=this;var pseudoClasses={link:1,visited:1,active:1,hover:1,focus:1,"first-letter":1,"first-line":1,"first-child":1,before:1,after:1,lang:1};CodeMirror.registerHelper("hint","css",function(cm){var cur=cm.getCursor(),token=cm.getTokenAt(cur);var inner=CodeMirror.innerMode(cm.getMode(),token.state);if(inner.mode.name!=="css"){return;}
|
3 |
-
if(token.type==="keyword"&&"!important".indexOf(token.string)===0){return{list:["!important"],from:CodeMirror.Pos(cur.line,token.start),to:CodeMirror.Pos(cur.line,token.end)};}
|
4 |
-
var start=token.start,end=cur.ch,word=token.string.slice(0,end-start);if(/[^\w$_-]/.test(word)){word="";start=end=cur.ch;}
|
5 |
-
var spec=CodeMirror.resolveMode("text/css");var result=[];function add(keywords){for(var name in keywords){if(!word||name.lastIndexOf(word,0)===0){result.push(name);}}}
|
6 |
-
var st=inner.state.state;if(st==='top'){var line=cm.getLine(cur.line).trim();var selectors=thisView.cssSelectors;for(var i=0;i<selectors.length;i++){if(selectors[i].selector.indexOf(line)!==-1){result.push(selectors[i].selector);}}
|
7 |
-
if(result.length){return{list:result,from:CodeMirror.Pos(cur.line,0),to:CodeMirror.Pos(cur.line,end)};}}
|
8 |
-
else{if(st==="pseudo"||token.type==="variable-3"){add(pseudoClasses);}
|
9 |
-
else if(st==="block"||st==="maybeprop"){add(spec.propertyKeywords);}
|
10 |
-
else if(st==="prop"||st==="parens"||st==="at"||st==="params"){add(spec.valueKeywords);add(spec.colorKeywords);}
|
11 |
-
else if(st==="media"||st==="media_parens"){add(spec.mediaTypes);add(spec.mediaFeatures);}
|
12 |
-
if(result.length){return{list:result,from:CodeMirror.Pos(cur.line,start),to:CodeMirror.Pos(cur.line,end)};}}});},setupCodeMirrorExtensions:function(){var thisView=this;this.codeMirror.on('cursorActivity',function(cm){var cur=cm.getCursor(),token=cm.getTokenAt(cur);var inner=CodeMirror.innerMode(cm.getMode(),token.state);if(token.type==='qualifier'||token.type==='tag'||token.type==='builtin'){var line=cm.getLine(cur.line);var selector=line.substring(0,token.end);thisView.preview.highlight(selector);}
|
13 |
-
else{thisView.preview.clearHighlight();}});this.codeMirror.on('keyup',function(cm,e){if((e.keyCode>=65&&e.keyCode<=90)||(e.keyCode===189&&!e.shiftKey)||(e.keyCode===190&&!e.shiftKey)||(e.keyCode===51&&e.shiftKey)||(e.keyCode===189&&e.shiftKey)){cm.showHint(e);}});},scaleEditor:function(){if(this.$el.hasClass('expanded')){this.codeMirror.setSize('100%',$(window).outerHeight()-this.$('.custom-css-toolbar').outerHeight());}
|
14 |
-
else{this.codeMirror.setSize('100%','auto');}},isExpanded:function(){return this.$el.hasClass('expanded');},toggleExpand:function(){this.$el.toggleClass('expanded');this.scaleEditor();},setExpand:function(expanded){if(expanded){this.$el.addClass('expanded');}
|
15 |
-
else{this.$el.removeClass('expanded');}
|
16 |
-
this.scaleEditor();},setSnippets:function(snippets){if(!_.isEmpty(snippets)){var thisView=this;this.snippets=new socss.view.snippets({snippets:snippets});this.snippets.editor=this;this.snippets.render();this.toolbar.addButton('Snippets','snippets');this.toolbar.on('click_snippets',function(){thisView.snippets.show();});}},addCode:function(css){var editor=this.codeMirror;var before_css='';if(editor.doc.lineCount()===1&&editor.doc.getLine(editor.doc.lastLine()).length===0){before_css="";}
|
17 |
-
else if(editor.doc.getLine(editor.doc.lastLine()).length===0){before_css="\n";}
|
18 |
-
else{before_css="\n\n";}
|
19 |
-
editor.doc.setCursor(editor.doc.lastLine(),editor.doc.getLine(editor.doc.lastLine()).length);editor.doc.replaceSelection(before_css+css);},addEmptySelector:function(selector){this.addCode(selector+" {\n \n}");},setInspector:function(inspector){var thisView=this;this.inspector=inspector;this.cssSelectors=inspector.pageSelectors;inspector.on('click_selector',function(selector){if(thisView.visualProperties.isVisible()){thisView.visualProperties.addSelector(selector);}
|
20 |
-
else{thisView.addEmptySelector(selector);}});inspector.on('click_property',function(property){if(!thisView.visualProperties.isVisible()){thisView.codeMirror.replaceSelection(property+";\n ");}});inspector.on('set_active_element',function(el,selectors){if(thisView.visualProperties.isVisible()&&selectors.length){thisView.visualProperties.addSelector(selectors[0].selector);}});}});socss.view.preview=Backbone.View.extend({template:_.template('<iframe class="preview-iframe" seamless="seamless"></iframe>'),editor:null,initialize:function(attr){this.editor=attr.editor;var thisView=this;this.editor.codeMirror.on('change',function(cm,c){thisView.updatePreviewCss();});},render:function(){var thisView=this;this.$el.html(this.template());this.$('.preview-iframe').attr('src',socssOptions.homeURL).load(function(){var $$=$(this);$$.contents().find('a').each(function(){var href=$(this).attr('href');if(href===undefined){return true;}
|
21 |
-
var firstSeperator=(href.indexOf('?')===-1?'?':'&');$(this).attr('href',href+firstSeperator+'so_css_preview=1');});thisView.updatePreviewCss();}).mouseleave(function(){thisView.clearHighlight();});},updatePreviewCss:function(){var preview=this.$('.preview-iframe');if(preview.length===0){return;}
|
22 |
-
var head=preview.contents().find('head');if(head.find('style.siteorigin-custom-css').length===0){head.append('<style class="siteorigin-custom-css" type="text/css"></style>');}
|
23 |
-
var style=head.find('style.siteorigin-custom-css');var css=this.editor.codeMirror.getValue();style.html(css);},highlight:function(selector){try{this.editor.inspector.hl.highlight(selector);}
|
24 |
-
catch(err){console.log('No inspector to highlight with');}},clearHighlight:function(){try{this.editor.inspector.hl.clear();}
|
25 |
-
catch(err){console.log('No inspector to highlight with');}}});socss.view.snippets=Backbone.View.extend({template:_.template($('#template-snippet-browser').html()),snippet:_.template('<li class="snippet"><%- name %></li>'),className:'css-editor-snippet-browser',snippets:null,editor:null,events:{'click .close':'hide','click .buttons .insert-snippet':'insertSnippet'},currentSnippet:null,initialize:function(args){this.snippets=args.snippets;},render:function(){var thisView=this;var clickSnippet=function(e){e.preventDefault();var $$=$(this);thisView.$('.snippets li.snippet').removeClass('active');$(this).addClass('active');thisView.viewSnippet({name:$$.html(),description:$$.data('description'),css:$$.data('css')});};this.$el.html(this.template());for(var i=0;i<this.snippets.length;i++){$(this.snippet({name:this.snippets[i].Name})).data({'description':this.snippets[i].Description,'css':this.snippets[i].css}).appendTo(this.$('ul.snippets')).click(clickSnippet);}
|
26 |
-
thisView.$('.snippets li.snippet').eq(0).click();this.attach();return this;},viewSnippet:function(args){var w=this.$('.main .snippet-view');w.find('.snippet-title').html(args.name);w.find('.snippet-description').html(args.description);w.find('.snippet-code').html(args.css);this.currentSnippet=args;},insertSnippet:function(){var editor=this.editor.codeMirror;var css=this.currentSnippet.css;var before_css='';if(editor.doc.lineCount()===1&&editor.doc.getLine(editor.doc.lastLine()).length===0){before_css="";}
|
27 |
-
else if(editor.doc.getLine(editor.doc.lastLine()).length===0){before_css="\n";}
|
28 |
-
else{before_css="\n\n";}
|
29 |
-
editor.doc.setCursor(editor.doc.lastLine(),editor.doc.getLine(editor.doc.lastLine()).length);editor.doc.replaceSelection(before_css+css);this.hide();},attach:function(){this.$el.appendTo('body');},show:function(){this.$el.show();},hide:function(){this.$el.hide();}});socss.view.properties=Backbone.View.extend({model:socss.model.cssRules,tabTemplate:_.template('<li data-section="<%- id %>"><span class="fa fa-<%- icon %>"></span> <%- title %></li>'),sectionTemplate:_.template('<div class="section" data-section="<%- id %>"><table class="fields-table"><tbody></tbody></table></div>'),controllerTemplate:_.template('<tr><th scope="row"><%- title %></th><td></td></tr>'),propertyControllers:[],editor:null,css:'',parsed:{},activeSelector:'',editorExpandedBefore:false,events:{'click .close':'hide'},initialize:function(attr){this.parser=new cssjs();this.editor=attr.editor;},render:function(){var thisView=this;var controllers=socssOptions.propertyControllers;for(var id in controllers){var $t=$(this.tabTemplate({id:id,icon:controllers[id].icon,title:controllers[id].title})).appendTo(this.$('.section-tabs'));var $s=$(this.sectionTemplate({id:id})).appendTo(this.$('.sections'));if(!_.isEmpty(controllers[id].controllers)){for(var i=0;i<controllers[id].controllers.length;i++){var $c=$(thisView.controllerTemplate({title:controllers[id].controllers[i].title})).appendTo($s.find('tbody'));var controllerAtts=controllers[id].controllers[i];var controller;if(typeof socss.view.properties.controllers[controllerAtts.type]==='undefined'){controller=new socss.view.propertyController({el:$c.find('td'),propertiesView:thisView,args:(typeof controllerAtts.args==='undefined'?{}:controllerAtts.args)});}
|
30 |
-
else{controller=new socss.view.properties.controllers[controllerAtts.type]({el:$c.find('td'),propertiesView:thisView,args:(typeof controllerAtts.args==='undefined'?{}:controllerAtts.args)});}
|
31 |
-
thisView.propertyControllers.push(controller);controller.render();controller.initChangeEvents();}}}
|
32 |
-
this.$('.section-tabs li').click(function(){var $$=$(this);var show=thisView.$('.sections .section[data-section="'+$$.data('section')+'"]');thisView.$('.sections .section').not(show).hide().removeClass('active');show.show().addClass('active');thisView.$('.section-tabs li').not($$).removeClass('active');$$.addClass('active');}).eq(0).click();this.$('.toolbar select').change(function(){thisView.setActivateSelector($(this).find(':selected').data('selector'));});},setRuleValue:function(rule,value){if(typeof this.activeSelector==='undefined'||typeof this.activeSelector.rules==='undefined'){return;}
|
33 |
-
var newRule=true;for(var i=0;i<this.activeSelector.rules.length;i++){if(this.activeSelector.rules[i].directive===rule){this.activeSelector.rules[i].value=value;newRule=false;break;}}
|
34 |
-
if(newRule){this.activeSelector.rules.push({directive:rule,value:value});}
|
35 |
-
this.updateMainEditor(false);},getRuleValue:function(rule){if(typeof this.activeSelector==='undefined'||typeof this.activeSelector.rules==='undefined'){return'';}
|
36 |
-
for(var i=0;i<this.activeSelector.rules.length;i++){if(this.activeSelector.rules[i].directive===rule){return this.activeSelector.rules[i].value;}}
|
37 |
-
return'';},updateMainEditor:function(compress){var css;if(typeof compress==='undefined'||compress===true){css=this.parser.compressCSS(this.parsed);css=css.filter(function(v){return(typeof v.type!=='undefined'||v.rules.length>0);});}
|
38 |
-
else{css=this.parsed;}
|
39 |
-
this.editor.codeMirror.setValue(this.parser.getCSSForEditor(css).trim());},show:function(){this.editorExpandedBefore=this.editor.isExpanded();this.editor.setExpand(true);this.$el.show().animate({'left':0},'fast');},hide:function(){this.editor.setExpand(this.editorExpandedBefore);this.$el.animate({'left':-338},'fast',function(){$(this).hide();});this.updateMainEditor(true);},isVisible:function(){return this.$el.is(':visible');},loadCSS:function(css,activeSelector){this.css=css;this.parsed=this.parser.compressCSS(this.parser.parseCSS(css));var dropdown=this.$('.toolbar select').empty();for(var i=0;i<this.parsed.length;i++){var rule=this.parsed[i];if(typeof rule.subStyles!=='undefined'){for(var j=0;j<rule.subStyles.length;j++){var subRule=rule.subStyles[j];dropdown.append($('<option>').html(rule.selector+': '+subRule.selector).attr('val',rule.selector+': '+subRule.selector).data('selector',subRule));}}
|
40 |
-
else{dropdown.append($('<option>').html(rule.selector).attr('val',rule.selector).data('selector',rule));}}
|
41 |
-
if(typeof activeSelector==='undefined'){activeSelector=dropdown.find('option').eq(0).attr('val');}
|
42 |
-
dropdown.val(activeSelector).change();},setActivateSelector:function(selector){this.activeSelector=selector;for(var i=0;i<this.propertyControllers.length;i++){this.propertyControllers[i].refreshFromRule();}},addSelector:function(selector){var dropdown=this.$('.toolbar select');dropdown.val(selector);if(dropdown.val()===selector){dropdown.change();}
|
43 |
-
else{this.editor.addEmptySelector(selector);this.loadCSS(this.editor.codeMirror.getValue(),selector);}
|
44 |
-
dropdown.addClass('highlighted');setTimeout(function(){dropdown.removeClass('highlighted');},2000);}});socss.view.propertyController=Backbone.View.extend({template:_.template('<input type="text" value="" />'),activeRule:null,args:null,propertiesView:null,initialize:function(args){this.args=args.args;this.propertiesView=args.propertiesView;this.on('set_value',this.updateRule,this);this.on('change',this.updateRule,this);},render:function(){this.$el.append($(this.template({})));this.field=this.$('input');},initChangeEvents:function(){var thisView=this;this.field.on('change keyup',function(){thisView.trigger('change',$(this).val());});},updateRule:function(){this.propertiesView.setRuleValue(this.args.property,this.getValue());},refreshFromRule:function(){var value=this.propertiesView.getRuleValue(this.args.property);this.setValue(value,{silent:true});},getValue:function(){return this.field.val();},setValue:function(val,options){options=_.extend({silent:false},options);this.field.val(val);if(!options.silent){this.trigger('set_value',val);}},reset:function(options){options=_.extend({silent:false},options);this.setValue('',options);}});socss.view.properties.controllers={};socss.view.properties.controllers.color=socss.view.propertyController.extend({template:_.template('<input type="text" value="" />'),render:function(){var thisView=this;this.$el.append($(this.template({})));this.field=this.$el.find('input');this.field.minicolors({});},initChangeEvents:function(){var thisView=this;this.field.on('change keyup',function(){thisView.trigger('change',thisView.field.minicolors('value'));});},getValue:function(){return this.field.minicolors('value');},setValue:function(val,options){options=_.extend({silent:false},options);this.field.minicolors('value',val);if(!options.silent){this.trigger('set_value',val);}}});socss.view.properties.controllers.select=socss.view.propertyController.extend({template:_.template('<select></select>'),render:function(){var thisView=this;this.$el.append($(this.template({})));this.field=this.$el.find('select');this.field.append($('<option value=""></option>').html(''));for(var k in this.args.options){this.field.append($('<option></option>').attr('value',k).html(this.args.options[k]));}
|
45 |
-
if(typeof this.args.option_icons!=='undefined'){this.setupVisualSelect();}},setupVisualSelect:function(){var thisView=this;this.field.hide();var $tc=$('<div class="select-tabs"></div>').appendTo(this.$el);$('<div class="select-tab" data-value=""><span class="fa fa-circle-o"></span></div>').appendTo($tc);for(var k in this.args.option_icons){$('<div class="select-tab"></div>').appendTo($tc).append($('<span class="fa"></span>').addClass('fa-'+this.args.option_icons[k])).attr('data-value',k);}
|
46 |
-
$tc.find('.select-tab').css('width',100/($tc.find('>div').length)+"%").click(function(){var $t=$(this);$tc.find('.select-tab').removeClass('active');$t.addClass('active');thisView.field.val($t.data('value')).change();});},setValue:function(val,options){options=_.extend({silent:false},options);this.field.val(val);this.$('.select-tabs .select-tab').removeClass('active').filter('[data-value="'+val+'"]').addClass('active');if(!options.silent){this.trigger('set_value',val);}}});socss.view.properties.controllers.image=socss.view.propertyController.extend({template:_.template('<input type="text" value="" /> <span class="select socss-button"><span class="fa fa-upload"></span></span>'),render:function(){var thisView=this;this.media=wp.media({title:socssOptions.loc.select_image,library:{type:'image'},button:{text:socssOptions.loc.select,close:false}});this.$el.append($(this.template({select:socssOptions.loc.select})));this.field=this.$el.find('input');this.$('.select').click(function(){thisView.media.open();});this.media.on('select',function(){var attachment=this.state().get('selection').first().attributes;var val=thisView.args.value.replace('{{url}}',attachment.url);thisView.field.val(val).change();thisView.media.close();},this.media);}});socss.view.properties.controllers.measurement=socss.view.propertyController.extend({wrapperClass:'socss-field-measurement',render:function(){this.$el.append($(this.template({})));this.field=this.$('input');this.setupMeasurementField(this.field,{});},setValue:function(val,options){options=_.extend({silent:false},options);this.field.val(val).trigger('measurement_refresh');if(!options.silent){this.trigger('set_value',val);}},units:['px','%','em','cm','mm','in','pt','pc','ex','ch','rem','vw','vh','vmin','vmax'],parseUnits:function(value){var escapeRegExp=function(str){return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");};var regexUnits=this.units.map(escapeRegExp);var regex=new RegExp('([0-9\\.\\-]+)('+regexUnits.join('|')+')?','i');var result=regex.exec(value);if(result===null){return{value:'',unit:''};}
|
47 |
-
else{return{value:result[1],unit:result[2]===undefined?'':result[2]};}},setupMeasurementField:function($el,options){var thisView=this;var $p=$el.parent();options=_.extend({defaultUnit:'px'},options);$el.hide();$p.addClass(this.wrapperClass).data('unit',options.defaultUnit);var $fi=$('<input type="text" class="socss-field-input"/>').appendTo($p);var $da=$('<span class="dashicons dashicons-arrow-down"></span>').appendTo($p);var $dd=$('<ul class="dropdown"></ul>').appendTo($p);var $u=$('<span class="units"></span>').html(options.defaultUnit).appendTo($p);for(var i=0;i<thisView.units.length;i++){var $o=$('<li></li>').html(thisView.units[i]).data('unit',thisView.units[i]);if(thisView.units[i]===options.defaultUnit){$o.addClass('active');}
|
48 |
-
$dd.append($o);}
|
49 |
-
var updateValue=function(){var value=thisView.parseUnits($fi.val());if(value.unit!==''&&value.unit!==$p.data('unit')){$fi.val(value.value);setUnit(value.unit);}
|
50 |
-
if(value.value===''){$el.val('');}
|
51 |
-
else{$el.val(value.value+$p.data('unit'));}};var setUnit=function(unit){$u.html(unit);$p.data('unit',unit);$fi.trigger('keydown');};$da.click(function(){$dd.toggle();});$dd.find('li').click(function(){$dd.toggle();setUnit($(this).data('unit'));updateValue();$el.trigger('change');});$fi.on('keyup keydown',function(e){var $$=$(this);var char='';if(e.type==='keydown'){if(e.keyCode>=48&&e.keyCode<=57){char=String.fromCharCode(e.keyCode);}
|
52 |
-
else if(e.keyCode===189){char='-';}
|
53 |
-
else if(e.keyCode===190){char='.';}}
|
54 |
-
var $pl=$('<span class="socss-hidden-placeholder"></span>').css({'font-size':'14px'}).html($fi.val()+char).appendTo('body');var width=$pl.width();width=Math.min(width,63);$pl.remove();$u.css('left',width+12);});$fi.on('keyup',function(e){updateValue();$el.trigger('change');});$el.on('measurement_refresh',function(){var value=thisView.parseUnits($el.val());$fi.val(value.value);var unit=value.unit===''?options.defaultUnit:value.unit;$p.data('unit',unit);$u.html(unit);var $pl=$('<span class="socss-hidden-placeholder"></span>').css({'font-size':'14px'}).html(value.value).appendTo('body');var width=$pl.width();width=Math.min(width,63);$pl.remove();$u.css('left',width+12);});var $diw=$('<div class="socss-diw"></div>').appendTo($p);var $dec=$('<div class="dec-button socss-button"><span class="fa fa-minus"></span></div>').appendTo($diw);var $inc=$('<div class="inc-button socss-button"><span class="fa fa-plus"></span></div>').appendTo($diw);$inc.click(function(){var value=thisView.parseUnits($el.val());if(value.value===''){return true;}
|
55 |
-
var newVal=Math.ceil(value.value*1.05);$fi.val(newVal);updateValue();$el.trigger('change').trigger('measurement_refresh');});$dec.click(function(){var value=thisView.parseUnits($el.val());if(value.value===''){return true;}
|
56 |
-
var newVal=Math.floor(value.value/1.05);$fi.val(newVal);updateValue();$el.trigger('change').trigger('measurement_refresh');});}});socss.view.properties.controllers.number=socss.view.propertyController.extend({render:function(){this.$el.append($(this.template({})));this.field=this.$('input');this.setupNumberField(this.field,this.args);},setupNumberField:function($el,options){options=_.extend({change:null,default:0,increment:1,decrement:-1,max:null,min:null},options);var $p=$el.parent();$p.addClass('socss-field-number');var $diw=$('<div class="socss-diw"></div>').appendTo($p);var $dec=$('<div class="dec-button socss-button">-</div>').appendTo($diw);var $inc=$('<div class="inc-button socss-button">+</div>').appendTo($diw);$diw.find('> div').click(function(e){e.preventDefault();var val=options.default;if($el.val()!==''){val=Number($el.val());}
|
57 |
-
val=val+($(this).is($dec)?options.decrement:options.increment);val=Math.round(val*100)/100;if(options.max!==null){val=Math.min(options.max,val);}
|
58 |
-
if(options.min!==null){val=Math.max(options.min,val);}
|
59 |
-
$el.val(val);$el.trigger('change');});return this;}});socss.view.properties.controllers.sides=socss.view.propertyController.extend({template:_.template($('#template-sides-field').html().trim()),controllers:[],render:function(){var thisView=this;this.$el.append($(this.template({})));this.field=this.$el.find('input');if(!thisView.args.hasAll){this.$('.select-tab').eq(0).remove();this.$('.select-tab').css('width','25%');}
|
60 |
-
this.$('.select-tab').each(function(){var dir=$(this).data('direction');var container=$('<li class="side">').appendTo(thisView.$('.sides')).hide();for(var i=0;i<thisView.args.controllers.length;i++){var controllerArgs=thisView.args.controllers[i];if(typeof socss.view.properties.controllers[controllerArgs.type]){var property='';if(dir==='all'){property=controllerArgs.args.propertyAll;}
|
61 |
-
else{property=controllerArgs.args.property.replace('{dir}',dir);}
|
62 |
-
var theseControllerArgs=_.extend({},controllerArgs.args,{property:property});var controller=new socss.view.properties.controllers[controllerArgs.type]({el:$('<div>').appendTo(container),propertiesView:thisView.propertiesView,args:theseControllerArgs});controller.render();controller.initChangeEvents();thisView.propertiesView.propertyControllers.push(controller);}}
|
63 |
-
$(this).on('click',function(){thisView.$('.select-tab').removeClass('active');$(this).addClass('active');thisView.$('.sides .side').hide();container.show();});});this.$('.select-tab').eq(0).click();}});})(jQuery,_,socssOptions);jQuery(function($){var socss=window.socss;var editor=new socss.view.editor({el:$('#so-custom-css-form').get(0)});editor.render();editor.setSnippets(socssOptions.snippets);window.socss.mainEditor=editor;$('#so-custom-css-getting-started a.hide').click(function(e){e.preventDefault();$('#so-custom-css-getting-started').slideUp();$.get($(this).attr('href'));});});
|
1 |
+
!function(e,t,i){var s={model:{},collection:{},view:{},fn:{}};window.socss=s,s.view.toolbar=Backbone.View.extend({button:t.template('<li><a href="#" class="toolbar-button socss-button"><%= text %></a></li>'),editor:null,initialize:function(t){this.editor=t.editor;var i=this;this.$(".editor-expand").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_expand")}),this.$(".editor-visual").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_visual")})},addButton:function(t,i){var s=this,n=e(this.button({text:t})).appendTo(this.$(".toolbar-function-buttons .toolbar-buttons")).click(function(t){t.preventDefault(),e(this).blur(),s.trigger("click_"+i)});return n}}),s.view.editor=Backbone.View.extend({codeMirror:null,snippets:null,toolbar:null,visualProperties:null,inspector:null,cssSelectors:[],initialize:function(e){this.setupEditor()},render:function(){var t=this;this.toolbar=new s.view.toolbar({editor:this,el:this.$(".custom-css-toolbar")}),this.toolbar.editor=this,this.toolbar.render(),this.visualProperties=new s.view.properties({editor:this,el:e("#so-custom-css-properties")}),this.visualProperties.render(),this.toolbar.on("click_expand",function(){t.toggleExpand()}),this.toolbar.on("click_visual",function(){t.visualProperties.loadCSS(t.codeMirror.getValue()),t.visualProperties.show()}),this.preview=new s.view.preview({editor:this,el:this.$(".custom-css-preview")}),this.preview.render()},setupEditor:function(){var t=this;this.registerCodeMirrorAutocomplete(),this.codeMirror=CodeMirror.fromTextArea(this.$("textarea.css-editor").get(0),{tabSize:2,mode:"css",theme:"neat",gutters:["CodeMirror-lint-markers"],lint:!0});var s=this.$("textarea.css-editor").val();this.$el.on("submit",function(){s=t.codeMirror.getValue()}),e(window).bind("beforeunload",function(){return t.codeMirror.getValue()!==s?i.loc.leave:void 0}),this.$el.find(".custom-css-container").css("overflow","visible"),this.scaleEditor(),e(window).resize(function(){t.scaleEditor()}),this.setupCodeMirrorExtensions()},registerCodeMirrorAutocomplete:function(){var e=this,t={link:1,visited:1,active:1,hover:1,focus:1,"first-letter":1,"first-line":1,"first-child":1,before:1,after:1,lang:1};CodeMirror.registerHelper("hint","css",function(i){function s(e){for(var t in e)c&&0!==t.lastIndexOf(c,0)||p.push(t)}var n=i.getCursor(),r=i.getTokenAt(n),o=CodeMirror.innerMode(i.getMode(),r.state);if("css"===o.mode.name){if("keyword"===r.type&&0==="!important".indexOf(r.string))return{list:["!important"],from:CodeMirror.Pos(n.line,r.start),to:CodeMirror.Pos(n.line,r.end)};var a=r.start,l=n.ch,c=r.string.slice(0,l-a);/[^\w$_-]/.test(c)&&(c="",a=l=n.ch);var d=CodeMirror.resolveMode("text/css"),p=[],h=o.state.state;if("top"===h){for(var u=i.getLine(n.line).trim(),v=e.cssSelectors,f=0;f<v.length;f++)-1!==v[f].selector.indexOf(u)&&p.push(v[f].selector);if(p.length)return{list:p,from:CodeMirror.Pos(n.line,0),to:CodeMirror.Pos(n.line,l)}}else if("pseudo"===h||"variable-3"===r.type?s(t):"block"===h||"maybeprop"===h?s(d.propertyKeywords):"prop"===h||"parens"===h||"at"===h||"params"===h?(s(d.valueKeywords),s(d.colorKeywords)):("media"===h||"media_parens"===h)&&(s(d.mediaTypes),s(d.mediaFeatures)),p.length)return{list:p,from:CodeMirror.Pos(n.line,a),to:CodeMirror.Pos(n.line,l)}}})},setupCodeMirrorExtensions:function(){var e=this;this.codeMirror.on("cursorActivity",function(t){var i=t.getCursor(),s=t.getTokenAt(i);CodeMirror.innerMode(t.getMode(),s.state);if("qualifier"===s.type||"tag"===s.type||"builtin"===s.type){var n=t.getLine(i.line),r=n.substring(0,s.end);e.preview.highlight(r)}else e.preview.clearHighlight()}),this.codeMirror.on("keyup",function(e,t){(t.keyCode>=65&&t.keyCode<=90||189===t.keyCode&&!t.shiftKey||190===t.keyCode&&!t.shiftKey||51===t.keyCode&&t.shiftKey||189===t.keyCode&&t.shiftKey)&&e.showHint(t)})},scaleEditor:function(){this.$el.hasClass("expanded")?this.codeMirror.setSize("100%",e(window).outerHeight()-this.$(".custom-css-toolbar").outerHeight()):this.codeMirror.setSize("100%","auto")},isExpanded:function(){return this.$el.hasClass("expanded")},toggleExpand:function(){this.$el.toggleClass("expanded"),this.scaleEditor()},setExpand:function(e){e?this.$el.addClass("expanded"):this.$el.removeClass("expanded"),this.scaleEditor()},setSnippets:function(e){if(!t.isEmpty(e)){var i=this;this.snippets=new s.view.snippets({snippets:e}),this.snippets.editor=this,this.snippets.render(),this.toolbar.addButton("Snippets","snippets"),this.toolbar.on("click_snippets",function(){i.snippets.show()})}},addCode:function(e){var t=this.codeMirror,i="";i=1===t.doc.lineCount()&&0===t.doc.getLine(t.doc.lastLine()).length?"":0===t.doc.getLine(t.doc.lastLine()).length?"\n":"\n\n",t.doc.setCursor(t.doc.lastLine(),t.doc.getLine(t.doc.lastLine()).length),t.doc.replaceSelection(i+e)},addEmptySelector:function(e){this.addCode(e+" {\n \n}")},setInspector:function(e){var t=this;this.inspector=e,this.cssSelectors=e.pageSelectors,e.on("click_selector",function(e){t.visualProperties.isVisible()?t.visualProperties.addSelector(e):t.addEmptySelector(e)}),e.on("click_property",function(e){t.visualProperties.isVisible()||t.codeMirror.replaceSelection(e+";\n ")}),e.on("set_active_element",function(e,i){t.visualProperties.isVisible()&&i.length&&t.visualProperties.addSelector(i[0].selector)})}}),s.view.preview=Backbone.View.extend({template:t.template('<iframe class="preview-iframe" seamless="seamless"></iframe>'),editor:null,initialize:function(e){this.editor=e.editor;var t=this;this.editor.codeMirror.on("change",function(e,i){t.updatePreviewCss()})},render:function(){var t=this;this.$el.html(this.template()),this.$(".preview-iframe").attr("src",i.homeURL).load(function(){var i=e(this);i.contents().find("a").each(function(){var t=e(this).attr("href");if(void 0===t)return!0;var i=-1===t.indexOf("?")?"?":"&";e(this).attr("href",t+i+"so_css_preview=1")}),t.updatePreviewCss()}).mouseleave(function(){t.clearHighlight()})},updatePreviewCss:function(){var e=this.$(".preview-iframe");if(0!==e.length){var t=e.contents().find("head");0===t.find("style.siteorigin-custom-css").length&&t.append('<style class="siteorigin-custom-css" type="text/css"></style>');var i=t.find("style.siteorigin-custom-css"),s=this.editor.codeMirror.getValue();i.html(s)}},highlight:function(e){try{this.editor.inspector.hl.highlight(e)}catch(t){console.log("No inspector to highlight with")}},clearHighlight:function(){try{this.editor.inspector.hl.clear()}catch(e){console.log("No inspector to highlight with")}}}),s.view.snippets=Backbone.View.extend({template:t.template(e("#template-snippet-browser").html()),snippet:t.template('<li class="snippet"><%- name %></li>'),className:"css-editor-snippet-browser",snippets:null,editor:null,events:{"click .close":"hide","click .buttons .insert-snippet":"insertSnippet"},currentSnippet:null,initialize:function(e){this.snippets=e.snippets},render:function(){var t=this,i=function(i){i.preventDefault();var s=e(this);t.$(".snippets li.snippet").removeClass("active"),e(this).addClass("active"),t.viewSnippet({name:s.html(),description:s.data("description"),css:s.data("css")})};this.$el.html(this.template());for(var s=0;s<this.snippets.length;s++)e(this.snippet({name:this.snippets[s].Name})).data({description:this.snippets[s].Description,css:this.snippets[s].css}).appendTo(this.$("ul.snippets")).click(i);return t.$(".snippets li.snippet").eq(0).click(),this.attach(),this},viewSnippet:function(e){var t=this.$(".main .snippet-view");t.find(".snippet-title").html(e.name),t.find(".snippet-description").html(e.description),t.find(".snippet-code").html(e.css),this.currentSnippet=e},insertSnippet:function(){var e=this.editor.codeMirror,t=this.currentSnippet.css,i="";i=1===e.doc.lineCount()&&0===e.doc.getLine(e.doc.lastLine()).length?"":0===e.doc.getLine(e.doc.lastLine()).length?"\n":"\n\n",e.doc.setCursor(e.doc.lastLine(),e.doc.getLine(e.doc.lastLine()).length),e.doc.replaceSelection(i+t),this.hide()},attach:function(){this.$el.appendTo("body")},show:function(){this.$el.show()},hide:function(){this.$el.hide()}}),s.view.properties=Backbone.View.extend({model:s.model.cssRules,tabTemplate:t.template('<li data-section="<%- id %>"><span class="fa fa-<%- icon %>"></span> <%- title %></li>'),sectionTemplate:t.template('<div class="section" data-section="<%- id %>"><table class="fields-table"><tbody></tbody></table></div>'),controllerTemplate:t.template('<tr><th scope="row"><%- title %></th><td></td></tr>'),propertyControllers:[],editor:null,css:"",parsed:{},activeSelector:"",editorExpandedBefore:!1,events:{"click .close":"hide"},initialize:function(e){this.parser=new cssjs,this.editor=e.editor},render:function(){var n=this,r=i.propertyControllers;for(var o in r){var a=(e(this.tabTemplate({id:o,icon:r[o].icon,title:r[o].title})).appendTo(this.$(".section-tabs")),e(this.sectionTemplate({id:o})).appendTo(this.$(".sections")));if(!t.isEmpty(r[o].controllers))for(var l=0;l<r[o].controllers.length;l++){var c,d=e(n.controllerTemplate({title:r[o].controllers[l].title})).appendTo(a.find("tbody")),p=r[o].controllers[l];c="undefined"==typeof s.view.properties.controllers[p.type]?new s.view.propertyController({el:d.find("td"),propertiesView:n,args:"undefined"==typeof p.args?{}:p.args}):new s.view.properties.controllers[p.type]({el:d.find("td"),propertiesView:n,args:"undefined"==typeof p.args?{}:p.args}),n.propertyControllers.push(c),c.render(),c.initChangeEvents()}}this.$(".section-tabs li").click(function(){var t=e(this),i=n.$('.sections .section[data-section="'+t.data("section")+'"]');n.$(".sections .section").not(i).hide().removeClass("active"),i.show().addClass("active"),n.$(".section-tabs li").not(t).removeClass("active"),t.addClass("active")}).eq(0).click(),this.$(".toolbar select").change(function(){n.setActivateSelector(e(this).find(":selected").data("selector"))})},setRuleValue:function(e,t){if("undefined"!=typeof this.activeSelector&&"undefined"!=typeof this.activeSelector.rules){for(var i=!0,s=0;s<this.activeSelector.rules.length;s++)if(this.activeSelector.rules[s].directive===e){this.activeSelector.rules[s].value=t,i=!1;break}i&&this.activeSelector.rules.push({directive:e,value:t}),this.updateMainEditor(!1)}},getRuleValue:function(e){if("undefined"==typeof this.activeSelector||"undefined"==typeof this.activeSelector.rules)return"";for(var t=0;t<this.activeSelector.rules.length;t++)if(this.activeSelector.rules[t].directive===e)return this.activeSelector.rules[t].value;return""},updateMainEditor:function(e){var t;"undefined"==typeof e||e===!0?(t=this.parser.compressCSS(this.parsed),t=t.filter(function(e){return"undefined"!=typeof e.type||e.rules.length>0})):t=this.parsed,this.editor.codeMirror.setValue(this.parser.getCSSForEditor(t).trim())},show:function(){this.editorExpandedBefore=this.editor.isExpanded(),this.editor.setExpand(!0),this.$el.show().animate({left:0},"fast")},hide:function(){this.editor.setExpand(this.editorExpandedBefore),this.$el.animate({left:-338},"fast",function(){e(this).hide()}),this.updateMainEditor(!0)},isVisible:function(){return this.$el.is(":visible")},loadCSS:function(t,i){this.css=t,this.parsed=this.parser.compressCSS(this.parser.parseCSS(t));for(var s=this.$(".toolbar select").empty(),n=0;n<this.parsed.length;n++){var r=this.parsed[n];if("undefined"!=typeof r.subStyles)for(var o=0;o<r.subStyles.length;o++){var a=r.subStyles[o];s.append(e("<option>").html(r.selector+": "+a.selector).attr("val",r.selector+": "+a.selector).data("selector",a))}else s.append(e("<option>").html(r.selector).attr("val",r.selector).data("selector",r))}"undefined"==typeof i&&(i=s.find("option").eq(0).attr("val")),s.val(i).change()},setActivateSelector:function(e){this.activeSelector=e;for(var t=0;t<this.propertyControllers.length;t++)this.propertyControllers[t].refreshFromRule()},addSelector:function(e){var t=this.$(".toolbar select");t.val(e),t.val()===e?t.change():(this.editor.addEmptySelector(e),this.loadCSS(this.editor.codeMirror.getValue(),e)),t.addClass("highlighted"),setTimeout(function(){t.removeClass("highlighted")},2e3)}}),s.view.propertyController=Backbone.View.extend({template:t.template('<input type="text" value="" />'),activeRule:null,args:null,propertiesView:null,initialize:function(e){this.args=e.args,this.propertiesView=e.propertiesView,this.on("set_value",this.updateRule,this),this.on("change",this.updateRule,this)},render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input")},initChangeEvents:function(){var t=this;this.field.on("change keyup",function(){t.trigger("change",e(this).val())})},updateRule:function(){this.propertiesView.setRuleValue(this.args.property,this.getValue())},refreshFromRule:function(){var e=this.propertiesView.getRuleValue(this.args.property);this.setValue(e,{silent:!0})},getValue:function(){return this.field.val()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),i.silent||this.trigger("set_value",e)},reset:function(e){e=t.extend({silent:!1},e),this.setValue("",e)}}),s.view.properties.controllers={},s.view.properties.controllers.color=s.view.propertyController.extend({template:t.template('<input type="text" value="" />'),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),this.field.minicolors({})},initChangeEvents:function(){var e=this;this.field.on("change keyup",function(){e.trigger("change",e.field.minicolors("value"))})},getValue:function(){return this.field.minicolors("value")},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.minicolors("value",e),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.select=s.view.propertyController.extend({template:t.template("<select></select>"),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("select"),this.field.append(e('<option value=""></option>').html(""));for(var t in this.args.options)this.field.append(e("<option></option>").attr("value",t).html(this.args.options[t]));"undefined"!=typeof this.args.option_icons&&this.setupVisualSelect()},setupVisualSelect:function(){var t=this;this.field.hide();var i=e('<div class="select-tabs"></div>').appendTo(this.$el);e('<div class="select-tab" data-value=""><span class="fa fa-circle-o"></span></div>').appendTo(i);for(var s in this.args.option_icons)e('<div class="select-tab"></div>').appendTo(i).append(e('<span class="fa"></span>').addClass("fa-"+this.args.option_icons[s])).attr("data-value",s);i.find(".select-tab").css("width",100/i.find(">div").length+"%").click(function(){var s=e(this);i.find(".select-tab").removeClass("active"),s.addClass("active"),t.field.val(s.data("value")).change()})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),this.$(".select-tabs .select-tab").removeClass("active").filter('[data-value="'+e+'"]').addClass("active"),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.image=s.view.propertyController.extend({template:t.template('<input type="text" value="" /> <span class="select socss-button"><span class="fa fa-upload"></span></span>'),render:function(){var t=this;this.media=wp.media({title:i.loc.select_image,library:{type:"image"},button:{text:i.loc.select,close:!1}}),this.$el.append(e(this.template({select:i.loc.select}))),this.field=this.$el.find("input"),this.$(".select").click(function(){t.media.open()}),this.media.on("select",function(){var e=this.state().get("selection").first().attributes,i=t.args.value.replace("{{url}}",e.url);t.field.val(i).change(),t.media.close()},this.media)}}),s.view.properties.controllers.measurement=s.view.propertyController.extend({wrapperClass:"socss-field-measurement",render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupMeasurementField(this.field,{})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e).trigger("measurement_refresh"),i.silent||this.trigger("set_value",e)},units:["px","%","em","cm","mm","in","pt","pc","ex","ch","rem","vw","vh","vmin","vmax"],parseUnits:function(e){var t=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},i=this.units.map(t),s=new RegExp("([0-9\\.\\-]+)("+i.join("|")+")?","i"),n=s.exec(e);return null===n?{value:"",unit:""}:{value:n[1],unit:void 0===n[2]?"":n[2]}},setupMeasurementField:function(i,s){var n=this,r=i.parent();s=t.extend({defaultUnit:"px"},s),i.hide(),r.addClass(this.wrapperClass).data("unit",s.defaultUnit);for(var o=e('<input type="text" class="socss-field-input"/>').appendTo(r),a=e('<span class="dashicons dashicons-arrow-down"></span>').appendTo(r),l=e('<ul class="dropdown"></ul>').appendTo(r),c=e('<span class="units"></span>').html(s.defaultUnit).appendTo(r),d=0;d<n.units.length;d++){var p=e("<li></li>").html(n.units[d]).data("unit",n.units[d]);n.units[d]===s.defaultUnit&&p.addClass("active"),l.append(p)}var h=function(){var e=n.parseUnits(o.val());""!==e.unit&&e.unit!==r.data("unit")&&(o.val(e.value),u(e.unit)),""===e.value?i.val(""):i.val(e.value+r.data("unit"))},u=function(e){c.html(e),r.data("unit",e),o.trigger("keydown")};a.click(function(){l.toggle()}),l.find("li").click(function(){l.toggle(),u(e(this).data("unit")),h(),i.trigger("change")}),o.on("keyup keydown",function(t){var i=(e(this),"");"keydown"===t.type&&(t.keyCode>=48&&t.keyCode<=57?i=String.fromCharCode(t.keyCode):189===t.keyCode?i="-":190===t.keyCode&&(i="."));var s=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(o.val()+i).appendTo("body"),n=s.width();n=Math.min(n,63),s.remove(),c.css("left",n+12)}),o.on("keyup",function(e){h(),i.trigger("change")}),i.on("measurement_refresh",function(){var t=n.parseUnits(i.val());o.val(t.value);var a=""===t.unit?s.defaultUnit:t.unit;r.data("unit",a),c.html(a);var l=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(t.value).appendTo("body"),d=l.width();d=Math.min(d,63),l.remove(),c.css("left",d+12)});var v=e('<div class="socss-diw"></div>').appendTo(r),f=e('<div class="dec-button socss-button"><span class="fa fa-minus"></span></div>').appendTo(v),g=e('<div class="inc-button socss-button"><span class="fa fa-plus"></span></div>').appendTo(v);g.click(function(){var e=n.parseUnits(i.val());if(""===e.value)return!0;var t=Math.ceil(1.05*e.value);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")}),f.click(function(){var e=n.parseUnits(i.val());if(""===e.value)return!0;var t=Math.floor(e.value/1.05);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")})}}),s.view.properties.controllers.number=s.view.propertyController.extend({render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupNumberField(this.field,this.args)},setupNumberField:function(i,s){s=t.extend({change:null,"default":0,increment:1,decrement:-1,max:null,min:null},s);var n=i.parent();n.addClass("socss-field-number");var r=e('<div class="socss-diw"></div>').appendTo(n),o=e('<div class="dec-button socss-button">-</div>').appendTo(r);e('<div class="inc-button socss-button">+</div>').appendTo(r);return r.find("> div").click(function(t){t.preventDefault();var n=s["default"];""!==i.val()&&(n=Number(i.val())),n+=e(this).is(o)?s.decrement:s.increment,n=Math.round(100*n)/100,null!==s.max&&(n=Math.min(s.max,n)),null!==s.min&&(n=Math.max(s.min,n)),i.val(n),i.trigger("change")}),this}}),s.view.properties.controllers.sides=s.view.propertyController.extend({template:t.template(e("#template-sides-field").html().trim()),controllers:[],render:function(){var i=this;this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),i.args.hasAll||(this.$(".select-tab").eq(0).remove(),this.$(".select-tab").css("width","25%")),this.$(".select-tab").each(function(){for(var n=e(this).data("direction"),r=e('<li class="side">').appendTo(i.$(".sides")).hide(),o=0;o<i.args.controllers.length;o++){var a=i.args.controllers[o],l="";l="all"===n?a.args.propertyAll:a.args.property.replace("{dir}",n);var c=t.extend({},a.args,{property:l}),d=new s.view.properties.controllers[a.type]({el:e("<div>").appendTo(r),propertiesView:i.propertiesView,args:c});d.render(),d.initChangeEvents(),i.propertiesView.propertyControllers.push(d)}e(this).on("click",function(){i.$(".select-tab").removeClass("active"),e(this).addClass("active"),i.$(".sides .side").hide(),r.show()})}),this.$(".select-tab").eq(0).click()}})}(jQuery,_,socssOptions),jQuery(function(e){var t=window.socss,i=new t.view.editor({el:e("#so-custom-css-form").get(0)});i.render(),i.setSnippets(socssOptions.snippets),window.socss.mainEditor=i,e("#so-custom-css-getting-started a.hide").click(function(t){t.preventDefault(),e("#so-custom-css-getting-started").slideUp(),e.get(e(this).attr("href"))})});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/inspector.min.js
CHANGED
@@ -1,26 +1 @@
|
|
1 |
-
|
2 |
-
(function($,_,socssOptions){var socss={model:{},collection:{},view:{},fn:{}};socss.view.inspector=Backbone.View.extend({active:false,hl:false,hoverEl:false,pageSelectors:[],selectorTemplate:_.template('<div class="socss-selector"><%= selector %></div>'),initialize:function(){var thisView=this;this.hl=new socss.view.highlighter();this.hl.initialize();this.pageSelectors=socss.fn.pageSelectors();$('body').on('mouseover','*',function(e){if(!thisView.active){return true;}
|
3 |
-
var $$=$(this);if($$.closest('.socss-element').length===0){e.stopPropagation();thisView.setHoverEl($(this));}});$('body *').click(function(e){if(!thisView.active||thisView.$el.is(':hover')){return true;}
|
4 |
-
e.preventDefault();e.stopPropagation();var $$=$(this);$$.blur();thisView.setActiveEl(thisView.hoverEl);});this.$('.socss-enable-inspector').click(function(){thisView.toggleActive();});this.$el.mouseenter(function(){thisView.hl.clear();});try{parent.socss.mainEditor.setInspector(this);}
|
5 |
-
catch(err){console.log('No editor to register this inspector with');}},setHoverEl:function(hoverEl){this.hoverEl=hoverEl;this.hl.highlight(hoverEl);},activate:function(){this.active=true;$('body').addClass('socss-active');$('body').removeClass('socss-inactive');},deactivate:function(){this.active=false;$('body').addClass('socss-inactive');$('body').removeClass('socss-active');this.hl.clear();this.$('.socss-hierarchy').empty();},toggleActive:function(){if(this.active){this.deactivate();}
|
6 |
-
else{this.activate();}},setActiveEl:function(el){var thisView=this;var $h=this.$('.socss-hierarchy');$h.empty();if(el.prop('tagName').toLowerCase()!=='body'){var cel=$(el);do{$(this.selectorTemplate({selector:socss.fn.elSelector(cel)})).prependTo($h).data('el',cel);cel=cel.parent();}while(cel.prop('tagName').toLowerCase()!=='body');$(this.selectorTemplate({selector:'body'})).prependTo($h).data('el',$('body'));this.$('.socss-hierarchy .socss-selector').hover(function(){thisView.hl.highlight($(this).data('el'));}).click(function(e){e.preventDefault();e.stopPropagation();thisView.setActiveEl($(this).data('el'));});}
|
7 |
-
$h.scrollLeft(99999);var selectors=this.pageSelectors.filter(function(a){try{return el.is(a.selector);}
|
8 |
-
catch(err){return false;}});var container=this.$('.socss-selectors-window').empty();_.each(selectors,function(selector){container.append($(thisView.selectorTemplate(selector)).data(selector));});container.find('> div').mouseenter(function(){thisView.hl.highlight($(this).data('selector'));}).click(function(e){e.preventDefault();e.stopPropagation();thisView.trigger('click_selector',$(this).data('selector'));});var attributes=socss.fn.elementAttributes(el);container=this.$('.socss-properties-window').empty();_.each(attributes,function(v,k){container.append($(thisView.selectorTemplate({selector:'<strong>'+k+'</strong>: '+v})).data('property',k+': '+v));});container.find('> div').click(function(e){e.preventDefault();e.stopPropagation();thisView.trigger('click_property',$(this).data('property'));});var link=el.closest('a[href]');var linkContainer=this.$('.socss-link');if(link.length){linkContainer.show().find('a').html(link.attr('href').replace(/[\?&]*so_css_preview=1/,'')).attr('href',link.attr('href'));}
|
9 |
-
else{linkContainer.hide();}
|
10 |
-
this.trigger('set_active_element',el,selectors);}});socss.view.highlighter=Backbone.View.extend({template:_.template($('#socss-template-hover').html().trim()),highlighted:[],highlight:function(els){this.clear();var thisView=this;$(els).each(function(i,el){el=$(el);if(!el.is(':visible')){return true;}
|
11 |
-
var hl=$(thisView.template());hl.css({'top':el.offset().top,'left':el.offset().left,'width':el.outerWidth(),'height':el.outerHeight()}).appendTo('body');var g;var padding=el.padding();for(var k in padding){if(parseInt(padding[k])>0){g=hl.find('.socss-guide-padding.socss-guide-'+k).show();if(k==='top'||k==='bottom'){g.css('height',padding[k]);}
|
12 |
-
else{g.css('width',padding[k]);g.css({'width':padding[k],'top':padding.top,'bottom':padding.bottom});}}}
|
13 |
-
var margin=el.margin();for(var k in margin){if(parseInt(margin[k])>0){g=hl.find('.socss-guide-margin.socss-guide-'+k).show();if(k==='top'||k==='bottom'){g.css('height',margin[k]);}
|
14 |
-
else{g.css('width',margin[k]);}}}
|
15 |
-
thisView.highlighted.push(hl);});},clear:function(){while(this.highlighted.length){this.highlighted.pop().remove();}}});socss.parsedCss={};socss.fn.getParsedCss=function(){if(Object.keys(socss.parsedCss).length===0){var parser=new cssjs();$('.socss-theme-styles').each(function(){var $$=$(this);var p=parser.parseCSS($$.html());socss.parsedCss[$$.attr('id')]=p;});}
|
16 |
-
return socss.parsedCss;};socss.fn.pageSelectors=function(){var selectors=[];var parsedCss=socss.fn.getParsedCss();for(var k in parsedCss){for(var i=0;i<parsedCss[k].length;i++){if(typeof parsedCss[k][i].selector==='undefined'){continue;}
|
17 |
-
var ruleSpecificity=SPECIFICITY.calculate(parsedCss[k][i].selector);for(var j=0;j<ruleSpecificity.length;j++){selectors.push({'selector':ruleSpecificity[j].selector.trim(),'specificity':parseInt(ruleSpecificity[j].specificity.replace(/,/g,''))});}}}
|
18 |
-
$('body *').each(function(){var $$=$(this);var elName=socss.fn.elSelector($$);var ruleSpecificity=SPECIFICITY.calculate(elName);for(var k=0;k<ruleSpecificity.length;k++){selectors.push({'selector':ruleSpecificity[k].selector.trim(),'specificity':parseInt(ruleSpecificity[k].specificity.replace(/,/g,''))});}});selectors=_.uniq(selectors,false,function(a){return a.selector;});selectors.sort(function(a,b){return a.specificity>b.specificity?-1:1;});return selectors;};socss.fn.elementAttributes=function(el){if(!document.styleSheets){return[];}
|
19 |
-
var elProperties=[];var trimFunc=function(e){return e.trim();};var filterFunc=function(e){return e!=='';};var splitFunc=function(e){return e.split(':').map(trimFunc);};var parsedCss=socss.fn.getParsedCss();for(var k in parsedCss){for(var i=0;i<parsedCss[k].length;i++){if(typeof parsedCss[k][i].selector==='undefined'||typeof parsedCss[k][i].type!=='undefined'||parsedCss[k][i].selector[0]==='@'){continue;}
|
20 |
-
var ruleSpecificity=SPECIFICITY.calculate(parsedCss[k][i].selector);for(var j=0;j<ruleSpecificity.length;j++){try{if(el.is(ruleSpecificity[j].selector)){for(var l=0;l<parsedCss[k][i].rules.length;l++){elProperties.push({'name':parsedCss[k][i].rules[l].directive,'value':parsedCss[k][i].rules[l].value,'specificity':parseInt(ruleSpecificity[j].specificity.replace(/,/g,''))});}}}
|
21 |
-
catch(e){}}}}
|
22 |
-
elProperties.sort(function(a,b){return a.specificity>b.specificity?1:-1;}).reverse();var returnProperties={};for(var pi=0;pi<elProperties.length;pi++){if(typeof returnProperties[elProperties[pi].name]==='undefined'){returnProperties[elProperties[pi].name]=elProperties[pi].value;}}
|
23 |
-
return returnProperties;};socss.fn.elSelector=function(el){var elName='';if(el.attr('id')!==undefined){elName+='#'+el.attr('id');}
|
24 |
-
if(el.attr('class')!==undefined){elName+='.'+el.attr('class').replace(/\s+/,'.');}
|
25 |
-
if(elName===''){elName=el.prop('tagName').toLowerCase();}
|
26 |
-
return elName;};window.socssInspector=socss;})(jQuery,_,socssOptions);jQuery(function($){var socss=window.socssInspector;var inspector=new socss.view.inspector({el:$('#socss-inspector-interface').get(0)});inspector.activate();window.socssInspector.mainInspector=inspector;});
|
1 |
+
!function(e,t,s){var i={model:{},collection:{},view:{},fn:{}};i.view.inspector=Backbone.View.extend({active:!1,hl:!1,hoverEl:!1,pageSelectors:[],selectorTemplate:t.template('<div class="socss-selector"><%= selector %></div>'),initialize:function(){var t=this;this.hl=new i.view.highlighter,this.hl.initialize(),this.pageSelectors=i.fn.pageSelectors(),e("body").on("mouseover","*",function(s){if(!t.active)return!0;var i=e(this);0===i.closest(".socss-element").length&&(s.stopPropagation(),t.setHoverEl(e(this)))}),e("body *").click(function(s){if(!t.active||t.$el.is(":hover"))return!0;s.preventDefault(),s.stopPropagation();var i=e(this);i.blur(),t.setActiveEl(t.hoverEl)}),this.$(".socss-enable-inspector").click(function(){t.toggleActive()}),this.$el.mouseenter(function(){t.hl.clear()});try{parent.socss.mainEditor.setInspector(this)}catch(s){console.log("No editor to register this inspector with")}},setHoverEl:function(e){this.hoverEl=e,this.hl.highlight(e)},activate:function(){this.active=!0,e("body").addClass("socss-active"),e("body").removeClass("socss-inactive")},deactivate:function(){this.active=!1,e("body").addClass("socss-inactive"),e("body").removeClass("socss-active"),this.hl.clear(),this.$(".socss-hierarchy").empty()},toggleActive:function(){this.active?this.deactivate():this.activate()},setActiveEl:function(s){var r=this,o=this.$(".socss-hierarchy");if(o.empty(),"body"!==s.prop("tagName").toLowerCase()){var c=e(s);do e(this.selectorTemplate({selector:i.fn.elSelector(c)})).prependTo(o).data("el",c),c=c.parent();while("body"!==c.prop("tagName").toLowerCase());e(this.selectorTemplate({selector:"body"})).prependTo(o).data("el",e("body")),this.$(".socss-hierarchy .socss-selector").hover(function(){r.hl.highlight(e(this).data("el"))}).click(function(t){t.preventDefault(),t.stopPropagation(),r.setActiveEl(e(this).data("el"))})}o.scrollLeft(99999);var n=this.pageSelectors.filter(function(e){try{return s.is(e.selector)}catch(t){return!1}}),a=this.$(".socss-selectors-window").empty();t.each(n,function(t){a.append(e(r.selectorTemplate(t)).data(t))}),a.find("> div").mouseenter(function(){r.hl.highlight(e(this).data("selector"))}).click(function(t){t.preventDefault(),t.stopPropagation(),r.trigger("click_selector",e(this).data("selector"))});var l=i.fn.elementAttributes(s);a=this.$(".socss-properties-window").empty(),t.each(l,function(t,s){a.append(e(r.selectorTemplate({selector:"<strong>"+s+"</strong>: "+t})).data("property",s+": "+t))}),a.find("> div").click(function(t){t.preventDefault(),t.stopPropagation(),r.trigger("click_property",e(this).data("property"))});var h=s.closest("a[href]"),p=this.$(".socss-link");h.length?p.show().find("a").html(h.attr("href").replace(/[\?&]*so_css_preview=1/,"")).attr("href",h.attr("href")):p.hide(),this.trigger("set_active_element",s,n)}}),i.view.highlighter=Backbone.View.extend({template:t.template(e("#socss-template-hover").html().trim()),highlighted:[],highlight:function(t){this.clear();var s=this;e(t).each(function(t,i){if(i=e(i),!i.is(":visible"))return!0;var r=e(s.template());r.css({top:i.offset().top,left:i.offset().left,width:i.outerWidth(),height:i.outerHeight()}).appendTo("body");var o,c=i.padding();for(var n in c)parseInt(c[n])>0&&(o=r.find(".socss-guide-padding.socss-guide-"+n).show(),"top"===n||"bottom"===n?o.css("height",c[n]):(o.css("width",c[n]),o.css({width:c[n],top:c.top,bottom:c.bottom})));var a=i.margin();for(var n in a)parseInt(a[n])>0&&(o=r.find(".socss-guide-margin.socss-guide-"+n).show(),"top"===n||"bottom"===n?o.css("height",a[n]):o.css("width",a[n]));s.highlighted.push(r)})},clear:function(){for(;this.highlighted.length;)this.highlighted.pop().remove()}}),i.parsedCss={},i.fn.getParsedCss=function(){if(0===Object.keys(i.parsedCss).length){var t=new cssjs;e(".socss-theme-styles").each(function(){var s=e(this),r=t.parseCSS(s.html());i.parsedCss[s.attr("id")]=r})}return i.parsedCss},i.fn.pageSelectors=function(){var s=[],r=i.fn.getParsedCss();for(var o in r)for(var c=0;c<r[o].length;c++)if("undefined"!=typeof r[o][c].selector)for(var n=SPECIFICITY.calculate(r[o][c].selector),a=0;a<n.length;a++)s.push({selector:n[a].selector.trim(),specificity:parseInt(n[a].specificity.replace(/,/g,""))});return e("body *").each(function(){for(var t=e(this),r=i.fn.elSelector(t),o=SPECIFICITY.calculate(r),c=0;c<o.length;c++)s.push({selector:o[c].selector.trim(),specificity:parseInt(o[c].specificity.replace(/,/g,""))})}),s=t.uniq(s,!1,function(e){return e.selector}),s.sort(function(e,t){return e.specificity>t.specificity?-1:1}),s},i.fn.elementAttributes=function(e){if(!document.styleSheets)return[];var t=[],s=i.fn.getParsedCss();for(var r in s)for(var o=0;o<s[r].length;o++)if("undefined"!=typeof s[r][o].selector&&"undefined"==typeof s[r][o].type&&"@"!==s[r][o].selector[0])for(var c=SPECIFICITY.calculate(s[r][o].selector),n=0;n<c.length;n++)try{if(e.is(c[n].selector))for(var a=0;a<s[r][o].rules.length;a++)t.push({name:s[r][o].rules[a].directive,value:s[r][o].rules[a].value,specificity:parseInt(c[n].specificity.replace(/,/g,""))})}catch(l){}t.sort(function(e,t){return e.specificity>t.specificity?1:-1}).reverse();for(var h={},p=0;p<t.length;p++)"undefined"==typeof h[t[p].name]&&(h[t[p].name]=t[p].value);return h},i.fn.elSelector=function(e){var t="";return void 0!==e.attr("id")&&(t+="#"+e.attr("id")),void 0!==e.attr("class")&&(t+="."+e.attr("class").replace(/\s+/,".")),""===t&&(t=e.prop("tagName").toLowerCase()),t},window.socssInspector=i}(jQuery,_,socssOptions),jQuery(function(e){var t=window.socssInspector,s=new t.view.inspector({el:e("#socss-inspector-interface").get(0)});s.activate(),window.socssInspector.mainInspector=s});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/jquery.sizes.min.js
CHANGED
@@ -1,8 +1 @@
|
|
1 |
-
|
2 |
-
(function($){'use strict';var num=function(value){return parseInt(value,10)||0;};$.each(['min','max'],function(i,name){$.fn[name+'Size']=function(value){var width,height;if(value){if(value.width!==undefined){this.css(name+'-width',value.width);}
|
3 |
-
if(value.height!==undefined){this.css(name+'-height',value.height);}}else{width=this.css(name+'-width');height=this.css(name+'-height');return{'width':(name==='max'&&(width===undefined||width==='none'||num(width)===-1)&&Number.MAX_VALUE)||num(width),'height':(name==='max'&&(height===undefined||height==='none'||num(height)===-1)&&Number.MAX_VALUE)||num(height)};}
|
4 |
-
return this;};});$.fn.isVisible=function(){return this.is(':visible');};$.each(['border','margin','padding'],function(i,name){$.fn[name]=function(value){if(value){if(value.top!==undefined){this.css(name+'-top'+(name==='border'?'-width':''),value.top);}
|
5 |
-
if(value.bottom!==undefined){this.css(name+'-bottom'+(name==='border'?'-width':''),value.bottom);}
|
6 |
-
if(value.left!==undefined){this.css(name+'-left'+(name==='border'?'-width':''),value.left);}
|
7 |
-
if(value.right!==undefined){this.css(name+'-right'+(name==='border'?'-width':''),value.right);}}else{return{top:num(this.css(name+'-top'+(name==='border'?'-width':''))),bottom:num(this.css(name+'-bottom'+(name==='border'?'-width':''))),left:num(this.css(name+'-left'+(name==='border'?'-width':''))),right:num(this.css(name+'-right'+(name==='border'?'-width':'')))};}
|
8 |
-
return this;};});}(jQuery));
|
1 |
+
!function(t){"use strict";var i=function(t){return parseInt(t,10)||0};t.each(["min","max"],function(s,h){t.fn[h+"Size"]=function(t){var s,o;return t?(void 0!==t.width&&this.css(h+"-width",t.width),void 0!==t.height&&this.css(h+"-height",t.height),this):(s=this.css(h+"-width"),o=this.css(h+"-height"),{width:"max"===h&&(void 0===s||"none"===s||-1===i(s))&&Number.MAX_VALUE||i(s),height:"max"===h&&(void 0===o||"none"===o||-1===i(o))&&Number.MAX_VALUE||i(o)})}}),t.fn.isVisible=function(){return this.is(":visible")},t.each(["border","margin","padding"],function(s,h){t.fn[h]=function(t){return t?(void 0!==t.top&&this.css(h+"-top"+("border"===h?"-width":""),t.top),void 0!==t.bottom&&this.css(h+"-bottom"+("border"===h?"-width":""),t.bottom),void 0!==t.left&&this.css(h+"-left"+("border"===h?"-width":""),t.left),void 0!==t.right&&this.css(h+"-right"+("border"===h?"-width":""),t.right),this):{top:i(this.css(h+"-top"+("border"===h?"-width":""))),bottom:i(this.css(h+"-bottom"+("border"===h?"-width":""))),left:i(this.css(h+"-left"+("border"===h?"-width":""))),right:i(this.css(h+"-right"+("border"===h?"-width":"")))}}})}(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/specificity.min.js
CHANGED
@@ -1,3 +1 @@
|
|
1 |
-
|
2 |
-
var SPECIFICITY=(function(){var calculate,calculateSingle;calculate=function(input){var selectors,selector,i,len,results=[];selectors=input.split(',');for(i=0,len=selectors.length;i<len;i+=1){selector=selectors[i];if(selector.length>0){results.push(calculateSingle(selector));}}
|
3 |
-
return results;};calculateSingle=function(input){var selector=input,findMatch,typeCount={'a':0,'b':0,'c':0},parts=[],attributeRegex=/(\[[^\]]+\])/g,idRegex=/(#[^\s\+>~\.\[:]+)/g,classRegex=/(\.[^\s\+>~\.\[:]+)/g,pseudoElementRegex=/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi,pseudoClassWithBracketsRegex=/(:[\w-]+\([^\)]*\))/gi,pseudoClassRegex=/(:[^\s\+>~\.\[:]+)/g,elementRegex=/([^\s\+>~\.\[:]+)/g;findMatch=function(regex,type){var matches,i,len,match,index,length;if(regex.test(selector)){matches=selector.match(regex);for(i=0,len=matches.length;i<len;i+=1){typeCount[type]+=1;match=matches[i];index=selector.indexOf(match);length=match.length;parts.push({selector:match,type:type,index:index,length:length});selector=selector.replace(match,Array(length+1).join(' '));}}};(function(){var regex=/:not\(([^\)]*)\)/g;if(regex.test(selector)){selector=selector.replace(regex,' $1 ');}}());(function(){var regex=/{[^]*/gm,matches,i,len,match;if(regex.test(selector)){matches=selector.match(regex);for(i=0,len=matches.length;i<len;i+=1){match=matches[i];selector=selector.replace(match,Array(match.length+1).join(' '));}}}());findMatch(attributeRegex,'b');findMatch(idRegex,'a');findMatch(classRegex,'b');findMatch(pseudoElementRegex,'c');findMatch(pseudoClassWithBracketsRegex,'b');findMatch(pseudoClassRegex,'b');selector=selector.replace(/[\*\s\+>~]/g,' ');selector=selector.replace(/[#\.]/g,' ');findMatch(elementRegex,'c');parts.sort(function(a,b){return a.index-b.index;});return{selector:input,specificity:'0,'+typeCount.a.toString()+','+typeCount.b.toString()+','+typeCount.c.toString(),parts:parts};};return{calculate:calculate};}());
|
1 |
+
var SPECIFICITY=function(){var t,e;return t=function(t){var r,n,i,c,a=[];for(r=t.split(","),i=0,c=r.length;c>i;i+=1)n=r[i],n.length>0&&a.push(e(n));return a},e=function(t){var e,r=t,n={a:0,b:0,c:0},i=[],c=/(\[[^\]]+\])/g,a=/(#[^\s\+>~\.\[:]+)/g,g=/(\.[^\s\+>~\.\[:]+)/g,o=/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi,l=/(:[\w-]+\([^\)]*\))/gi,s=/(:[^\s\+>~\.\[:]+)/g,f=/([^\s\+>~\.\[:]+)/g;return e=function(t,e){var c,a,g,o,l,s;if(t.test(r))for(c=r.match(t),a=0,g=c.length;g>a;a+=1)n[e]+=1,o=c[a],l=r.indexOf(o),s=o.length,i.push({selector:o,type:e,index:l,length:s}),r=r.replace(o,Array(s+1).join(" "))},function(){var t=/:not\(([^\)]*)\)/g;t.test(r)&&(r=r.replace(t," $1 "))}(),function(){var t,e,n,i,c=/{[^]*/gm;if(c.test(r))for(t=r.match(c),e=0,n=t.length;n>e;e+=1)i=t[e],r=r.replace(i,Array(i.length+1).join(" "))}(),e(c,"b"),e(a,"a"),e(g,"b"),e(o,"c"),e(l,"b"),e(s,"b"),r=r.replace(/[\*\s\+>~]/g," "),r=r.replace(/[#\.]/g," "),e(f,"c"),i.sort(function(t,e){return t.index-e.index}),{selector:t,specificity:"0,"+n.a.toString()+","+n.b.toString()+","+n.c.toString(),parts:i}},{calculate:t}}();
|
|
|
|
lib/codemirror/addon/fold/brace-fold.min.js
CHANGED
@@ -1,15 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.registerHelper("fold","brace",function(cm,start){var line=start.line,lineText=cm.getLine(line);var startCh,tokenType;function findOpening(openCh){for(var at=start.ch,pass=0;;){var found=at<=0?-1:lineText.lastIndexOf(openCh,at-1);if(found==-1){if(pass==1)break;pass=1;at=lineText.length;continue;}
|
6 |
-
if(pass==1&&found<start.ch)break;tokenType=cm.getTokenTypeAt(CodeMirror.Pos(line,found+1));if(!/^(comment|string)/.test(tokenType))return found+1;at=found-1;}}
|
7 |
-
var startToken="{",endToken="}",startCh=findOpening("{");if(startCh==null){startToken="[",endToken="]";startCh=findOpening("[");}
|
8 |
-
if(startCh==null)return;var count=1,lastLine=cm.lastLine(),end,endCh;outer:for(var i=line;i<=lastLine;++i){var text=cm.getLine(i),pos=i==line?startCh:0;for(;;){var nextOpen=text.indexOf(startToken,pos),nextClose=text.indexOf(endToken,pos);if(nextOpen<0)nextOpen=text.length;if(nextClose<0)nextClose=text.length;pos=Math.min(nextOpen,nextClose);if(pos==text.length)break;if(cm.getTokenTypeAt(CodeMirror.Pos(i,pos+1))==tokenType){if(pos==nextOpen)++count;else if(!--count){end=i;endCh=pos;break outer;}}
|
9 |
-
++pos;}}
|
10 |
-
if(end==null||line==end&&endCh==startCh)return;return{from:CodeMirror.Pos(line,startCh),to:CodeMirror.Pos(end,endCh)};});CodeMirror.registerHelper("fold","import",function(cm,start){function hasImport(line){if(line<cm.firstLine()||line>cm.lastLine())return null;var start=cm.getTokenAt(CodeMirror.Pos(line,1));if(!/\S/.test(start.string))start=cm.getTokenAt(CodeMirror.Pos(line,start.end+1));if(start.type!="keyword"||start.string!="import")return null;for(var i=line,e=Math.min(cm.lastLine(),line+10);i<=e;++i){var text=cm.getLine(i),semi=text.indexOf(";");if(semi!=-1)return{startCh:start.end,end:CodeMirror.Pos(i,semi)};}}
|
11 |
-
var start=start.line,has=hasImport(start),prev;if(!has||hasImport(start-1)||((prev=hasImport(start-2))&&prev.end.line==start-1))
|
12 |
-
return null;for(var end=has.end;;){var next=hasImport(end.line+1);if(next==null)break;end=next.end;}
|
13 |
-
return{from:cm.clipPos(CodeMirror.Pos(start,has.startCh+1)),to:end};});CodeMirror.registerHelper("fold","include",function(cm,start){function hasInclude(line){if(line<cm.firstLine()||line>cm.lastLine())return null;var start=cm.getTokenAt(CodeMirror.Pos(line,1));if(!/\S/.test(start.string))start=cm.getTokenAt(CodeMirror.Pos(line,start.end+1));if(start.type=="meta"&&start.string.slice(0,8)=="#include")return start.start+8;}
|
14 |
-
var start=start.line,has=hasInclude(start);if(has==null||hasInclude(start-1)!=null)return null;for(var end=start;;){var next=hasInclude(end+1);if(next==null)break;++end;}
|
15 |
-
return{from:CodeMirror.Pos(start,has+1),to:cm.clipPos(CodeMirror.Pos(end))};});});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("fold","brace",function(r,n){function t(t){for(var i=n.ch,s=0;;){var u=0>=i?-1:f.lastIndexOf(t,i-1);if(-1!=u){if(1==s&&u<n.ch)break;if(o=r.getTokenTypeAt(e.Pos(l,u+1)),!/^(comment|string)/.test(o))return u+1;i=u-1}else{if(1==s)break;s=1,i=f.length}}}var i,o,l=n.line,f=r.getLine(l),s="{",u="}",i=t("{");if(null==i&&(s="[",u="]",i=t("[")),null!=i){var a,d,c=1,g=r.lastLine();e:for(var v=l;g>=v;++v)for(var p=r.getLine(v),m=v==l?i:0;;){var P=p.indexOf(s,m),k=p.indexOf(u,m);if(0>P&&(P=p.length),0>k&&(k=p.length),m=Math.min(P,k),m==p.length)break;if(r.getTokenTypeAt(e.Pos(v,m+1))==o)if(m==P)++c;else if(!--c){a=v,d=m;break e}++m}if(null!=a&&(l!=a||d!=i))return{from:e.Pos(l,i),to:e.Pos(a,d)}}}),e.registerHelper("fold","import",function(r,n){function t(n){if(n<r.firstLine()||n>r.lastLine())return null;var t=r.getTokenAt(e.Pos(n,1));if(/\S/.test(t.string)||(t=r.getTokenAt(e.Pos(n,t.end+1))),"keyword"!=t.type||"import"!=t.string)return null;for(var i=n,o=Math.min(r.lastLine(),n+10);o>=i;++i){var l=r.getLine(i),f=l.indexOf(";");if(-1!=f)return{startCh:t.end,end:e.Pos(i,f)}}}var i,n=n.line,o=t(n);if(!o||t(n-1)||(i=t(n-2))&&i.end.line==n-1)return null;for(var l=o.end;;){var f=t(l.line+1);if(null==f)break;l=f.end}return{from:r.clipPos(e.Pos(n,o.startCh+1)),to:l}}),e.registerHelper("fold","include",function(r,n){function t(n){if(n<r.firstLine()||n>r.lastLine())return null;var t=r.getTokenAt(e.Pos(n,1));return/\S/.test(t.string)||(t=r.getTokenAt(e.Pos(n,t.end+1))),"meta"==t.type&&"#include"==t.string.slice(0,8)?t.start+8:void 0}var n=n.line,i=t(n);if(null==i||null!=t(n-1))return null;for(var o=n;;){var l=t(o+1);if(null==l)break;++o}return{from:e.Pos(n,i+1),to:r.clipPos(e.Pos(o))}})});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/fold/comment-fold.min.js
CHANGED
@@ -1,10 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.registerGlobalHelper("fold","comment",function(mode){return mode.blockCommentStart&&mode.blockCommentEnd;},function(cm,start){var mode=cm.getModeAt(start),startToken=mode.blockCommentStart,endToken=mode.blockCommentEnd;if(!startToken||!endToken)return;var line=start.line,lineText=cm.getLine(line);var startCh;for(var at=start.ch,pass=0;;){var found=at<=0?-1:lineText.lastIndexOf(startToken,at-1);if(found==-1){if(pass==1)return;pass=1;at=lineText.length;continue;}
|
6 |
-
if(pass==1&&found<start.ch)return;if(/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line,found+1)))){startCh=found+startToken.length;break;}
|
7 |
-
at=found-1;}
|
8 |
-
var depth=1,lastLine=cm.lastLine(),end,endCh;outer:for(var i=line;i<=lastLine;++i){var text=cm.getLine(i),pos=i==line?startCh:0;for(;;){var nextOpen=text.indexOf(startToken,pos),nextClose=text.indexOf(endToken,pos);if(nextOpen<0)nextOpen=text.length;if(nextClose<0)nextClose=text.length;pos=Math.min(nextOpen,nextClose);if(pos==text.length)break;if(pos==nextOpen)++depth;else if(!--depth){end=i;endCh=pos;break outer;}
|
9 |
-
++pos;}}
|
10 |
-
if(end==null||line==end&&endCh==startCh)return;return{from:CodeMirror.Pos(line,startCh),to:CodeMirror.Pos(end,endCh)};});});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerGlobalHelper("fold","comment",function(e){return e.blockCommentStart&&e.blockCommentEnd},function(t,n){var o=t.getModeAt(n),r=o.blockCommentStart,i=o.blockCommentEnd;if(r&&i){for(var f,l=n.line,c=t.getLine(l),m=n.ch,a=0;;){var d=0>=m?-1:c.lastIndexOf(r,m-1);if(-1!=d){if(1==a&&d<n.ch)return;if(/comment/.test(t.getTokenTypeAt(e.Pos(l,d+1)))){f=d+r.length;break}m=d-1}else{if(1==a)return;a=1,m=c.length}}var u,b,s=1,g=t.lastLine();e:for(var h=l;g>=h;++h)for(var k=t.getLine(h),v=h==l?f:0;;){var p=k.indexOf(r,v),C=k.indexOf(i,v);if(0>p&&(p=k.length),0>C&&(C=k.length),v=Math.min(p,C),v==k.length)break;if(v==p)++s;else if(!--s){u=h,b=v;break e}++v}if(null!=u&&(l!=u||b!=f))return{from:e.Pos(l,f),to:e.Pos(u,b)}}})});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/fold/foldcode.min.js
CHANGED
@@ -1,18 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";function doFold(cm,pos,options,force){if(options&&options.call){var finder=options;options=null;}else{var finder=getOption(cm,options,"rangeFinder");}
|
6 |
-
if(typeof pos=="number")pos=CodeMirror.Pos(pos,0);var minSize=getOption(cm,options,"minFoldSize");function getRange(allowFolded){var range=finder(cm,pos);if(!range||range.to.line-range.from.line<minSize)return null;var marks=cm.findMarksAt(range.from);for(var i=0;i<marks.length;++i){if(marks[i].__isFold&&force!=="fold"){if(!allowFolded)return null;range.cleared=true;marks[i].clear();}}
|
7 |
-
return range;}
|
8 |
-
var range=getRange(true);if(getOption(cm,options,"scanUp"))while(!range&&pos.line>cm.firstLine()){pos=CodeMirror.Pos(pos.line-1,0);range=getRange(false);}
|
9 |
-
if(!range||range.cleared||force==="unfold")return;var myWidget=makeWidget(cm,options);CodeMirror.on(myWidget,"mousedown",function(e){myRange.clear();CodeMirror.e_preventDefault(e);});var myRange=cm.markText(range.from,range.to,{replacedWith:myWidget,clearOnEnter:true,__isFold:true});myRange.on("clear",function(from,to){CodeMirror.signal(cm,"unfold",cm,from,to);});CodeMirror.signal(cm,"fold",cm,range.from,range.to);}
|
10 |
-
function makeWidget(cm,options){var widget=getOption(cm,options,"widget");if(typeof widget=="string"){var text=document.createTextNode(widget);widget=document.createElement("span");widget.appendChild(text);widget.className="CodeMirror-foldmarker";}
|
11 |
-
return widget;}
|
12 |
-
CodeMirror.newFoldFunction=function(rangeFinder,widget){return function(cm,pos){doFold(cm,pos,{rangeFinder:rangeFinder,widget:widget});};};CodeMirror.defineExtension("foldCode",function(pos,options,force){doFold(this,pos,options,force);});CodeMirror.defineExtension("isFolded",function(pos){var marks=this.findMarksAt(pos);for(var i=0;i<marks.length;++i)
|
13 |
-
if(marks[i].__isFold)return true;});CodeMirror.commands.toggleFold=function(cm){cm.foldCode(cm.getCursor());};CodeMirror.commands.fold=function(cm){cm.foldCode(cm.getCursor(),null,"fold");};CodeMirror.commands.unfold=function(cm){cm.foldCode(cm.getCursor(),null,"unfold");};CodeMirror.commands.foldAll=function(cm){cm.operation(function(){for(var i=cm.firstLine(),e=cm.lastLine();i<=e;i++)
|
14 |
-
cm.foldCode(CodeMirror.Pos(i,0),null,"fold");});};CodeMirror.commands.unfoldAll=function(cm){cm.operation(function(){for(var i=cm.firstLine(),e=cm.lastLine();i<=e;i++)
|
15 |
-
cm.foldCode(CodeMirror.Pos(i,0),null,"unfold");});};CodeMirror.registerHelper("fold","combine",function(){var funcs=Array.prototype.slice.call(arguments,0);return function(cm,start){for(var i=0;i<funcs.length;++i){var found=funcs[i](cm,start);if(found)return found;}};});CodeMirror.registerHelper("fold","auto",function(cm,start){var helpers=cm.getHelpers(start,"fold");for(var i=0;i<helpers.length;i++){var cur=helpers[i](cm,start);if(cur)return cur;}});var defaultOptions={rangeFinder:CodeMirror.fold.auto,widget:"\u2194",minFoldSize:0,scanUp:false};CodeMirror.defineOption("foldOptions",null);function getOption(cm,options,name){if(options&&options[name]!==undefined)
|
16 |
-
return options[name];var editorOptions=cm.options.foldOptions;if(editorOptions&&editorOptions[name]!==undefined)
|
17 |
-
return editorOptions[name];return defaultOptions[name];}
|
18 |
-
CodeMirror.defineExtension("foldOption",function(options,name){return getOption(this,options,name);});});
|
1 |
+
!function(n){"object"==typeof exports&&"object"==typeof module?n(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){"use strict";function o(o,i,t,f){function l(n){var e=d(o,i);if(!e||e.to.line-e.from.line<u)return null;for(var r=o.findMarksAt(e.from),t=0;t<r.length;++t)if(r[t].__isFold&&"fold"!==f){if(!n)return null;e.cleared=!0,r[t].clear()}return e}if(t&&t.call){var d=t;t=null}else var d=r(o,t,"rangeFinder");"number"==typeof i&&(i=n.Pos(i,0));var u=r(o,t,"minFoldSize"),a=l(!0);if(r(o,t,"scanUp"))for(;!a&&i.line>o.firstLine();)i=n.Pos(i.line-1,0),a=l(!1);if(a&&!a.cleared&&"unfold"!==f){var c=e(o,t);n.on(c,"mousedown",function(o){s.clear(),n.e_preventDefault(o)});var s=o.markText(a.from,a.to,{replacedWith:c,clearOnEnter:!0,__isFold:!0});s.on("clear",function(e,r){n.signal(o,"unfold",o,e,r)}),n.signal(o,"fold",o,a.from,a.to)}}function e(n,o){var e=r(n,o,"widget");if("string"==typeof e){var i=document.createTextNode(e);e=document.createElement("span"),e.appendChild(i),e.className="CodeMirror-foldmarker"}return e}function r(n,o,e){if(o&&void 0!==o[e])return o[e];var r=n.options.foldOptions;return r&&void 0!==r[e]?r[e]:i[e]}n.newFoldFunction=function(n,e){return function(r,i){o(r,i,{rangeFinder:n,widget:e})}},n.defineExtension("foldCode",function(n,e,r){o(this,n,e,r)}),n.defineExtension("isFolded",function(n){for(var o=this.findMarksAt(n),e=0;e<o.length;++e)if(o[e].__isFold)return!0}),n.commands.toggleFold=function(n){n.foldCode(n.getCursor())},n.commands.fold=function(n){n.foldCode(n.getCursor(),null,"fold")},n.commands.unfold=function(n){n.foldCode(n.getCursor(),null,"unfold")},n.commands.foldAll=function(o){o.operation(function(){for(var e=o.firstLine(),r=o.lastLine();r>=e;e++)o.foldCode(n.Pos(e,0),null,"fold")})},n.commands.unfoldAll=function(o){o.operation(function(){for(var e=o.firstLine(),r=o.lastLine();r>=e;e++)o.foldCode(n.Pos(e,0),null,"unfold")})},n.registerHelper("fold","combine",function(){var n=Array.prototype.slice.call(arguments,0);return function(o,e){for(var r=0;r<n.length;++r){var i=n[r](o,e);if(i)return i}}}),n.registerHelper("fold","auto",function(n,o){for(var e=n.getHelpers(o,"fold"),r=0;r<e.length;r++){var i=e[r](n,o);if(i)return i}});var i={rangeFinder:n.fold.auto,widget:"↔",minFoldSize:0,scanUp:!1};n.defineOption("foldOptions",null),n.defineExtension("foldOption",function(n,o){return r(this,n,o)})});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/fold/foldgutter.min.js
CHANGED
@@ -1,20 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"),require("./foldcode"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror","./foldcode"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.defineOption("foldGutter",false,function(cm,val,old){if(old&&old!=CodeMirror.Init){cm.clearGutter(cm.state.foldGutter.options.gutter);cm.state.foldGutter=null;cm.off("gutterClick",onGutterClick);cm.off("change",onChange);cm.off("viewportChange",onViewportChange);cm.off("fold",onFold);cm.off("unfold",onFold);cm.off("swapDoc",updateInViewport);}
|
6 |
-
if(val){cm.state.foldGutter=new State(parseOptions(val));updateInViewport(cm);cm.on("gutterClick",onGutterClick);cm.on("change",onChange);cm.on("viewportChange",onViewportChange);cm.on("fold",onFold);cm.on("unfold",onFold);cm.on("swapDoc",updateInViewport);}});var Pos=CodeMirror.Pos;function State(options){this.options=options;this.from=this.to=0;}
|
7 |
-
function parseOptions(opts){if(opts===true)opts={};if(opts.gutter==null)opts.gutter="CodeMirror-foldgutter";if(opts.indicatorOpen==null)opts.indicatorOpen="CodeMirror-foldgutter-open";if(opts.indicatorFolded==null)opts.indicatorFolded="CodeMirror-foldgutter-folded";return opts;}
|
8 |
-
function isFolded(cm,line){var marks=cm.findMarksAt(Pos(line));for(var i=0;i<marks.length;++i)
|
9 |
-
if(marks[i].__isFold&&marks[i].find().from.line==line)return marks[i];}
|
10 |
-
function marker(spec){if(typeof spec=="string"){var elt=document.createElement("div");elt.className=spec+" CodeMirror-guttermarker-subtle";return elt;}else{return spec.cloneNode(true);}}
|
11 |
-
function updateFoldInfo(cm,from,to){var opts=cm.state.foldGutter.options,cur=from;var minSize=cm.foldOption(opts,"minFoldSize");var func=cm.foldOption(opts,"rangeFinder");cm.eachLine(from,to,function(line){var mark=null;if(isFolded(cm,cur)){mark=marker(opts.indicatorFolded);}else{var pos=Pos(cur,0);var range=func&&func(cm,pos);if(range&&range.to.line-range.from.line>=minSize)
|
12 |
-
mark=marker(opts.indicatorOpen);}
|
13 |
-
cm.setGutterMarker(line,opts.gutter,mark);++cur;});}
|
14 |
-
function updateInViewport(cm){var vp=cm.getViewport(),state=cm.state.foldGutter;if(!state)return;cm.operation(function(){updateFoldInfo(cm,vp.from,vp.to);});state.from=vp.from;state.to=vp.to;}
|
15 |
-
function onGutterClick(cm,line,gutter){var state=cm.state.foldGutter;if(!state)return;var opts=state.options;if(gutter!=opts.gutter)return;var folded=isFolded(cm,line);if(folded)folded.clear();else cm.foldCode(Pos(line,0),opts.rangeFinder);}
|
16 |
-
function onChange(cm){var state=cm.state.foldGutter;if(!state)return;var opts=state.options;state.from=state.to=0;clearTimeout(state.changeUpdate);state.changeUpdate=setTimeout(function(){updateInViewport(cm);},opts.foldOnChangeTimeSpan||600);}
|
17 |
-
function onViewportChange(cm){var state=cm.state.foldGutter;if(!state)return;var opts=state.options;clearTimeout(state.changeUpdate);state.changeUpdate=setTimeout(function(){var vp=cm.getViewport();if(state.from==state.to||vp.from-state.to>20||state.from-vp.to>20){updateInViewport(cm);}else{cm.operation(function(){if(vp.from<state.from){updateFoldInfo(cm,vp.from,state.from);state.from=vp.from;}
|
18 |
-
if(vp.to>state.to){updateFoldInfo(cm,state.to,vp.to);state.to=vp.to;}});}},opts.updateViewportTimeSpan||400);}
|
19 |
-
function onFold(cm,from){var state=cm.state.foldGutter;if(!state)return;var line=from.line;if(line>=state.from&&line<state.to)
|
20 |
-
updateFoldInfo(cm,line,line+1);}});
|
1 |
+
!function(o){"object"==typeof exports&&"object"==typeof module?o(require("../../lib/codemirror"),require("./foldcode")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./foldcode"],o):o(CodeMirror)}(function(o){"use strict";function t(o){this.options=o,this.from=this.to=0}function e(o){return o===!0&&(o={}),null==o.gutter&&(o.gutter="CodeMirror-foldgutter"),null==o.indicatorOpen&&(o.indicatorOpen="CodeMirror-foldgutter-open"),null==o.indicatorFolded&&(o.indicatorFolded="CodeMirror-foldgutter-folded"),o}function r(o,t){for(var e=o.findMarksAt(c(t)),r=0;r<e.length;++r)if(e[r].__isFold&&e[r].find().from.line==t)return e[r]}function n(o){if("string"==typeof o){var t=document.createElement("div");return t.className=o+" CodeMirror-guttermarker-subtle",t}return o.cloneNode(!0)}function i(o,t,e){var i=o.state.foldGutter.options,f=t,d=o.foldOption(i,"minFoldSize"),a=o.foldOption(i,"rangeFinder");o.eachLine(t,e,function(t){var e=null;if(r(o,f))e=n(i.indicatorFolded);else{var u=c(f,0),l=a&&a(o,u);l&&l.to.line-l.from.line>=d&&(e=n(i.indicatorOpen))}o.setGutterMarker(t,i.gutter,e),++f})}function f(o){var t=o.getViewport(),e=o.state.foldGutter;e&&(o.operation(function(){i(o,t.from,t.to)}),e.from=t.from,e.to=t.to)}function d(o,t,e){var n=o.state.foldGutter;if(n){var i=n.options;if(e==i.gutter){var f=r(o,t);f?f.clear():o.foldCode(c(t,0),i.rangeFinder)}}}function a(o){var t=o.state.foldGutter;if(t){var e=t.options;t.from=t.to=0,clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout(function(){f(o)},e.foldOnChangeTimeSpan||600)}}function u(o){var t=o.state.foldGutter;if(t){var e=t.options;clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout(function(){var e=o.getViewport();t.from==t.to||e.from-t.to>20||t.from-e.to>20?f(o):o.operation(function(){e.from<t.from&&(i(o,e.from,t.from),t.from=e.from),e.to>t.to&&(i(o,t.to,e.to),t.to=e.to)})},e.updateViewportTimeSpan||400)}}function l(o,t){var e=o.state.foldGutter;if(e){var r=t.line;r>=e.from&&r<e.to&&i(o,r,r+1)}}o.defineOption("foldGutter",!1,function(r,n,i){i&&i!=o.Init&&(r.clearGutter(r.state.foldGutter.options.gutter),r.state.foldGutter=null,r.off("gutterClick",d),r.off("change",a),r.off("viewportChange",u),r.off("fold",l),r.off("unfold",l),r.off("swapDoc",f)),n&&(r.state.foldGutter=new t(e(n)),f(r),r.on("gutterClick",d),r.on("change",a),r.on("viewportChange",u),r.on("fold",l),r.on("unfold",l),r.on("swapDoc",f))});var c=o.Pos});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/fold/indent-fold.min.js
CHANGED
@@ -1,6 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.registerHelper("fold","indent",function(cm,start){var tabSize=cm.getOption("tabSize"),firstLine=cm.getLine(start.line);if(!/\S/.test(firstLine))return;var getIndent=function(line){return CodeMirror.countColumn(line,null,tabSize);};var myIndent=getIndent(firstLine);var lastLineInFold=null;for(var i=start.line+1,end=cm.lastLine();i<=end;++i){var curLine=cm.getLine(i);var curIndent=getIndent(curLine);if(curIndent>myIndent){lastLineInFold=i;}else if(!/\S/.test(curLine)){}else{break;}}
|
6 |
-
if(lastLineInFold)return{from:CodeMirror.Pos(start.line,firstLine.length),to:CodeMirror.Pos(lastLineInFold,cm.getLine(lastLineInFold).length)};});});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("fold","indent",function(t,n){var i=t.getOption("tabSize"),o=t.getLine(n.line);if(/\S/.test(o)){for(var r=function(t){return e.countColumn(t,null,i)},f=r(o),l=null,u=n.line+1,c=t.lastLine();c>=u;++u){var d=t.getLine(u),s=r(d);if(s>f)l=u;else if(/\S/.test(d))break}return l?{from:e.Pos(n.line,o.length),to:e.Pos(l,t.getLine(l).length)}:void 0}})});
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/fold/markdown-fold.min.js
CHANGED
@@ -1,8 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.registerHelper("fold","markdown",function(cm,start){var maxDepth=100;function isHeader(lineNo){var tokentype=cm.getTokenTypeAt(CodeMirror.Pos(lineNo,0));return tokentype&&/\bheader\b/.test(tokentype);}
|
6 |
-
function headerLevel(lineNo,line,nextLine){var match=line&&line.match(/^#+/);if(match&&isHeader(lineNo))return match[0].length;match=nextLine&&nextLine.match(/^[=\-]+\s*$/);if(match&&isHeader(lineNo+1))return nextLine[0]=="="?1:2;return maxDepth;}
|
7 |
-
var firstLine=cm.getLine(start.line),nextLine=cm.getLine(start.line+1);var level=headerLevel(start.line,firstLine,nextLine);if(level===maxDepth)return undefined;var lastLineNo=cm.lastLine();var end=start.line,nextNextLine=cm.getLine(end+2);while(end<lastLineNo){if(headerLevel(end+1,nextLine,nextNextLine)<=level)break;++end;nextLine=nextNextLine;nextNextLine=cm.getLine(end+2);}
|
8 |
-
return{from:CodeMirror.Pos(start.line,firstLine.length),to:CodeMirror.Pos(end,cm.getLine(end).length)};});});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("fold","markdown",function(n,t){function r(t){var r=n.getTokenTypeAt(e.Pos(t,0));return r&&/\bheader\b/.test(r)}function i(e,n,t){var i=n&&n.match(/^#+/);return i&&r(e)?i[0].length:(i=t&&t.match(/^[=\-]+\s*$/),i&&r(e+1)?"="==t[0]?1:2:o)}var o=100,f=n.getLine(t.line),l=n.getLine(t.line+1),c=i(t.line,f,l);if(c===o)return void 0;for(var u=n.lastLine(),d=t.line,a=n.getLine(d+2);u>d&&!(i(d+1,l,a)<=c);)++d,l=a,a=n.getLine(d+2);return{from:e.Pos(t.line,f.length),to:e.Pos(d,n.getLine(d).length)}})});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/fold/xml-fold.min.js
CHANGED
@@ -1,27 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";var Pos=CodeMirror.Pos;function cmp(a,b){return a.line-b.line||a.ch-b.ch;}
|
6 |
-
var nameStartChar="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";var nameChar=nameStartChar+"\-\:\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";var xmlTagStart=new RegExp("<(/?)(["+nameStartChar+"]["+nameChar+"]*)","g");function Iter(cm,line,ch,range){this.line=line;this.ch=ch;this.cm=cm;this.text=cm.getLine(line);this.min=range?range.from:cm.firstLine();this.max=range?range.to-1:cm.lastLine();}
|
7 |
-
function tagAt(iter,ch){var type=iter.cm.getTokenTypeAt(Pos(iter.line,ch));return type&&/\btag\b/.test(type);}
|
8 |
-
function nextLine(iter){if(iter.line>=iter.max)return;iter.ch=0;iter.text=iter.cm.getLine(++iter.line);return true;}
|
9 |
-
function prevLine(iter){if(iter.line<=iter.min)return;iter.text=iter.cm.getLine(--iter.line);iter.ch=iter.text.length;return true;}
|
10 |
-
function toTagEnd(iter){for(;;){var gt=iter.text.indexOf(">",iter.ch);if(gt==-1){if(nextLine(iter))continue;else return;}
|
11 |
-
if(!tagAt(iter,gt+1)){iter.ch=gt+1;continue;}
|
12 |
-
var lastSlash=iter.text.lastIndexOf("/",gt);var selfClose=lastSlash>-1&&!/\S/.test(iter.text.slice(lastSlash+1,gt));iter.ch=gt+1;return selfClose?"selfClose":"regular";}}
|
13 |
-
function toTagStart(iter){for(;;){var lt=iter.ch?iter.text.lastIndexOf("<",iter.ch-1):-1;if(lt==-1){if(prevLine(iter))continue;else return;}
|
14 |
-
if(!tagAt(iter,lt+1)){iter.ch=lt;continue;}
|
15 |
-
xmlTagStart.lastIndex=lt;iter.ch=lt;var match=xmlTagStart.exec(iter.text);if(match&&match.index==lt)return match;}}
|
16 |
-
function toNextTag(iter){for(;;){xmlTagStart.lastIndex=iter.ch;var found=xmlTagStart.exec(iter.text);if(!found){if(nextLine(iter))continue;else return;}
|
17 |
-
if(!tagAt(iter,found.index+1)){iter.ch=found.index+1;continue;}
|
18 |
-
iter.ch=found.index+found[0].length;return found;}}
|
19 |
-
function toPrevTag(iter){for(;;){var gt=iter.ch?iter.text.lastIndexOf(">",iter.ch-1):-1;if(gt==-1){if(prevLine(iter))continue;else return;}
|
20 |
-
if(!tagAt(iter,gt+1)){iter.ch=gt;continue;}
|
21 |
-
var lastSlash=iter.text.lastIndexOf("/",gt);var selfClose=lastSlash>-1&&!/\S/.test(iter.text.slice(lastSlash+1,gt));iter.ch=gt+1;return selfClose?"selfClose":"regular";}}
|
22 |
-
function findMatchingClose(iter,tag){var stack=[];for(;;){var next=toNextTag(iter),end,startLine=iter.line,startCh=iter.ch-(next?next[0].length:0);if(!next||!(end=toTagEnd(iter)))return;if(end=="selfClose")continue;if(next[1]){for(var i=stack.length-1;i>=0;--i)if(stack[i]==next[2]){stack.length=i;break;}
|
23 |
-
if(i<0&&(!tag||tag==next[2]))return{tag:next[2],from:Pos(startLine,startCh),to:Pos(iter.line,iter.ch)};}else{stack.push(next[2]);}}}
|
24 |
-
function findMatchingOpen(iter,tag){var stack=[];for(;;){var prev=toPrevTag(iter);if(!prev)return;if(prev=="selfClose"){toTagStart(iter);continue;}
|
25 |
-
var endLine=iter.line,endCh=iter.ch;var start=toTagStart(iter);if(!start)return;if(start[1]){stack.push(start[2]);}else{for(var i=stack.length-1;i>=0;--i)if(stack[i]==start[2]){stack.length=i;break;}
|
26 |
-
if(i<0&&(!tag||tag==start[2]))return{tag:start[2],from:Pos(iter.line,iter.ch),to:Pos(endLine,endCh)};}}}
|
27 |
-
CodeMirror.registerHelper("fold","xml",function(cm,start){var iter=new Iter(cm,start.line,0);for(;;){var openTag=toNextTag(iter),end;if(!openTag||iter.line!=start.line||!(end=toTagEnd(iter)))return;if(!openTag[1]&&end!="selfClose"){var start=Pos(iter.line,iter.ch);var close=findMatchingClose(iter,openTag[2]);return close&&{from:start,to:close.from};}}});CodeMirror.findMatchingTag=function(cm,pos,range){var iter=new Iter(cm,pos.line,pos.ch,range);if(iter.text.indexOf(">")==-1&&iter.text.indexOf("<")==-1)return;var end=toTagEnd(iter),to=end&&Pos(iter.line,iter.ch);var start=end&&toTagStart(iter);if(!end||!start||cmp(iter,pos)>0)return;var here={from:Pos(iter.line,iter.ch),to:to,tag:start[2]};if(end=="selfClose")return{open:here,close:null,at:"open"};if(start[1]){return{open:findMatchingOpen(iter,start[2]),close:here,at:"close"};}else{iter=new Iter(cm,to.line,to.ch,range);return{open:here,close:findMatchingClose(iter,start[2]),at:"open"};}};CodeMirror.findEnclosingTag=function(cm,pos,range){var iter=new Iter(cm,pos.line,pos.ch,range);for(;;){var open=findMatchingOpen(iter);if(!open)break;var forward=new Iter(cm,pos.line,pos.ch,range);var close=findMatchingClose(forward,open.tag);if(close)return{open:open,close:close};}};CodeMirror.scanForClosingTag=function(cm,pos,name,end){var iter=new Iter(cm,pos.line,pos.ch,end?{from:0,to:end}:null);return findMatchingClose(iter,name);};});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function n(e,n){return e.line-n.line||e.ch-n.ch}function t(e,n,t,i){this.line=n,this.ch=t,this.cm=e,this.text=e.getLine(n),this.min=i?i.from:e.firstLine(),this.max=i?i.to-1:e.lastLine()}function i(e,n){var t=e.cm.getTokenTypeAt(h(e.line,n));return t&&/\btag\b/.test(t)}function r(e){return e.line>=e.max?void 0:(e.ch=0,e.text=e.cm.getLine(++e.line),!0)}function f(e){return e.line<=e.min?void 0:(e.text=e.cm.getLine(--e.line),e.ch=e.text.length,!0)}function o(e){for(;;){var n=e.text.indexOf(">",e.ch);if(-1==n){if(r(e))continue;return}{if(i(e,n+1)){var t=e.text.lastIndexOf("/",n),f=t>-1&&!/\S/.test(e.text.slice(t+1,n));return e.ch=n+1,f?"selfClose":"regular"}e.ch=n+1}}}function u(e){for(;;){var n=e.ch?e.text.lastIndexOf("<",e.ch-1):-1;if(-1==n){if(f(e))continue;return}if(i(e,n+1)){g.lastIndex=n,e.ch=n;var t=g.exec(e.text);if(t&&t.index==n)return t}else e.ch=n}}function c(e){for(;;){g.lastIndex=e.ch;var n=g.exec(e.text);if(!n){if(r(e))continue;return}{if(i(e,n.index+1))return e.ch=n.index+n[0].length,n;e.ch=n.index+1}}}function l(e){for(;;){var n=e.ch?e.text.lastIndexOf(">",e.ch-1):-1;if(-1==n){if(f(e))continue;return}{if(i(e,n+1)){var t=e.text.lastIndexOf("/",n),r=t>-1&&!/\S/.test(e.text.slice(t+1,n));return e.ch=n+1,r?"selfClose":"regular"}e.ch=n}}}function a(e,n){for(var t=[];;){var i,r=c(e),f=e.line,u=e.ch-(r?r[0].length:0);if(!r||!(i=o(e)))return;if("selfClose"!=i)if(r[1]){for(var l=t.length-1;l>=0;--l)if(t[l]==r[2]){t.length=l;break}if(0>l&&(!n||n==r[2]))return{tag:r[2],from:h(f,u),to:h(e.line,e.ch)}}else t.push(r[2])}}function s(e,n){for(var t=[];;){var i=l(e);if(!i)return;if("selfClose"!=i){var r=e.line,f=e.ch,o=u(e);if(!o)return;if(o[1])t.push(o[2]);else{for(var c=t.length-1;c>=0;--c)if(t[c]==o[2]){t.length=c;break}if(0>c&&(!n||n==o[2]))return{tag:o[2],from:h(e.line,e.ch),to:h(r,f)}}}else u(e)}}var h=e.Pos,x="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",v=x+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",g=new RegExp("<(/?)(["+x+"]["+v+"]*)","g");e.registerHelper("fold","xml",function(e,n){for(var i=new t(e,n.line,0);;){var r,f=c(i);if(!f||i.line!=n.line||!(r=o(i)))return;if(!f[1]&&"selfClose"!=r){var n=h(i.line,i.ch),u=a(i,f[2]);return u&&{from:n,to:u.from}}}}),e.findMatchingTag=function(e,i,r){var f=new t(e,i.line,i.ch,r);if(-1!=f.text.indexOf(">")||-1!=f.text.indexOf("<")){var c=o(f),l=c&&h(f.line,f.ch),x=c&&u(f);if(c&&x&&!(n(f,i)>0)){var v={from:h(f.line,f.ch),to:l,tag:x[2]};return"selfClose"==c?{open:v,close:null,at:"open"}:x[1]?{open:s(f,x[2]),close:v,at:"close"}:(f=new t(e,l.line,l.ch,r),{open:v,close:a(f,x[2]),at:"open"})}}},e.findEnclosingTag=function(e,n,i){for(var r=new t(e,n.line,n.ch,i);;){var f=s(r);if(!f)break;var o=new t(e,n.line,n.ch,i),u=a(o,f.tag);if(u)return{open:f,close:u}}},e.scanForClosingTag=function(e,n,i,r){var f=new t(e,n.line,n.ch,r?{from:0,to:r}:null);return a(f,i)}});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/hint/anyword-hint.min.js
CHANGED
@@ -1,6 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";var WORD=/[\w$]+/,RANGE=500;CodeMirror.registerHelper("hint","anyword",function(editor,options){var word=options&&options.word||WORD;var range=options&&options.range||RANGE;var cur=editor.getCursor(),curLine=editor.getLine(cur.line);var end=cur.ch,start=end;while(start&&word.test(curLine.charAt(start-1)))--start;var curWord=start!=end&&curLine.slice(start,end);var list=[],seen={};var re=new RegExp(word.source,"g");for(var dir=-1;dir<=1;dir+=2){var line=cur.line,endLine=Math.min(Math.max(line+dir*range,editor.firstLine()),editor.lastLine())+dir;for(;line!=endLine;line+=dir){var text=editor.getLine(line),m;while(m=re.exec(text)){if(line==cur.line&&m[0]===curWord)continue;if((!curWord||m[0].lastIndexOf(curWord,0)==0)&&!Object.prototype.hasOwnProperty.call(seen,m[0])){seen[m[0]]=true;list.push(m[0]);}}}}
|
6 |
-
return{list:list,from:CodeMirror.Pos(cur.line,start),to:CodeMirror.Pos(cur.line,end)};});});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";var r=/[\w$]+/,o=500;e.registerHelper("hint","anyword",function(t,i){for(var n=i&&i.word||r,f=i&&i.range||o,a=t.getCursor(),c=t.getLine(a.line),s=a.ch,l=s;l&&n.test(c.charAt(l-1));)--l;for(var d=l!=s&&c.slice(l,s),u=[],p={},g=new RegExp(n.source,"g"),h=-1;1>=h;h+=2)for(var m=a.line,y=Math.min(Math.max(m+h*f,t.firstLine()),t.lastLine())+h;m!=y;m+=h)for(var b,v=t.getLine(m);b=g.exec(v);)(m!=a.line||b[0]!==d)&&(d&&0!=b[0].lastIndexOf(d,0)||Object.prototype.hasOwnProperty.call(p,b[0])||(p[b[0]]=!0,u.push(b[0])));return{list:u,from:e.Pos(a.line,l),to:e.Pos(a.line,s)}})});
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/hint/css-hint.min.js
CHANGED
@@ -1,11 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"),require("../../mode/css/css"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror","../../mode/css/css"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";var pseudoClasses={link:1,visited:1,active:1,hover:1,focus:1,"first-letter":1,"first-line":1,"first-child":1,before:1,after:1,lang:1};CodeMirror.registerHelper("hint","css",function(cm){var cur=cm.getCursor(),token=cm.getTokenAt(cur);var inner=CodeMirror.innerMode(cm.getMode(),token.state);if(inner.mode.name!="css")return;if(token.type=="keyword"&&"!important".indexOf(token.string)==0)
|
6 |
-
return{list:["!important"],from:CodeMirror.Pos(cur.line,token.start),to:CodeMirror.Pos(cur.line,token.end)};var start=token.start,end=cur.ch,word=token.string.slice(0,end-start);if(/[^\w$_-]/.test(word)){word="";start=end=cur.ch;}
|
7 |
-
var spec=CodeMirror.resolveMode("text/css");var result=[];function add(keywords){for(var name in keywords)
|
8 |
-
if(!word||name.lastIndexOf(word,0)==0)
|
9 |
-
result.push(name);}
|
10 |
-
var st=inner.state.state;if(st=="pseudo"||token.type=="variable-3"){add(pseudoClasses);}else if(st=="block"||st=="maybeprop"){add(spec.propertyKeywords);}else if(st=="prop"||st=="parens"||st=="at"||st=="params"){add(spec.valueKeywords);add(spec.colorKeywords);}else if(st=="media"||st=="media_parens"){add(spec.mediaTypes);add(spec.mediaFeatures);}
|
11 |
-
if(result.length)return{list:result,from:CodeMirror.Pos(cur.line,start),to:CodeMirror.Pos(cur.line,end)};});});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../../mode/css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../../mode/css/css"],e):e(CodeMirror)}(function(e){"use strict";var r={link:1,visited:1,active:1,hover:1,focus:1,"first-letter":1,"first-line":1,"first-child":1,before:1,after:1,lang:1};e.registerHelper("hint","css",function(t){function o(e){for(var r in e)c&&0!=r.lastIndexOf(c,0)||l.push(r)}var s=t.getCursor(),i=t.getTokenAt(s),n=e.innerMode(t.getMode(),i.state);if("css"==n.mode.name){if("keyword"==i.type&&0=="!important".indexOf(i.string))return{list:["!important"],from:e.Pos(s.line,i.start),to:e.Pos(s.line,i.end)};var a=i.start,d=s.ch,c=i.string.slice(0,d-a);/[^\w$_-]/.test(c)&&(c="",a=d=s.ch);var f=e.resolveMode("text/css"),l=[],p=n.state.state;return"pseudo"==p||"variable-3"==i.type?o(r):"block"==p||"maybeprop"==p?o(f.propertyKeywords):"prop"==p||"parens"==p||"at"==p||"params"==p?(o(f.valueKeywords),o(f.colorKeywords)):("media"==p||"media_parens"==p)&&(o(f.mediaTypes),o(f.mediaFeatures)),l.length?{list:l,from:e.Pos(s.line,a),to:e.Pos(s.line,d)}:void 0}})});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/hint/html-hint.min.js
CHANGED
@@ -1,9 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"),require("./xml-hint"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror","./xml-hint"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";var langs="ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" ");var targets=["_blank","_self","_top","_parent"];var charsets=["ascii","utf-8","utf-16","latin1","latin1"];var methods=["get","post","put","delete"];var encs=["application/x-www-form-urlencoded","multipart/form-data","text/plain"];var media=["all","screen","print","embossed","braille","handheld","print","projection","screen","tty","tv","speech","3d-glasses","resolution [>][<][=] [X]","device-aspect-ratio: X/Y","orientation:portrait","orientation:landscape","device-height: [X]","device-width: [X]"];var s={attrs:{}};var data={a:{attrs:{href:null,ping:null,type:null,media:media,target:targets,hreflang:langs}},abbr:s,acronym:s,address:s,applet:s,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:media,hreflang:langs,type:null,shape:["default","rect","circle","poly"]}},article:s,aside:s,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["","autoplay"],loop:["","loop"],controls:["","controls"]}},b:s,base:{attrs:{href:null,target:targets}},basefont:s,bdi:s,bdo:s,big:s,blockquote:{attrs:{cite:null}},body:s,br:s,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["","autofocus"],disabled:["","autofocus"],formenctype:encs,formmethod:methods,formnovalidate:["","novalidate"],formtarget:targets,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:s,center:s,cite:s,code:s,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["","disabled"],checked:["","checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["","disabled"],multiple:["","multiple"]}},datalist:{attrs:{data:null}},dd:s,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["","open"]}},dfn:s,dir:s,div:s,dl:s,dt:s,em:s,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["","disabled"],form:null,name:null}},figcaption:s,figure:s,font:s,footer:s,form:{attrs:{action:null,name:null,"accept-charset":charsets,autocomplete:["on","off"],enctype:encs,method:methods,novalidate:["","novalidate"],target:targets}},frame:s,frameset:s,h1:s,h2:s,h3:s,h4:s,h5:s,h6:s,head:{attrs:{},children:["title","base","link","style","meta","script","noscript","command"]},header:s,hgroup:s,hr:s,html:{attrs:{manifest:null},children:["head","body"]},i:s,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["","seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["","autofocus"],checked:["","checked"],disabled:["","disabled"],formenctype:encs,formmethod:methods,formnovalidate:["","novalidate"],formtarget:targets,multiple:["","multiple"],readonly:["","readonly"],required:["","required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:s,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["","autofocus"],disabled:["","disabled"],keytype:["RSA"]}},label:{attrs:{"for":null,form:null}},legend:s,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:langs,media:media,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:s,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:charsets,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:s,noframes:s,noscript:s,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["","typemustmatch"]}},ol:{attrs:{reversed:["","reversed"],start:null,type:["1","a","A","i","I"]}},optgroup:{attrs:{disabled:["","disabled"],label:null}},option:{attrs:{disabled:["","disabled"],label:null,selected:["","selected"],value:null}},output:{attrs:{"for":null,form:null,name:null}},p:s,param:{attrs:{name:null,value:null}},pre:s,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:s,rt:s,ruby:s,s:s,samp:s,script:{attrs:{type:["text/javascript"],src:null,async:["","async"],defer:["","defer"],charset:charsets}},section:s,select:{attrs:{form:null,name:null,size:null,autofocus:["","autofocus"],disabled:["","disabled"],multiple:["","multiple"]}},small:s,source:{attrs:{src:null,type:null,media:null}},span:s,strike:s,strong:s,style:{attrs:{type:["text/css"],media:media,scoped:null}},sub:s,summary:s,sup:s,table:s,tbody:s,td:{attrs:{colspan:null,rowspan:null,headers:null}},textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["","autofocus"],disabled:["","disabled"],readonly:["","readonly"],required:["","required"],wrap:["soft","hard"]}},tfoot:s,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:s,time:{attrs:{datetime:null}},title:s,tr:s,track:{attrs:{src:null,label:null,"default":null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:langs}},tt:s,u:s,ul:s,"var":s,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["","autoplay"],mediagroup:["movie"],muted:["","muted"],controls:["","controls"]}},wbr:s};var globalAttrs={accesskey:["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"],"class":null,contenteditable:["true","false"],contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["en","es"],spellcheck:["true","false"],style:null,tabindex:["1","2","3","4","5","6","7","8","9"],title:null,translate:["yes","no"],onclick:null,rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"]};function populate(obj){for(var attr in globalAttrs)if(globalAttrs.hasOwnProperty(attr))
|
6 |
-
obj.attrs[attr]=globalAttrs[attr];}
|
7 |
-
populate(s);for(var tag in data)if(data.hasOwnProperty(tag)&&data[tag]!=s)
|
8 |
-
populate(data[tag]);CodeMirror.htmlSchema=data;function htmlHint(cm,options){var local={schemaInfo:data};if(options)for(var opt in options)local[opt]=options[opt];return CodeMirror.hint.xml(cm,local);}
|
9 |
-
CodeMirror.registerHelper("hint","html",htmlHint);});
|
1 |
+
!function(l){"object"==typeof exports&&"object"==typeof module?l(require("../../lib/codemirror"),require("./xml-hint")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./xml-hint"],l):l(CodeMirror)}(function(l){"use strict";function t(l){for(var t in c)c.hasOwnProperty(t)&&(l.attrs[t]=c[t])}function e(t,e){var a={schemaInfo:d};if(e)for(var n in e)a[n]=e[n];return l.hint.xml(t,a)}var a="ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" "),n=["_blank","_self","_top","_parent"],r=["ascii","utf-8","utf-16","latin1","latin1"],o=["get","post","put","delete"],s=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],u=["all","screen","print","embossed","braille","handheld","print","projection","screen","tty","tv","speech","3d-glasses","resolution [>][<][=] [X]","device-aspect-ratio: X/Y","orientation:portrait","orientation:landscape","device-height: [X]","device-width: [X]"],i={attrs:{}},d={a:{attrs:{href:null,ping:null,type:null,media:u,target:n,hreflang:a}},abbr:i,acronym:i,address:i,applet:i,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:u,hreflang:a,type:null,shape:["default","rect","circle","poly"]}},article:i,aside:i,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["","autoplay"],loop:["","loop"],controls:["","controls"]}},b:i,base:{attrs:{href:null,target:n}},basefont:i,bdi:i,bdo:i,big:i,blockquote:{attrs:{cite:null}},body:i,br:i,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["","autofocus"],disabled:["","autofocus"],formenctype:s,formmethod:o,formnovalidate:["","novalidate"],formtarget:n,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:i,center:i,cite:i,code:i,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["","disabled"],checked:["","checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["","disabled"],multiple:["","multiple"]}},datalist:{attrs:{data:null}},dd:i,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["","open"]}},dfn:i,dir:i,div:i,dl:i,dt:i,em:i,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["","disabled"],form:null,name:null}},figcaption:i,figure:i,font:i,footer:i,form:{attrs:{action:null,name:null,"accept-charset":r,autocomplete:["on","off"],enctype:s,method:o,novalidate:["","novalidate"],target:n}},frame:i,frameset:i,h1:i,h2:i,h3:i,h4:i,h5:i,h6:i,head:{attrs:{},children:["title","base","link","style","meta","script","noscript","command"]},header:i,hgroup:i,hr:i,html:{attrs:{manifest:null},children:["head","body"]},i:i,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["","seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["","autofocus"],checked:["","checked"],disabled:["","disabled"],formenctype:s,formmethod:o,formnovalidate:["","novalidate"],formtarget:n,multiple:["","multiple"],readonly:["","readonly"],required:["","required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:i,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["","autofocus"],disabled:["","disabled"],keytype:["RSA"]}},label:{attrs:{"for":null,form:null}},legend:i,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:a,media:u,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:i,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:r,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:i,noframes:i,noscript:i,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["","typemustmatch"]}},ol:{attrs:{reversed:["","reversed"],start:null,type:["1","a","A","i","I"]}},optgroup:{attrs:{disabled:["","disabled"],label:null}},option:{attrs:{disabled:["","disabled"],label:null,selected:["","selected"],value:null}},output:{attrs:{"for":null,form:null,name:null}},p:i,param:{attrs:{name:null,value:null}},pre:i,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:i,rt:i,ruby:i,s:i,samp:i,script:{attrs:{type:["text/javascript"],src:null,async:["","async"],defer:["","defer"],charset:r}},section:i,select:{attrs:{form:null,name:null,size:null,autofocus:["","autofocus"],disabled:["","disabled"],multiple:["","multiple"]}},small:i,source:{attrs:{src:null,type:null,media:null}},span:i,strike:i,strong:i,style:{attrs:{type:["text/css"],media:u,scoped:null}},sub:i,summary:i,sup:i,table:i,tbody:i,td:{attrs:{colspan:null,rowspan:null,headers:null}},textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["","autofocus"],disabled:["","disabled"],readonly:["","readonly"],required:["","required"],wrap:["soft","hard"]}},tfoot:i,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:i,time:{attrs:{datetime:null}},title:i,tr:i,track:{attrs:{src:null,label:null,"default":null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:a}},tt:i,u:i,ul:i,"var":i,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["","autoplay"],mediagroup:["movie"],muted:["","muted"],controls:["","controls"]}},wbr:i},c={accesskey:["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"],"class":null,contenteditable:["true","false"],contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["en","es"],spellcheck:["true","false"],style:null,tabindex:["1","2","3","4","5","6","7","8","9"],title:null,translate:["yes","no"],onclick:null,rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"]};t(i);for(var m in d)d.hasOwnProperty(m)&&d[m]!=i&&t(d[m]);l.htmlSchema=d,l.registerHelper("hint","html",e)});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/hint/javascript-hint.min.js
CHANGED
@@ -1,26 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){var Pos=CodeMirror.Pos;function forEach(arr,f){for(var i=0,e=arr.length;i<e;++i)f(arr[i]);}
|
6 |
-
function arrayContains(arr,item){if(!Array.prototype.indexOf){var i=arr.length;while(i--){if(arr[i]===item){return true;}}
|
7 |
-
return false;}
|
8 |
-
return arr.indexOf(item)!=-1;}
|
9 |
-
function scriptHint(editor,keywords,getToken,options){var cur=editor.getCursor(),token=getToken(editor,cur);if(/\b(?:string|comment)\b/.test(token.type))return;token.state=CodeMirror.innerMode(editor.getMode(),token.state).state;if(!/^[\w$_]*$/.test(token.string)){token={start:cur.ch,end:cur.ch,string:"",state:token.state,type:token.string=="."?"property":null};}else if(token.end>cur.ch){token.end=cur.ch;token.string=token.string.slice(0,cur.ch-token.start);}
|
10 |
-
var tprop=token;while(tprop.type=="property"){tprop=getToken(editor,Pos(cur.line,tprop.start));if(tprop.string!=".")return;tprop=getToken(editor,Pos(cur.line,tprop.start));if(!context)var context=[];context.push(tprop);}
|
11 |
-
return{list:getCompletions(token,context,keywords,options),from:Pos(cur.line,token.start),to:Pos(cur.line,token.end)};}
|
12 |
-
function javascriptHint(editor,options){return scriptHint(editor,javascriptKeywords,function(e,cur){return e.getTokenAt(cur);},options);};CodeMirror.registerHelper("hint","javascript",javascriptHint);function getCoffeeScriptToken(editor,cur){var token=editor.getTokenAt(cur);if(cur.ch==token.start+1&&token.string.charAt(0)=='.'){token.end=token.start;token.string='.';token.type="property";}
|
13 |
-
else if(/^\.[\w$_]*$/.test(token.string)){token.type="property";token.start++;token.string=token.string.replace(/\./,'');}
|
14 |
-
return token;}
|
15 |
-
function coffeescriptHint(editor,options){return scriptHint(editor,coffeescriptKeywords,getCoffeeScriptToken,options);}
|
16 |
-
CodeMirror.registerHelper("hint","coffeescript",coffeescriptHint);var stringProps=("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight "+"toUpperCase toLowerCase split concat match replace search").split(" ");var arrayProps=("length concat join splice push pop shift unshift slice reverse sort indexOf "+"lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");var funcProps="prototype apply call bind".split(" ");var javascriptKeywords=("break case catch continue debugger default delete do else false finally for function "+"if in instanceof new null return switch throw true try typeof var void while with").split(" ");var coffeescriptKeywords=("and break catch class continue delete do else extends false finally for "+"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");function getCompletions(token,context,keywords,options){var found=[],start=token.string,global=options&&options.globalScope||window;function maybeAdd(str){if(str.lastIndexOf(start,0)==0&&!arrayContains(found,str))found.push(str);}
|
17 |
-
function gatherCompletions(obj){if(typeof obj=="string")forEach(stringProps,maybeAdd);else if(obj instanceof Array)forEach(arrayProps,maybeAdd);else if(obj instanceof Function)forEach(funcProps,maybeAdd);for(var name in obj)maybeAdd(name);}
|
18 |
-
if(context&&context.length){var obj=context.pop(),base;if(obj.type&&obj.type.indexOf("variable")===0){if(options&&options.additionalContext)
|
19 |
-
base=options.additionalContext[obj.string];if(!options||options.useGlobalScope!==false)
|
20 |
-
base=base||global[obj.string];}else if(obj.type=="string"){base="";}else if(obj.type=="atom"){base=1;}else if(obj.type=="function"){if(global.jQuery!=null&&(obj.string=='$'||obj.string=='jQuery')&&(typeof global.jQuery=='function'))
|
21 |
-
base=global.jQuery();else if(global._!=null&&(obj.string=='_')&&(typeof global._=='function'))
|
22 |
-
base=global._();}
|
23 |
-
while(base!=null&&context.length)
|
24 |
-
base=base[context.pop().string];if(base!=null)gatherCompletions(base);}else{for(var v=token.state.localVars;v;v=v.next)maybeAdd(v.name);for(var v=token.state.globalVars;v;v=v.next)maybeAdd(v.name);if(!options||options.useGlobalScope!==false)
|
25 |
-
gatherCompletions(global);forEach(keywords,maybeAdd);}
|
26 |
-
return found;}});
|
1 |
+
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){function e(t,e){for(var r=0,n=t.length;n>r;++r)e(t[r])}function r(t,e){if(!Array.prototype.indexOf){for(var r=t.length;r--;)if(t[r]===e)return!0;return!1}return-1!=t.indexOf(e)}function n(e,r,n,i){var o=e.getCursor(),s=n(e,o);if(!/\b(?:string|comment)\b/.test(s.type)){s.state=t.innerMode(e.getMode(),s.state).state,/^[\w$_]*$/.test(s.string)?s.end>o.ch&&(s.end=o.ch,s.string=s.string.slice(0,o.ch-s.start)):s={start:o.ch,end:o.ch,string:"",state:s.state,type:"."==s.string?"property":null};for(var f=s;"property"==f.type;){if(f=n(e,l(o.line,f.start)),"."!=f.string)return;if(f=n(e,l(o.line,f.start)),!c)var c=[];c.push(f)}return{list:a(s,c,r,i),from:l(o.line,s.start),to:l(o.line,s.end)}}}function i(t,e){return n(t,u,function(t,e){return t.getTokenAt(e)},e)}function o(t,e){var r=t.getTokenAt(e);return e.ch==r.start+1&&"."==r.string.charAt(0)?(r.end=r.start,r.string=".",r.type="property"):/^\.[\w$_]*$/.test(r.string)&&(r.type="property",r.start++,r.string=r.string.replace(/\./,"")),r}function s(t,e){return n(t,d,o,e)}function a(t,n,i,o){function s(t){0!=t.lastIndexOf(u,0)||r(l,t)||l.push(t)}function a(t){"string"==typeof t?e(f,s):t instanceof Array?e(c,s):t instanceof Function&&e(p,s);for(var r in t)s(r)}var l=[],u=t.string,d=o&&o.globalScope||window;if(n&&n.length){var g,h=n.pop();for(h.type&&0===h.type.indexOf("variable")?(o&&o.additionalContext&&(g=o.additionalContext[h.string]),o&&o.useGlobalScope===!1||(g=g||d[h.string])):"string"==h.type?g="":"atom"==h.type?g=1:"function"==h.type&&(null==d.jQuery||"$"!=h.string&&"jQuery"!=h.string||"function"!=typeof d.jQuery?null!=d._&&"_"==h.string&&"function"==typeof d._&&(g=d._()):g=d.jQuery());null!=g&&n.length;)g=g[n.pop().string];null!=g&&a(g)}else{for(var y=t.state.localVars;y;y=y.next)s(y.name);for(var y=t.state.globalVars;y;y=y.next)s(y.name);o&&o.useGlobalScope===!1||a(d),e(i,s)}return l}var l=t.Pos;t.registerHelper("hint","javascript",i),t.registerHelper("hint","coffeescript",s);var f="charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight toUpperCase toLowerCase split concat match replace search".split(" "),c="length concat join splice push pop shift unshift slice reverse sort indexOf lastIndexOf every some filter forEach map reduce reduceRight ".split(" "),p="prototype apply call bind".split(" "),u="break case catch continue debugger default delete do else false finally for function if in instanceof new null return switch throw true try typeof var void while with".split(" "),d="and break catch class continue delete do else extends false finally for if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes".split(" ")});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/hint/show-hint.min.js
CHANGED
@@ -1,35 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";var HINT_ELEMENT_CLASS="CodeMirror-hint";var ACTIVE_HINT_ELEMENT_CLASS="CodeMirror-hint-active";CodeMirror.showHint=function(cm,getHints,options){if(!getHints)return cm.showHint(options);if(options&&options.async)getHints.async=true;var newOpts={hint:getHints};if(options)for(var prop in options)newOpts[prop]=options[prop];return cm.showHint(newOpts);};CodeMirror.defineExtension("showHint",function(options){if(this.listSelections().length>1||this.somethingSelected())return;if(this.state.completionActive)this.state.completionActive.close();var completion=this.state.completionActive=new Completion(this,options);if(!completion.options.hint)return;CodeMirror.signal(this,"startCompletion",this);completion.update();});function Completion(cm,options){this.cm=cm;this.options=this.buildOptions(options);this.widget=null;this.debounce=0;this.tick=0;this.startPos=this.cm.getCursor();this.startLen=this.cm.getLine(this.startPos.line).length;var self=this;cm.on("cursorActivity",this.activityFunc=function(){self.cursorActivity();});}
|
6 |
-
var requestAnimationFrame=window.requestAnimationFrame||function(fn){return setTimeout(fn,1000/60);};var cancelAnimationFrame=window.cancelAnimationFrame||clearTimeout;Completion.prototype={close:function(){if(!this.active())return;this.cm.state.completionActive=null;this.tick=null;this.cm.off("cursorActivity",this.activityFunc);if(this.widget)this.widget.close();CodeMirror.signal(this.cm,"endCompletion",this.cm);},active:function(){return this.cm.state.completionActive==this;},pick:function(data,i){var completion=data.list[i];if(completion.hint)completion.hint(this.cm,data,completion);else this.cm.replaceRange(getText(completion),completion.from||data.from,completion.to||data.to,"complete");CodeMirror.signal(data,"pick",completion);this.close();},showHints:function(data){if(!data||!data.list.length||!this.active())return this.close();if(this.options.completeSingle&&data.list.length==1)
|
7 |
-
this.pick(data,0);else
|
8 |
-
this.showWidget(data);},cursorActivity:function(){if(this.debounce){cancelAnimationFrame(this.debounce);this.debounce=0;}
|
9 |
-
var pos=this.cm.getCursor(),line=this.cm.getLine(pos.line);if(pos.line!=this.startPos.line||line.length-pos.ch!=this.startLen-this.startPos.ch||pos.ch<this.startPos.ch||this.cm.somethingSelected()||(pos.ch&&this.options.closeCharacters.test(line.charAt(pos.ch-1)))){this.close();}else{var self=this;this.debounce=requestAnimationFrame(function(){self.update();});if(this.widget)this.widget.disable();}},update:function(){if(this.tick==null)return;if(this.data)CodeMirror.signal(this.data,"update");if(!this.options.hint.async){this.finishUpdate(this.options.hint(this.cm,this.options),myTick);}else{var myTick=++this.tick,self=this;this.options.hint(this.cm,function(data){if(self.tick==myTick)self.finishUpdate(data);},this.options);}},finishUpdate:function(data){this.data=data;var picked=this.widget&&this.widget.picked;if(this.widget)this.widget.close();if(data&&data.list.length){if(picked&&data.list.length==1)this.pick(data,0);else this.widget=new Widget(this,data);}},showWidget:function(data){this.data=data;this.widget=new Widget(this,data);CodeMirror.signal(data,"shown");},buildOptions:function(options){var editor=this.cm.options.hintOptions;var out={};for(var prop in defaultOptions)out[prop]=defaultOptions[prop];if(editor)for(var prop in editor)
|
10 |
-
if(editor[prop]!==undefined)out[prop]=editor[prop];if(options)for(var prop in options)
|
11 |
-
if(options[prop]!==undefined)out[prop]=options[prop];return out;}};function getText(completion){if(typeof completion=="string")return completion;else return completion.text;}
|
12 |
-
function buildKeyMap(completion,handle){var baseMap={Up:function(){handle.moveFocus(-1);},Down:function(){handle.moveFocus(1);},PageUp:function(){handle.moveFocus(-handle.menuSize()+1,true);},PageDown:function(){handle.moveFocus(handle.menuSize()-1,true);},Home:function(){handle.setFocus(0);},End:function(){handle.setFocus(handle.length-1);},Enter:handle.pick,Tab:handle.pick,Esc:handle.close};var custom=completion.options.customKeys;var ourMap=custom?{}:baseMap;function addBinding(key,val){var bound;if(typeof val!="string")
|
13 |
-
bound=function(cm){return val(cm,handle);};else if(baseMap.hasOwnProperty(val))
|
14 |
-
bound=baseMap[val];else
|
15 |
-
bound=val;ourMap[key]=bound;}
|
16 |
-
if(custom)
|
17 |
-
for(var key in custom)if(custom.hasOwnProperty(key))
|
18 |
-
addBinding(key,custom[key]);var extra=completion.options.extraKeys;if(extra)
|
19 |
-
for(var key in extra)if(extra.hasOwnProperty(key))
|
20 |
-
addBinding(key,extra[key]);return ourMap;}
|
21 |
-
function getHintElement(hintsElement,el){while(el&&el!=hintsElement){if(el.nodeName.toUpperCase()==="LI"&&el.parentNode==hintsElement)return el;el=el.parentNode;}}
|
22 |
-
function Widget(completion,data){this.completion=completion;this.data=data;this.picked=false;var widget=this,cm=completion.cm;var hints=this.hints=document.createElement("ul");hints.className="CodeMirror-hints";this.selectedHint=data.selectedHint||0;var completions=data.list;for(var i=0;i<completions.length;++i){var elt=hints.appendChild(document.createElement("li")),cur=completions[i];var className=HINT_ELEMENT_CLASS+(i!=this.selectedHint?"":" "+ACTIVE_HINT_ELEMENT_CLASS);if(cur.className!=null)className=cur.className+" "+className;elt.className=className;if(cur.render)cur.render(elt,data,cur);else elt.appendChild(document.createTextNode(cur.displayText||getText(cur)));elt.hintId=i;}
|
23 |
-
var pos=cm.cursorCoords(completion.options.alignWithWord?data.from:null);var left=pos.left,top=pos.bottom,below=true;hints.style.left=left+"px";hints.style.top=top+"px";var winW=window.innerWidth||Math.max(document.body.offsetWidth,document.documentElement.offsetWidth);var winH=window.innerHeight||Math.max(document.body.offsetHeight,document.documentElement.offsetHeight);(completion.options.container||document.body).appendChild(hints);var box=hints.getBoundingClientRect(),overlapY=box.bottom-winH;if(overlapY>0){var height=box.bottom-box.top,curTop=pos.top-(pos.bottom-box.top);if(curTop-height>0){hints.style.top=(top=pos.top-height)+"px";below=false;}else if(height>winH){hints.style.height=(winH-5)+"px";hints.style.top=(top=pos.bottom-box.top)+"px";var cursor=cm.getCursor();if(data.from.ch!=cursor.ch){pos=cm.cursorCoords(cursor);hints.style.left=(left=pos.left)+"px";box=hints.getBoundingClientRect();}}}
|
24 |
-
var overlapX=box.right-winW;if(overlapX>0){if(box.right-box.left>winW){hints.style.width=(winW-5)+"px";overlapX-=(box.right-box.left)-winW;}
|
25 |
-
hints.style.left=(left=pos.left-overlapX)+"px";}
|
26 |
-
cm.addKeyMap(this.keyMap=buildKeyMap(completion,{moveFocus:function(n,avoidWrap){widget.changeActive(widget.selectedHint+n,avoidWrap);},setFocus:function(n){widget.changeActive(n);},menuSize:function(){return widget.screenAmount();},length:completions.length,close:function(){completion.close();},pick:function(){widget.pick();},data:data}));if(completion.options.closeOnUnfocus){var closingOnBlur;cm.on("blur",this.onBlur=function(){closingOnBlur=setTimeout(function(){completion.close();},100);});cm.on("focus",this.onFocus=function(){clearTimeout(closingOnBlur);});}
|
27 |
-
var startScroll=cm.getScrollInfo();cm.on("scroll",this.onScroll=function(){var curScroll=cm.getScrollInfo(),editor=cm.getWrapperElement().getBoundingClientRect();var newTop=top+startScroll.top-curScroll.top;var point=newTop-(window.pageYOffset||(document.documentElement||document.body).scrollTop);if(!below)point+=hints.offsetHeight;if(point<=editor.top||point>=editor.bottom)return completion.close();hints.style.top=newTop+"px";hints.style.left=(left+startScroll.left-curScroll.left)+"px";});CodeMirror.on(hints,"dblclick",function(e){var t=getHintElement(hints,e.target||e.srcElement);if(t&&t.hintId!=null){widget.changeActive(t.hintId);widget.pick();}});CodeMirror.on(hints,"click",function(e){var t=getHintElement(hints,e.target||e.srcElement);if(t&&t.hintId!=null){widget.changeActive(t.hintId);if(completion.options.completeOnSingleClick)widget.pick();}});CodeMirror.on(hints,"mousedown",function(){setTimeout(function(){cm.focus();},20);});CodeMirror.signal(data,"select",completions[0],hints.firstChild);return true;}
|
28 |
-
Widget.prototype={close:function(){if(this.completion.widget!=this)return;this.completion.widget=null;this.hints.parentNode.removeChild(this.hints);this.completion.cm.removeKeyMap(this.keyMap);var cm=this.completion.cm;if(this.completion.options.closeOnUnfocus){cm.off("blur",this.onBlur);cm.off("focus",this.onFocus);}
|
29 |
-
cm.off("scroll",this.onScroll);},disable:function(){this.completion.cm.removeKeyMap(this.keyMap);var widget=this;this.keyMap={Enter:function(){widget.picked=true;}};this.completion.cm.addKeyMap(this.keyMap);},pick:function(){this.completion.pick(this.data,this.selectedHint);},changeActive:function(i,avoidWrap){if(i>=this.data.list.length)
|
30 |
-
i=avoidWrap?this.data.list.length-1:0;else if(i<0)
|
31 |
-
i=avoidWrap?0:this.data.list.length-1;if(this.selectedHint==i)return;var node=this.hints.childNodes[this.selectedHint];node.className=node.className.replace(" "+ACTIVE_HINT_ELEMENT_CLASS,"");node=this.hints.childNodes[this.selectedHint=i];node.className+=" "+ACTIVE_HINT_ELEMENT_CLASS;if(node.offsetTop<this.hints.scrollTop)
|
32 |
-
this.hints.scrollTop=node.offsetTop-3;else if(node.offsetTop+node.offsetHeight>this.hints.scrollTop+this.hints.clientHeight)
|
33 |
-
this.hints.scrollTop=node.offsetTop+node.offsetHeight-this.hints.clientHeight+3;CodeMirror.signal(this.data,"select",this.data.list[this.selectedHint],node);},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1;}};CodeMirror.registerHelper("hint","auto",function(cm,options){var helpers=cm.getHelpers(cm.getCursor(),"hint"),words;if(helpers.length){for(var i=0;i<helpers.length;i++){var cur=helpers[i](cm,options);if(cur&&cur.list.length)return cur;}}else if(words=cm.getHelper(cm.getCursor(),"hintWords")){if(words)return CodeMirror.hint.fromList(cm,{words:words});}else if(CodeMirror.hint.anyword){return CodeMirror.hint.anyword(cm,options);}});CodeMirror.registerHelper("hint","fromList",function(cm,options){var cur=cm.getCursor(),token=cm.getTokenAt(cur);var found=[];for(var i=0;i<options.words.length;i++){var word=options.words[i];if(word.slice(0,token.string.length)==token.string)
|
34 |
-
found.push(word);}
|
35 |
-
if(found.length)return{list:found,from:CodeMirror.Pos(cur.line,token.start),to:CodeMirror.Pos(cur.line,token.end)};});CodeMirror.commands.autocomplete=CodeMirror.showHint;var defaultOptions={hint:CodeMirror.hint.auto,completeSingle:true,alignWithWord:true,closeCharacters:/[\s()\[\]{};:>,]/,closeOnUnfocus:true,completeOnSingleClick:false,container:null,customKeys:null,extraKeys:null};CodeMirror.defineOption("hintOptions",null);});
|
1 |
+
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";function i(t,i){this.cm=t,this.options=this.buildOptions(i),this.widget=null,this.debounce=0,this.tick=0,this.startPos=this.cm.getCursor(),this.startLen=this.cm.getLine(this.startPos.line).length;var e=this;t.on("cursorActivity",this.activityFunc=function(){e.cursorActivity()})}function e(t){return"string"==typeof t?t:t.text}function n(t,i){function e(t,e){var o;o="string"!=typeof e?function(t){return e(t,i)}:n.hasOwnProperty(e)?n[e]:e,s[t]=o}var n={Up:function(){i.moveFocus(-1)},Down:function(){i.moveFocus(1)},PageUp:function(){i.moveFocus(-i.menuSize()+1,!0)},PageDown:function(){i.moveFocus(i.menuSize()-1,!0)},Home:function(){i.setFocus(0)},End:function(){i.setFocus(i.length-1)},Enter:i.pick,Tab:i.pick,Esc:i.close},o=t.options.customKeys,s=o?{}:n;if(o)for(var c in o)o.hasOwnProperty(c)&&e(c,o[c]);var h=t.options.extraKeys;if(h)for(var c in h)h.hasOwnProperty(c)&&e(c,h[c]);return s}function o(t,i){for(;i&&i!=t;){if("LI"===i.nodeName.toUpperCase()&&i.parentNode==t)return i;i=i.parentNode}}function s(i,s){this.completion=i,this.data=s,this.picked=!1;var r=this,l=i.cm,a=this.hints=document.createElement("ul");a.className="CodeMirror-hints",this.selectedHint=s.selectedHint||0;for(var u=s.list,f=0;f<u.length;++f){var d=a.appendChild(document.createElement("li")),p=u[f],m=c+(f!=this.selectedHint?"":" "+h);null!=p.className&&(m=p.className+" "+m),d.className=m,p.render?p.render(d,s,p):d.appendChild(document.createTextNode(p.displayText||e(p))),d.hintId=f}var g=l.cursorCoords(i.options.alignWithWord?s.from:null),v=g.left,y=g.bottom,w=!0;a.style.left=v+"px",a.style.top=y+"px";var k=window.innerWidth||Math.max(document.body.offsetWidth,document.documentElement.offsetWidth),H=window.innerHeight||Math.max(document.body.offsetHeight,document.documentElement.offsetHeight);(i.options.container||document.body).appendChild(a);var C=a.getBoundingClientRect(),b=C.bottom-H;if(b>0){var A=C.bottom-C.top,x=g.top-(g.bottom-C.top);if(x-A>0)a.style.top=(y=g.top-A)+"px",w=!1;else if(A>H){a.style.height=H-5+"px",a.style.top=(y=g.bottom-C.top)+"px";var T=l.getCursor();s.from.ch!=T.ch&&(g=l.cursorCoords(T),a.style.left=(v=g.left)+"px",C=a.getBoundingClientRect())}}var M=C.right-k;if(M>0&&(C.right-C.left>k&&(a.style.width=k-5+"px",M-=C.right-C.left-k),a.style.left=(v=g.left-M)+"px"),l.addKeyMap(this.keyMap=n(i,{moveFocus:function(t,i){r.changeActive(r.selectedHint+t,i)},setFocus:function(t){r.changeActive(t)},menuSize:function(){return r.screenAmount()},length:u.length,close:function(){i.close()},pick:function(){r.pick()},data:s})),i.options.closeOnUnfocus){var F;l.on("blur",this.onBlur=function(){F=setTimeout(function(){i.close()},100)}),l.on("focus",this.onFocus=function(){clearTimeout(F)})}var N=l.getScrollInfo();return l.on("scroll",this.onScroll=function(){var t=l.getScrollInfo(),e=l.getWrapperElement().getBoundingClientRect(),n=y+N.top-t.top,o=n-(window.pageYOffset||(document.documentElement||document.body).scrollTop);return w||(o+=a.offsetHeight),o<=e.top||o>=e.bottom?i.close():(a.style.top=n+"px",void(a.style.left=v+N.left-t.left+"px"))}),t.on(a,"dblclick",function(t){var i=o(a,t.target||t.srcElement);i&&null!=i.hintId&&(r.changeActive(i.hintId),r.pick())}),t.on(a,"click",function(t){var e=o(a,t.target||t.srcElement);e&&null!=e.hintId&&(r.changeActive(e.hintId),i.options.completeOnSingleClick&&r.pick())}),t.on(a,"mousedown",function(){setTimeout(function(){l.focus()},20)}),t.signal(s,"select",u[0],a.firstChild),!0}var c="CodeMirror-hint",h="CodeMirror-hint-active";t.showHint=function(t,i,e){if(!i)return t.showHint(e);e&&e.async&&(i.async=!0);var n={hint:i};if(e)for(var o in e)n[o]=e[o];return t.showHint(n)},t.defineExtension("showHint",function(e){if(!(this.listSelections().length>1||this.somethingSelected())){this.state.completionActive&&this.state.completionActive.close();var n=this.state.completionActive=new i(this,e);n.options.hint&&(t.signal(this,"startCompletion",this),n.update())}});var r=window.requestAnimationFrame||function(t){return setTimeout(t,1e3/60)},l=window.cancelAnimationFrame||clearTimeout;i.prototype={close:function(){this.active()&&(this.cm.state.completionActive=null,this.tick=null,this.cm.off("cursorActivity",this.activityFunc),this.widget&&this.widget.close(),t.signal(this.cm,"endCompletion",this.cm))},active:function(){return this.cm.state.completionActive==this},pick:function(i,n){var o=i.list[n];o.hint?o.hint(this.cm,i,o):this.cm.replaceRange(e(o),o.from||i.from,o.to||i.to,"complete"),t.signal(i,"pick",o),this.close()},showHints:function(t){return t&&t.list.length&&this.active()?void(this.options.completeSingle&&1==t.list.length?this.pick(t,0):this.showWidget(t)):this.close()},cursorActivity:function(){this.debounce&&(l(this.debounce),this.debounce=0);var t=this.cm.getCursor(),i=this.cm.getLine(t.line);if(t.line!=this.startPos.line||i.length-t.ch!=this.startLen-this.startPos.ch||t.ch<this.startPos.ch||this.cm.somethingSelected()||t.ch&&this.options.closeCharacters.test(i.charAt(t.ch-1)))this.close();else{var e=this;this.debounce=r(function(){e.update()}),this.widget&&this.widget.disable()}},update:function(){if(null!=this.tick)if(this.data&&t.signal(this.data,"update"),this.options.hint.async){var i=++this.tick,e=this;this.options.hint(this.cm,function(t){e.tick==i&&e.finishUpdate(t)},this.options)}else this.finishUpdate(this.options.hint(this.cm,this.options),i)},finishUpdate:function(t){this.data=t;var i=this.widget&&this.widget.picked;this.widget&&this.widget.close(),t&&t.list.length&&(i&&1==t.list.length?this.pick(t,0):this.widget=new s(this,t))},showWidget:function(i){this.data=i,this.widget=new s(this,i),t.signal(i,"shown")},buildOptions:function(t){var i=this.cm.options.hintOptions,e={};for(var n in a)e[n]=a[n];if(i)for(var n in i)void 0!==i[n]&&(e[n]=i[n]);if(t)for(var n in t)void 0!==t[n]&&(e[n]=t[n]);return e}},s.prototype={close:function(){if(this.completion.widget==this){this.completion.widget=null,this.hints.parentNode.removeChild(this.hints),this.completion.cm.removeKeyMap(this.keyMap);var t=this.completion.cm;this.completion.options.closeOnUnfocus&&(t.off("blur",this.onBlur),t.off("focus",this.onFocus)),t.off("scroll",this.onScroll)}},disable:function(){this.completion.cm.removeKeyMap(this.keyMap);var t=this;this.keyMap={Enter:function(){t.picked=!0}},this.completion.cm.addKeyMap(this.keyMap)},pick:function(){this.completion.pick(this.data,this.selectedHint)},changeActive:function(i,e){if(i>=this.data.list.length?i=e?this.data.list.length-1:0:0>i&&(i=e?0:this.data.list.length-1),this.selectedHint!=i){var n=this.hints.childNodes[this.selectedHint];n.className=n.className.replace(" "+h,""),n=this.hints.childNodes[this.selectedHint=i],n.className+=" "+h,n.offsetTop<this.hints.scrollTop?this.hints.scrollTop=n.offsetTop-3:n.offsetTop+n.offsetHeight>this.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=n.offsetTop+n.offsetHeight-this.hints.clientHeight+3),t.signal(this.data,"select",this.data.list[this.selectedHint],n)}},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}},t.registerHelper("hint","auto",function(i,e){var n,o=i.getHelpers(i.getCursor(),"hint");if(o.length)for(var s=0;s<o.length;s++){var c=o[s](i,e);if(c&&c.list.length)return c}else if(n=i.getHelper(i.getCursor(),"hintWords")){if(n)return t.hint.fromList(i,{words:n})}else if(t.hint.anyword)return t.hint.anyword(i,e)}),t.registerHelper("hint","fromList",function(i,e){for(var n=i.getCursor(),o=i.getTokenAt(n),s=[],c=0;c<e.words.length;c++){var h=e.words[c];h.slice(0,o.string.length)==o.string&&s.push(h)}return s.length?{list:s,from:t.Pos(n.line,o.start),to:t.Pos(n.line,o.end)}:void 0}),t.commands.autocomplete=t.showHint;var a={hint:t.hint.auto,completeSingle:!0,alignWithWord:!0,closeCharacters:/[\s()\[\]{};:>,]/,closeOnUnfocus:!0,completeOnSingleClick:!1,container:null,customKeys:null,extraKeys:null};t.defineOption("hintOptions",null)});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/hint/sql-hint.min.js
CHANGED
@@ -1,38 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"),require("../../mode/sql/sql"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror","../../mode/sql/sql"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";var tables;var defaultTable;var keywords;var CONS={QUERY_DIV:";",ALIAS_KEYWORD:"AS"};var Pos=CodeMirror.Pos;function getKeywords(editor){var mode=editor.doc.modeOption;if(mode==="sql")mode="text/x-sql";return CodeMirror.resolveMode(mode).keywords;}
|
6 |
-
function getText(item){return typeof item=="string"?item:item.text;}
|
7 |
-
function getItem(list,item){if(!list.slice)return list[item];for(var i=list.length-1;i>=0;i--)if(getText(list[i])==item)
|
8 |
-
return list[i];}
|
9 |
-
function shallowClone(object){var result={};for(var key in object)if(object.hasOwnProperty(key))
|
10 |
-
result[key]=object[key];return result;}
|
11 |
-
function match(string,word){var len=string.length;var sub=getText(word).substr(0,len);return string.toUpperCase()===sub.toUpperCase();}
|
12 |
-
function addMatches(result,search,wordlist,formatter){for(var word in wordlist){if(!wordlist.hasOwnProperty(word))continue;if(wordlist.slice)word=wordlist[word];if(match(search,word))result.push(formatter(word));}}
|
13 |
-
function cleanName(name){if(name.charAt(0)=="."){name=name.substr(1);}
|
14 |
-
return name.replace(/`/g,"");}
|
15 |
-
function insertBackticks(name){var nameParts=getText(name).split(".");for(var i=0;i<nameParts.length;i++)
|
16 |
-
nameParts[i]="`"+nameParts[i]+"`";var escaped=nameParts.join(".");if(typeof name=="string")return escaped;name=shallowClone(name);name.text=escaped;return name;}
|
17 |
-
function nameCompletion(cur,token,result,editor){var useBacktick=false;var nameParts=[];var start=token.start;var cont=true;while(cont){cont=(token.string.charAt(0)==".");useBacktick=useBacktick||(token.string.charAt(0)=="`");start=token.start;nameParts.unshift(cleanName(token.string));token=editor.getTokenAt(Pos(cur.line,token.start));if(token.string=="."){cont=true;token=editor.getTokenAt(Pos(cur.line,token.start));}}
|
18 |
-
var string=nameParts.join(".");addMatches(result,string,tables,function(w){return useBacktick?insertBackticks(w):w;});addMatches(result,string,defaultTable,function(w){return useBacktick?insertBackticks(w):w;});string=nameParts.pop();var table=nameParts.join(".");if(!getItem(tables,table))
|
19 |
-
table=findTableByAlias(table,editor);var columns=getItem(tables,table);if(columns&&columns.columns)
|
20 |
-
columns=columns.columns;if(columns){addMatches(result,string,columns,function(w){if(typeof w=="string"){w=table+"."+w;}else{w=shallowClone(w);w.text=table+"."+w.text;}
|
21 |
-
return useBacktick?insertBackticks(w):w;});}
|
22 |
-
return start;}
|
23 |
-
function eachWord(lineText,f){if(!lineText)return;var excepted=/[,;]/g;var words=lineText.split(" ");for(var i=0;i<words.length;i++){f(words[i]?words[i].replace(excepted,''):'');}}
|
24 |
-
function convertCurToNumber(cur){return cur.line+cur.ch/Math.pow(10,6);}
|
25 |
-
function convertNumberToCur(num){return Pos(Math.floor(num),+num.toString().split('.').pop());}
|
26 |
-
function findTableByAlias(alias,editor){var doc=editor.doc;var fullQuery=doc.getValue();var aliasUpperCase=alias.toUpperCase();var previousWord="";var table="";var separator=[];var validRange={start:Pos(0,0),end:Pos(editor.lastLine(),editor.getLineHandle(editor.lastLine()).length)};var indexOfSeparator=fullQuery.indexOf(CONS.QUERY_DIV);while(indexOfSeparator!=-1){separator.push(doc.posFromIndex(indexOfSeparator));indexOfSeparator=fullQuery.indexOf(CONS.QUERY_DIV,indexOfSeparator+1);}
|
27 |
-
separator.unshift(Pos(0,0));separator.push(Pos(editor.lastLine(),editor.getLineHandle(editor.lastLine()).text.length));var prevItem=0;var current=convertCurToNumber(editor.getCursor());for(var i=0;i<separator.length;i++){var _v=convertCurToNumber(separator[i]);if(current>prevItem&¤t<=_v){validRange={start:convertNumberToCur(prevItem),end:convertNumberToCur(_v)};break;}
|
28 |
-
prevItem=_v;}
|
29 |
-
var query=doc.getRange(validRange.start,validRange.end,false);for(var i=0;i<query.length;i++){var lineText=query[i];eachWord(lineText,function(word){var wordUpperCase=word.toUpperCase();if(wordUpperCase===aliasUpperCase&&getItem(tables,previousWord))
|
30 |
-
table=previousWord;if(wordUpperCase!==CONS.ALIAS_KEYWORD)
|
31 |
-
previousWord=word;});if(table)break;}
|
32 |
-
return table;}
|
33 |
-
CodeMirror.registerHelper("hint","sql",function(editor,options){tables=(options&&options.tables)||{};var defaultTableName=options&&options.defaultTable;defaultTable=defaultTableName&&getItem(tables,defaultTableName);keywords=keywords||getKeywords(editor);if(defaultTableName&&!defaultTable)
|
34 |
-
defaultTable=findTableByAlias(defaultTableName,editor);defaultTable=defaultTable||[];if(defaultTable.columns)
|
35 |
-
defaultTable=defaultTable.columns;var cur=editor.getCursor();var result=[];var token=editor.getTokenAt(cur),start,end,search;if(token.end>cur.ch){token.end=cur.ch;token.string=token.string.slice(0,cur.ch-token.start);}
|
36 |
-
if(token.string.match(/^[.`\w@]\w*$/)){search=token.string;start=token.start;end=token.end;}else{start=end=cur.ch;search="";}
|
37 |
-
if(search.charAt(0)=="."||search.charAt(0)=="`"){start=nameCompletion(cur,token,result,editor);}else{addMatches(result,search,tables,function(w){return w;});addMatches(result,search,defaultTable,function(w){return w;});addMatches(result,search,keywords,function(w){return w.toUpperCase();});}
|
38 |
-
return{list:result,from:Pos(cur.line,start),to:Pos(cur.line,end)};});});
|
1 |
+
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("../../mode/sql/sql")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../../mode/sql/sql"],t):t(CodeMirror)}(function(t){"use strict";function r(r){var n=r.doc.modeOption;return"sql"===n&&(n="text/x-sql"),t.resolveMode(n).keywords}function n(t){return"string"==typeof t?t:t.text}function e(t,r){if(!t.slice)return t[r];for(var e=t.length-1;e>=0;e--)if(n(t[e])==r)return t[e]}function o(t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n]);return r}function i(t,r){var e=t.length,o=n(r).substr(0,e);return t.toUpperCase()===o.toUpperCase()}function s(t,r,n,e){for(var o in n)n.hasOwnProperty(o)&&(n.slice&&(o=n[o]),i(r,o)&&t.push(e(o)))}function a(t){return"."==t.charAt(0)&&(t=t.substr(1)),t.replace(/`/g,"")}function u(t){for(var r=n(t).split("."),e=0;e<r.length;e++)r[e]="`"+r[e]+"`";var i=r.join(".");return"string"==typeof t?i:(t=o(t),t.text=i,t)}function f(t,r,n,i){for(var f=!1,c=[],l=r.start,p=!0;p;)p="."==r.string.charAt(0),f=f||"`"==r.string.charAt(0),l=r.start,c.unshift(a(r.string)),r=i.getTokenAt(A(t.line,r.start)),"."==r.string&&(p=!0,r=i.getTokenAt(A(t.line,r.start)));var v=c.join(".");s(n,v,h,function(t){return f?u(t):t}),s(n,v,d,function(t){return f?u(t):t}),v=c.pop();var m=c.join(".");e(h,m)||(m=g(m,i));var x=e(h,m);return x&&x.columns&&(x=x.columns),x&&s(n,v,x,function(t){return"string"==typeof t?t=m+"."+t:(t=o(t),t.text=m+"."+t.text),f?u(t):t}),l}function c(t,r){if(t)for(var n=/[,;]/g,e=t.split(" "),o=0;o<e.length;o++)r(e[o]?e[o].replace(n,""):"")}function l(t){return t.line+t.ch/Math.pow(10,6)}function p(t){return A(Math.floor(t),+t.toString().split(".").pop())}function g(t,r){for(var n=r.doc,o=n.getValue(),i=t.toUpperCase(),s="",a="",u=[],f={start:A(0,0),end:A(r.lastLine(),r.getLineHandle(r.lastLine()).length)},g=o.indexOf(m.QUERY_DIV);-1!=g;)u.push(n.posFromIndex(g)),g=o.indexOf(m.QUERY_DIV,g+1);u.unshift(A(0,0)),u.push(A(r.lastLine(),r.getLineHandle(r.lastLine()).text.length));for(var d=0,v=l(r.getCursor()),x=0;x<u.length;x++){var b=l(u[x]);if(v>d&&b>=v){f={start:p(d),end:p(b)};break}d=b}for(var q=n.getRange(f.start,f.end,!1),x=0;x<q.length;x++){var y=q[x];if(c(y,function(t){var r=t.toUpperCase();r===i&&e(h,s)&&(a=s),r!==m.ALIAS_KEYWORD&&(s=t)}),a)break}return a}var h,d,v,m={QUERY_DIV:";",ALIAS_KEYWORD:"AS"},A=t.Pos;t.registerHelper("hint","sql",function(t,n){h=n&&n.tables||{};var o=n&&n.defaultTable;d=o&&e(h,o),v=v||r(t),o&&!d&&(d=g(o,t)),d=d||[],d.columns&&(d=d.columns);var i,a,u,c=t.getCursor(),l=[],p=t.getTokenAt(c);return p.end>c.ch&&(p.end=c.ch,p.string=p.string.slice(0,c.ch-p.start)),p.string.match(/^[.`\w@]\w*$/)?(u=p.string,i=p.start,a=p.end):(i=a=c.ch,u=""),"."==u.charAt(0)||"`"==u.charAt(0)?i=f(c,p,l,t):(s(l,u,h,function(t){return t}),s(l,u,d,function(t){return t}),s(l,u,v,function(t){return t.toUpperCase()})),{list:l,from:A(c.line,i),to:A(c.line,a)}})});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/hint/xml-hint.min.js
CHANGED
@@ -1,22 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";var Pos=CodeMirror.Pos;function getHints(cm,options){var tags=options&&options.schemaInfo;var quote=(options&&options.quoteChar)||'"';if(!tags)return;var cur=cm.getCursor(),token=cm.getTokenAt(cur);if(token.end>cur.ch){token.end=cur.ch;token.string=token.string.slice(0,cur.ch-token.start);}
|
6 |
-
var inner=CodeMirror.innerMode(cm.getMode(),token.state);if(inner.mode.name!="xml")return;var result=[],replaceToken=false,prefix;var tag=/\btag\b/.test(token.type)&&!/>$/.test(token.string);var tagName=tag&&/^\w/.test(token.string),tagStart;if(tagName){var before=cm.getLine(cur.line).slice(Math.max(0,token.start-2),token.start);var tagType=/<\/$/.test(before)?"close":/<$/.test(before)?"open":null;if(tagType)tagStart=token.start-(tagType=="close"?2:1);}else if(tag&&token.string=="<"){tagType="open";}else if(tag&&token.string=="</"){tagType="close";}
|
7 |
-
if(!tag&&!inner.state.tagName||tagType){if(tagName)
|
8 |
-
prefix=token.string;replaceToken=tagType;var cx=inner.state.context,curTag=cx&&tags[cx.tagName];var childList=cx?curTag&&curTag.children:tags["!top"];if(childList&&tagType!="close"){for(var i=0;i<childList.length;++i)if(!prefix||childList[i].lastIndexOf(prefix,0)==0)
|
9 |
-
result.push("<"+childList[i]);}else if(tagType!="close"){for(var name in tags)
|
10 |
-
if(tags.hasOwnProperty(name)&&name!="!top"&&name!="!attrs"&&(!prefix||name.lastIndexOf(prefix,0)==0))
|
11 |
-
result.push("<"+name);}
|
12 |
-
if(cx&&(!prefix||tagType=="close"&&cx.tagName.lastIndexOf(prefix,0)==0))
|
13 |
-
result.push("</"+cx.tagName+">");}else{var curTag=tags[inner.state.tagName],attrs=curTag&&curTag.attrs;var globalAttrs=tags["!attrs"];if(!attrs&&!globalAttrs)return;if(!attrs){attrs=globalAttrs;}else if(globalAttrs){var set={};for(var nm in globalAttrs)if(globalAttrs.hasOwnProperty(nm))set[nm]=globalAttrs[nm];for(var nm in attrs)if(attrs.hasOwnProperty(nm))set[nm]=attrs[nm];attrs=set;}
|
14 |
-
if(token.type=="string"||token.string=="="){var before=cm.getRange(Pos(cur.line,Math.max(0,cur.ch-60)),Pos(cur.line,token.type=="string"?token.start:token.end));var atName=before.match(/([^\s\u00a0=<>\"\']+)=$/),atValues;if(!atName||!attrs.hasOwnProperty(atName[1])||!(atValues=attrs[atName[1]]))return;if(typeof atValues=='function')atValues=atValues.call(this,cm);if(token.type=="string"){prefix=token.string;var n=0;if(/['"]/.test(token.string.charAt(0))){quote=token.string.charAt(0);prefix=token.string.slice(1);n++;}
|
15 |
-
var len=token.string.length;if(/['"]/.test(token.string.charAt(len-1))){quote=token.string.charAt(len-1);prefix=token.string.substr(n,len-2);}
|
16 |
-
replaceToken=true;}
|
17 |
-
for(var i=0;i<atValues.length;++i)if(!prefix||atValues[i].lastIndexOf(prefix,0)==0)
|
18 |
-
result.push(quote+atValues[i]+quote);}else{if(token.type=="attribute"){prefix=token.string;replaceToken=true;}
|
19 |
-
for(var attr in attrs)if(attrs.hasOwnProperty(attr)&&(!prefix||attr.lastIndexOf(prefix,0)==0))
|
20 |
-
result.push(attr);}}
|
21 |
-
return{list:result,from:replaceToken?Pos(cur.line,tagStart==null?token.start:tagStart):cur,to:replaceToken?Pos(cur.line,token.end):cur};}
|
22 |
-
CodeMirror.registerHelper("hint","xml",getHints);});
|
1 |
+
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";function e(e,s){var n=s&&s.schemaInfo,a=s&&s.quoteChar||'"';if(n){var i=e.getCursor(),o=e.getTokenAt(i);o.end>i.ch&&(o.end=i.ch,o.string=o.string.slice(0,i.ch-o.start));var l=t.innerMode(e.getMode(),o.state);if("xml"==l.mode.name){var f,g,c=[],h=!1,p=/\btag\b/.test(o.type)&&!/>$/.test(o.string),u=p&&/^\w/.test(o.string);if(u){var d=e.getLine(i.line).slice(Math.max(0,o.start-2),o.start),m=/<\/$/.test(d)?"close":/<$/.test(d)?"open":null;m&&(g=o.start-("close"==m?2:1))}else p&&"<"==o.string?m="open":p&&"</"==o.string&&(m="close");if(!p&&!l.state.tagName||m){u&&(f=o.string),h=m;var v=l.state.context,y=v&&n[v.tagName],x=v?y&&y.children:n["!top"];if(x&&"close"!=m)for(var O=0;O<x.length;++O)f&&0!=x[O].lastIndexOf(f,0)||c.push("<"+x[O]);else if("close"!=m)for(var b in n)!n.hasOwnProperty(b)||"!top"==b||"!attrs"==b||f&&0!=b.lastIndexOf(f,0)||c.push("<"+b);v&&(!f||"close"==m&&0==v.tagName.lastIndexOf(f,0))&&c.push("</"+v.tagName+">")}else{var y=n[l.state.tagName],w=y&&y.attrs,I=n["!attrs"];if(!w&&!I)return;if(w){if(I){var P={};for(var A in I)I.hasOwnProperty(A)&&(P[A]=I[A]);for(var A in w)w.hasOwnProperty(A)&&(P[A]=w[A]);w=P}}else w=I;if("string"==o.type||"="==o.string){var M,d=e.getRange(r(i.line,Math.max(0,i.ch-60)),r(i.line,"string"==o.type?o.start:o.end)),N=d.match(/([^\s\u00a0=<>\"\']+)=$/);if(!N||!w.hasOwnProperty(N[1])||!(M=w[N[1]]))return;if("function"==typeof M&&(M=M.call(this,e)),"string"==o.type){f=o.string;var $=0;/['"]/.test(o.string.charAt(0))&&(a=o.string.charAt(0),f=o.string.slice(1),$++);var C=o.string.length;/['"]/.test(o.string.charAt(C-1))&&(a=o.string.charAt(C-1),f=o.string.substr($,C-2)),h=!0}for(var O=0;O<M.length;++O)f&&0!=M[O].lastIndexOf(f,0)||c.push(a+M[O]+a)}else{"attribute"==o.type&&(f=o.string,h=!0);for(var j in w)!w.hasOwnProperty(j)||f&&0!=j.lastIndexOf(f,0)||c.push(j)}}return{list:c,from:h?r(i.line,null==g?o.start:g):i,to:h?r(i.line,o.end):i}}}}var r=t.Pos;t.registerHelper("hint","xml",e)});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/lint/coffeescript-lint.min.js
CHANGED
@@ -1,6 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.registerHelper("lint","coffeescript",function(text){var found=[];var parseError=function(err){var loc=err.lineNumber;found.push({from:CodeMirror.Pos(loc-1,0),to:CodeMirror.Pos(loc,0),severity:err.level,message:err.message});};try{var res=coffeelint.lint(text);for(var i=0;i<res.length;i++){parseError(res[i]);}}catch(e){found.push({from:CodeMirror.Pos(e.location.first_line,0),to:CodeMirror.Pos(e.location.last_line,e.location.last_column),severity:'error',message:e.message});}
|
6 |
-
return found;});});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("lint","coffeescript",function(o){var r=[],t=function(o){var t=o.lineNumber;r.push({from:e.Pos(t-1,0),to:e.Pos(t,0),severity:o.level,message:o.message})};try{for(var i=coffeelint.lint(o),n=0;n<i.length;n++)t(i[n])}catch(s){r.push({from:e.Pos(s.location.first_line,0),to:e.Pos(s.location.last_line,s.location.last_column),severity:"error",message:s.message})}return r})});
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/lint/css-lint.min.js
CHANGED
@@ -1,6 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.registerHelper("lint","css",function(text){var found=[];if(!window.CSSLint)return found;var results=CSSLint.verify(text,{"box-model":1,"display-property-grouping":1,"duplicate-properties":1,"empty-rules":1,"known-properties":1}),messages=results.messages,message=null;for(var i=0;i<messages.length;i++){message=messages[i];var startLine=message.line-1,endLine=message.line-1,startCol=message.col-1,endCol=message.col;found.push({from:CodeMirror.Pos(startLine,startCol),to:CodeMirror.Pos(endLine,endCol),message:message.message,severity:message.type});}
|
6 |
-
return found;});});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("lint","css",function(r){var o=[];if(!window.CSSLint)return o;for(var i=CSSLint.verify(r,{"box-model":1,"display-property-grouping":1,"duplicate-properties":1,"empty-rules":1,"known-properties":1}),t=i.messages,n=null,s=0;s<t.length;s++){n=t[s];var p=n.line-1,l=n.line-1,f=n.col-1,u=n.col;o.push({from:e.Pos(p,f),to:e.Pos(l,u),message:n.message,severity:n.type})}return o})});
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/lint/javascript-lint.min.js
CHANGED
@@ -1,15 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";var bogus=["Dangerous comment"];var warnings=[["Expected '{'","Statement body should be inside '{ }' braces."]];var errors=["Missing semicolon","Extra comma","Missing property name","Unmatched "," and instead saw"," is not defined","Unclosed string","Stopping, unable to continue"];function validator(text,options){if(!window.JSHINT)return[];JSHINT(text,options,options.globals);var errors=JSHINT.data().errors,result=[];if(errors)parseErrors(errors,result);return result;}
|
6 |
-
CodeMirror.registerHelper("lint","javascript",validator);function cleanup(error){fixWith(error,warnings,"warning",true);fixWith(error,errors,"error");return isBogus(error)?null:error;}
|
7 |
-
function fixWith(error,fixes,severity,force){var description,fix,find,replace,found;description=error.description;for(var i=0;i<fixes.length;i++){fix=fixes[i];find=(typeof fix==="string"?fix:fix[0]);replace=(typeof fix==="string"?null:fix[1]);found=description.indexOf(find)!==-1;if(force||found){error.severity=severity;}
|
8 |
-
if(found&&replace){error.description=replace;}}}
|
9 |
-
function isBogus(error){var description=error.description;for(var i=0;i<bogus.length;i++){if(description.indexOf(bogus[i])!==-1){return true;}}
|
10 |
-
return false;}
|
11 |
-
function parseErrors(errors,output){for(var i=0;i<errors.length;i++){var error=errors[i];if(error){var linetabpositions,index;linetabpositions=[];if(error.evidence){var tabpositions=linetabpositions[error.line];if(!tabpositions){var evidence=error.evidence;tabpositions=[];Array.prototype.forEach.call(evidence,function(item,index){if(item==='\t'){tabpositions.push(index+1);}});linetabpositions[error.line]=tabpositions;}
|
12 |
-
if(tabpositions.length>0){var pos=error.character;tabpositions.forEach(function(tabposition){if(pos>tabposition)pos-=1;});error.character=pos;}}
|
13 |
-
var start=error.character-1,end=start+1;if(error.evidence){index=error.evidence.substring(start).search(/.\b/);if(index>-1){end+=index;}}
|
14 |
-
error.description=error.reason;error.start=error.character;error.end=end;error=cleanup(error);if(error)
|
15 |
-
output.push({message:error.description,severity:error.severity,from:CodeMirror.Pos(error.line-1,start),to:CodeMirror.Pos(error.line-1,end)});}}}});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function r(e,r){if(!window.JSHINT)return[];JSHINT(e,r,r.globals);var n=JSHINT.data().errors,i=[];return n&&o(n,i),i}function n(e){return i(e,c,"warning",!0),i(e,s,"error"),t(e)?null:e}function i(e,r,n,i){var t,o,a,c,s;t=e.description;for(var f=0;f<r.length;f++)o=r[f],a="string"==typeof o?o:o[0],c="string"==typeof o?null:o[1],s=-1!==t.indexOf(a),(i||s)&&(e.severity=n),s&&c&&(e.description=c)}function t(e){for(var r=e.description,n=0;n<a.length;n++)if(-1!==r.indexOf(a[n]))return!0;return!1}function o(r,i){for(var t=0;t<r.length;t++){var o=r[t];if(o){var a,c;if(a=[],o.evidence){var s=a[o.line];if(!s){var f=o.evidence;s=[],Array.prototype.forEach.call(f,function(e,r){" "===e&&s.push(r+1)}),a[o.line]=s}if(s.length>0){var d=o.character;s.forEach(function(e){d>e&&(d-=1)}),o.character=d}}var u=o.character-1,l=u+1;o.evidence&&(c=o.evidence.substring(u).search(/.\b/),c>-1&&(l+=c)),o.description=o.reason,o.start=o.character,o.end=l,o=n(o),o&&i.push({message:o.description,severity:o.severity,from:e.Pos(o.line-1,u),to:e.Pos(o.line-1,l)})}}}var a=["Dangerous comment"],c=[["Expected '{'","Statement body should be inside '{ }' braces."]],s=["Missing semicolon","Extra comma","Missing property name","Unmatched "," and instead saw"," is not defined","Unclosed string","Stopping, unable to continue"];e.registerHelper("lint","javascript",r)});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/lint/json-lint.min.js
CHANGED
@@ -1,7 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.registerHelper("lint","json",function(text){var found=[];jsonlint.parseError=function(str,hash){var loc=hash.loc;found.push({from:CodeMirror.Pos(loc.first_line-1,loc.first_column),to:CodeMirror.Pos(loc.last_line-1,loc.last_column),message:str});};try{jsonlint.parse(text);}
|
6 |
-
catch(e){}
|
7 |
-
return found;});});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("lint","json",function(o){var r=[];jsonlint.parseError=function(o,t){var n=t.loc;r.push({from:e.Pos(n.first_line-1,n.first_column),to:e.Pos(n.last_line-1,n.last_column),message:o})};try{jsonlint.parse(o)}catch(t){}return r})});
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/lint/lint.min.js
CHANGED
@@ -1,34 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";var GUTTER_ID="CodeMirror-lint-markers";function showTooltip(e,content){var tt=document.createElement("div");tt.className="CodeMirror-lint-tooltip";tt.appendChild(content.cloneNode(true));document.body.appendChild(tt);function position(e){if(!tt.parentNode)return CodeMirror.off(document,"mousemove",position);tt.style.top=Math.max(0,e.clientY-tt.offsetHeight-5)+"px";tt.style.left=(e.clientX+5)+"px";}
|
6 |
-
CodeMirror.on(document,"mousemove",position);position(e);if(tt.style.opacity!=null)tt.style.opacity=1;return tt;}
|
7 |
-
function rm(elt){if(elt.parentNode)elt.parentNode.removeChild(elt);}
|
8 |
-
function hideTooltip(tt){if(!tt.parentNode)return;if(tt.style.opacity==null)rm(tt);tt.style.opacity=0;setTimeout(function(){rm(tt);},600);}
|
9 |
-
function showTooltipFor(e,content,node){var tooltip=showTooltip(e,content);function hide(){CodeMirror.off(node,"mouseout",hide);if(tooltip){hideTooltip(tooltip);tooltip=null;}}
|
10 |
-
var poll=setInterval(function(){if(tooltip)for(var n=node;;n=n.parentNode){if(n&&n.nodeType==11)n=n.host;if(n==document.body)return;if(!n){hide();break;}}
|
11 |
-
if(!tooltip)return clearInterval(poll);},400);CodeMirror.on(node,"mouseout",hide);}
|
12 |
-
function LintState(cm,options,hasGutter){this.marked=[];this.options=options;this.timeout=null;this.hasGutter=hasGutter;this.onMouseOver=function(e){onMouseOver(cm,e);};}
|
13 |
-
function parseOptions(cm,options){if(options instanceof Function)return{getAnnotations:options};if(!options||options===true)options={};if(!options.getAnnotations)options.getAnnotations=cm.getHelper(CodeMirror.Pos(0,0),"lint");if(!options.getAnnotations)throw new Error("Required option 'getAnnotations' missing (lint addon)");return options;}
|
14 |
-
function clearMarks(cm){var state=cm.state.lint;if(state.hasGutter)cm.clearGutter(GUTTER_ID);for(var i=0;i<state.marked.length;++i)
|
15 |
-
state.marked[i].clear();state.marked.length=0;}
|
16 |
-
function makeMarker(labels,severity,multiple,tooltips){var marker=document.createElement("div"),inner=marker;marker.className="CodeMirror-lint-marker-"+severity;if(multiple){inner=marker.appendChild(document.createElement("div"));inner.className="CodeMirror-lint-marker-multiple";}
|
17 |
-
if(tooltips!=false)CodeMirror.on(inner,"mouseover",function(e){showTooltipFor(e,labels,inner);});return marker;}
|
18 |
-
function getMaxSeverity(a,b){if(a=="error")return a;else return b;}
|
19 |
-
function groupByLine(annotations){var lines=[];for(var i=0;i<annotations.length;++i){var ann=annotations[i],line=ann.from.line;(lines[line]||(lines[line]=[])).push(ann);}
|
20 |
-
return lines;}
|
21 |
-
function annotationTooltip(ann){var severity=ann.severity;if(!severity)severity="error";var tip=document.createElement("div");tip.className="CodeMirror-lint-message-"+severity;tip.appendChild(document.createTextNode(ann.message));return tip;}
|
22 |
-
function startLinting(cm){var state=cm.state.lint,options=state.options;var passOptions=options.options||options;if(options.async||options.getAnnotations.async)
|
23 |
-
options.getAnnotations(cm.getValue(),updateLinting,passOptions,cm);else
|
24 |
-
updateLinting(cm,options.getAnnotations(cm.getValue(),passOptions,cm));}
|
25 |
-
function updateLinting(cm,annotationsNotSorted){clearMarks(cm);var state=cm.state.lint,options=state.options;var annotations=groupByLine(annotationsNotSorted);for(var line=0;line<annotations.length;++line){var anns=annotations[line];if(!anns)continue;var maxSeverity=null;var tipLabel=state.hasGutter&&document.createDocumentFragment();for(var i=0;i<anns.length;++i){var ann=anns[i];var severity=ann.severity;if(!severity)severity="error";maxSeverity=getMaxSeverity(maxSeverity,severity);if(options.formatAnnotation)ann=options.formatAnnotation(ann);if(state.hasGutter)tipLabel.appendChild(annotationTooltip(ann));if(ann.to)state.marked.push(cm.markText(ann.from,ann.to,{className:"CodeMirror-lint-mark-"+severity,__annotation:ann}));}
|
26 |
-
if(state.hasGutter)
|
27 |
-
cm.setGutterMarker(line,GUTTER_ID,makeMarker(tipLabel,maxSeverity,anns.length>1,state.options.tooltips));}
|
28 |
-
if(options.onUpdateLinting)options.onUpdateLinting(annotationsNotSorted,annotations,cm);}
|
29 |
-
function onChange(cm){var state=cm.state.lint;if(!state)return;clearTimeout(state.timeout);state.timeout=setTimeout(function(){startLinting(cm);},state.options.delay||500);}
|
30 |
-
function popupSpanTooltip(ann,e){var target=e.target||e.srcElement;showTooltipFor(e,annotationTooltip(ann),target);}
|
31 |
-
function onMouseOver(cm,e){var target=e.target||e.srcElement;if(!/\bCodeMirror-lint-mark-/.test(target.className))return;var box=target.getBoundingClientRect(),x=(box.left+box.right)/2,y=(box.top+box.bottom)/2;var spans=cm.findMarksAt(cm.coordsChar({left:x,top:y},"client"));for(var i=0;i<spans.length;++i){var ann=spans[i].__annotation;if(ann)return popupSpanTooltip(ann,e);}}
|
32 |
-
CodeMirror.defineOption("lint",false,function(cm,val,old){if(old&&old!=CodeMirror.Init){clearMarks(cm);cm.off("change",onChange);CodeMirror.off(cm.getWrapperElement(),"mouseover",cm.state.lint.onMouseOver);clearTimeout(cm.state.lint.timeout);delete cm.state.lint;}
|
33 |
-
if(val){var gutters=cm.getOption("gutters"),hasLintGutter=false;for(var i=0;i<gutters.length;++i)if(gutters[i]==GUTTER_ID)hasLintGutter=true;var state=cm.state.lint=new LintState(cm,parseOptions(cm,val),hasLintGutter);cm.on("change",onChange);if(state.options.tooltips!=false)
|
34 |
-
CodeMirror.on(cm.getWrapperElement(),"mouseover",state.onMouseOver);startLinting(cm);}});});
|
1 |
+
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";function e(e,n){function o(e){return r.parentNode?(r.style.top=Math.max(0,e.clientY-r.offsetHeight-5)+"px",void(r.style.left=e.clientX+5+"px")):t.off(document,"mousemove",o)}var r=document.createElement("div");return r.className="CodeMirror-lint-tooltip",r.appendChild(n.cloneNode(!0)),document.body.appendChild(r),t.on(document,"mousemove",o),o(e),null!=r.style.opacity&&(r.style.opacity=1),r}function n(t){t.parentNode&&t.parentNode.removeChild(t)}function o(t){t.parentNode&&(null==t.style.opacity&&n(t),t.style.opacity=0,setTimeout(function(){n(t)},600))}function r(n,r,i){function a(){t.off(i,"mouseout",a),s&&(o(s),s=null)}var s=e(n,r),u=setInterval(function(){if(s)for(var t=i;;t=t.parentNode){if(t&&11==t.nodeType&&(t=t.host),t==document.body)return;if(!t){a();break}}return s?void 0:clearInterval(u)},400);t.on(i,"mouseout",a)}function i(t,e,n){this.marked=[],this.options=e,this.timeout=null,this.hasGutter=n,this.onMouseOver=function(e){g(t,e)}}function a(e,n){if(n instanceof Function)return{getAnnotations:n};if(n&&n!==!0||(n={}),n.getAnnotations||(n.getAnnotations=e.getHelper(t.Pos(0,0),"lint")),!n.getAnnotations)throw new Error("Required option 'getAnnotations' missing (lint addon)");return n}function s(t){var e=t.state.lint;e.hasGutter&&t.clearGutter(h);for(var n=0;n<e.marked.length;++n)e.marked[n].clear();e.marked.length=0}function u(e,n,o,i){var a=document.createElement("div"),s=a;return a.className="CodeMirror-lint-marker-"+n,o&&(s=a.appendChild(document.createElement("div")),s.className="CodeMirror-lint-marker-multiple"),0!=i&&t.on(s,"mouseover",function(t){r(t,e,s)}),a}function l(t,e){return"error"==t?t:e}function c(t){for(var e=[],n=0;n<t.length;++n){var o=t[n],r=o.from.line;(e[r]||(e[r]=[])).push(o)}return e}function f(t){var e=t.severity;e||(e="error");var n=document.createElement("div");return n.className="CodeMirror-lint-message-"+e,n.appendChild(document.createTextNode(t.message)),n}function m(t){var e=t.state.lint,n=e.options,o=n.options||n;n.async||n.getAnnotations.async?n.getAnnotations(t.getValue(),d,o,t):d(t,n.getAnnotations(t.getValue(),o,t))}function d(t,e){s(t);for(var n=t.state.lint,o=n.options,r=c(e),i=0;i<r.length;++i){var a=r[i];if(a){for(var m=null,d=n.hasGutter&&document.createDocumentFragment(),p=0;p<a.length;++p){var v=a[p],g=v.severity;g||(g="error"),m=l(m,g),o.formatAnnotation&&(v=o.formatAnnotation(v)),n.hasGutter&&d.appendChild(f(v)),v.to&&n.marked.push(t.markText(v.from,v.to,{className:"CodeMirror-lint-mark-"+g,__annotation:v}))}n.hasGutter&&t.setGutterMarker(i,h,u(d,m,a.length>1,n.options.tooltips))}}o.onUpdateLinting&&o.onUpdateLinting(e,r,t)}function p(t){var e=t.state.lint;e&&(clearTimeout(e.timeout),e.timeout=setTimeout(function(){m(t)},e.options.delay||500))}function v(t,e){var n=e.target||e.srcElement;r(e,f(t),n)}function g(t,e){var n=e.target||e.srcElement;if(/\bCodeMirror-lint-mark-/.test(n.className))for(var o=n.getBoundingClientRect(),r=(o.left+o.right)/2,i=(o.top+o.bottom)/2,a=t.findMarksAt(t.coordsChar({left:r,top:i},"client")),s=0;s<a.length;++s){var u=a[s].__annotation;if(u)return v(u,e)}}var h="CodeMirror-lint-markers";t.defineOption("lint",!1,function(e,n,o){if(o&&o!=t.Init&&(s(e),e.off("change",p),t.off(e.getWrapperElement(),"mouseover",e.state.lint.onMouseOver),clearTimeout(e.state.lint.timeout),delete e.state.lint),n){for(var r=e.getOption("gutters"),u=!1,l=0;l<r.length;++l)r[l]==h&&(u=!0);var c=e.state.lint=new i(e,a(e,n),u);e.on("change",p),0!=c.options.tooltips&&t.on(e.getWrapperElement(),"mouseover",c.onMouseOver),m(e)}})});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/lint/yaml-lint.min.js
CHANGED
@@ -1,7 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.registerHelper("lint","yaml",function(text){var found=[];try{jsyaml.load(text);}
|
6 |
-
catch(e){var loc=e.mark;found.push({from:CodeMirror.Pos(loc.line,loc.column),to:CodeMirror.Pos(loc.line,loc.column),message:e.message});}
|
7 |
-
return found;});});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("lint","yaml",function(o){var r=[];try{jsyaml.load(o)}catch(i){var t=i.mark;r.push({from:e.Pos(t.line,t.column),to:e.Pos(t.line,t.column),message:i.message})}return r})});
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/addon/merge/merge.min.js
CHANGED
@@ -1,109 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"),require("diff_match_patch"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror","diff_match_patch"],mod);else
|
5 |
-
mod(CodeMirror,diff_match_patch);})(function(CodeMirror,diff_match_patch){"use strict";var Pos=CodeMirror.Pos;var svgNS="http://www.w3.org/2000/svg";function DiffView(mv,type){this.mv=mv;this.type=type;this.classes=type=="left"?{chunk:"CodeMirror-merge-l-chunk",start:"CodeMirror-merge-l-chunk-start",end:"CodeMirror-merge-l-chunk-end",insert:"CodeMirror-merge-l-inserted",del:"CodeMirror-merge-l-deleted",connect:"CodeMirror-merge-l-connect"}:{chunk:"CodeMirror-merge-r-chunk",start:"CodeMirror-merge-r-chunk-start",end:"CodeMirror-merge-r-chunk-end",insert:"CodeMirror-merge-r-inserted",del:"CodeMirror-merge-r-deleted",connect:"CodeMirror-merge-r-connect"};}
|
6 |
-
DiffView.prototype={constructor:DiffView,init:function(pane,orig,options){this.edit=this.mv.edit;(this.edit.state.diffViews||(this.edit.state.diffViews=[])).push(this);this.orig=CodeMirror(pane,copyObj({value:orig,readOnly:!this.mv.options.allowEditingOriginals},copyObj(options)));this.orig.state.diffViews=[this];this.diff=getDiff(asString(orig),asString(options.value));this.chunks=getChunks(this.diff);this.diffOutOfDate=this.dealigned=false;this.showDifferences=options.showDifferences!==false;this.forceUpdate=registerUpdate(this);setScrollLock(this,true,false);registerScroll(this);},setShowDifferences:function(val){val=val!==false;if(val!=this.showDifferences){this.showDifferences=val;this.forceUpdate("full");}}};function ensureDiff(dv){if(dv.diffOutOfDate){dv.diff=getDiff(dv.orig.getValue(),dv.edit.getValue());dv.chunks=getChunks(dv.diff);dv.diffOutOfDate=false;CodeMirror.signal(dv.edit,"updateDiff",dv.diff);}}
|
7 |
-
var updating=false;function registerUpdate(dv){var edit={from:0,to:0,marked:[]};var orig={from:0,to:0,marked:[]};var debounceChange,updatingFast=false;function update(mode){updating=true;updatingFast=false;if(mode=="full"){if(dv.svg)clear(dv.svg);if(dv.copyButtons)clear(dv.copyButtons);clearMarks(dv.edit,edit.marked,dv.classes);clearMarks(dv.orig,orig.marked,dv.classes);edit.from=edit.to=orig.from=orig.to=0;}
|
8 |
-
ensureDiff(dv);if(dv.showDifferences){updateMarks(dv.edit,dv.diff,edit,DIFF_INSERT,dv.classes);updateMarks(dv.orig,dv.diff,orig,DIFF_DELETE,dv.classes);}
|
9 |
-
makeConnections(dv);if(dv.mv.options.connect=="align")
|
10 |
-
alignChunks(dv);updating=false;}
|
11 |
-
function setDealign(fast){if(updating)return;dv.dealigned=true;set(fast);}
|
12 |
-
function set(fast){if(updating||updatingFast)return;clearTimeout(debounceChange);if(fast===true)updatingFast=true;debounceChange=setTimeout(update,fast===true?20:250);}
|
13 |
-
function change(_cm,change){if(!dv.diffOutOfDate){dv.diffOutOfDate=true;edit.from=edit.to=orig.from=orig.to=0;}
|
14 |
-
setDealign(change.text.length-1!=change.to.line-change.from.line);}
|
15 |
-
dv.edit.on("change",change);dv.orig.on("change",change);dv.edit.on("markerAdded",setDealign);dv.edit.on("markerCleared",setDealign);dv.orig.on("markerAdded",setDealign);dv.orig.on("markerCleared",setDealign);dv.edit.on("viewportChange",function(){set(false);});dv.orig.on("viewportChange",function(){set(false);});update();return update;}
|
16 |
-
function registerScroll(dv){dv.edit.on("scroll",function(){syncScroll(dv,DIFF_INSERT)&&makeConnections(dv);});dv.orig.on("scroll",function(){syncScroll(dv,DIFF_DELETE)&&makeConnections(dv);});}
|
17 |
-
function syncScroll(dv,type){if(dv.diffOutOfDate)return false;if(!dv.lockScroll)return true;var editor,other,now=+new Date;if(type==DIFF_INSERT){editor=dv.edit;other=dv.orig;}
|
18 |
-
else{editor=dv.orig;other=dv.edit;}
|
19 |
-
if(editor.state.scrollSetBy==dv&&(editor.state.scrollSetAt||0)+50>now)return false;var sInfo=editor.getScrollInfo();if(dv.mv.options.connect=="align"){targetPos=sInfo.top;}else{var halfScreen=.5*sInfo.clientHeight,midY=sInfo.top+halfScreen;var mid=editor.lineAtHeight(midY,"local");var around=chunkBoundariesAround(dv.chunks,mid,type==DIFF_INSERT);var off=getOffsets(editor,type==DIFF_INSERT?around.edit:around.orig);var offOther=getOffsets(other,type==DIFF_INSERT?around.orig:around.edit);var ratio=(midY-off.top)/(off.bot-off.top);var targetPos=(offOther.top-halfScreen)+ratio*(offOther.bot-offOther.top);var botDist,mix;if(targetPos>sInfo.top&&(mix=sInfo.top/halfScreen)<1){targetPos=targetPos*mix+sInfo.top*(1-mix);}else if((botDist=sInfo.height-sInfo.clientHeight-sInfo.top)<halfScreen){var otherInfo=other.getScrollInfo();var botDistOther=otherInfo.height-otherInfo.clientHeight-targetPos;if(botDistOther>botDist&&(mix=botDist/halfScreen)<1)
|
20 |
-
targetPos=targetPos*mix+(otherInfo.height-otherInfo.clientHeight-botDist)*(1-mix);}}
|
21 |
-
other.scrollTo(sInfo.left,targetPos);other.state.scrollSetAt=now;other.state.scrollSetBy=dv;return true;}
|
22 |
-
function getOffsets(editor,around){var bot=around.after;if(bot==null)bot=editor.lastLine()+1;return{top:editor.heightAtLine(around.before||0,"local"),bot:editor.heightAtLine(bot,"local")};}
|
23 |
-
function setScrollLock(dv,val,action){dv.lockScroll=val;if(val&&action!=false)syncScroll(dv,DIFF_INSERT)&&makeConnections(dv);dv.lockButton.innerHTML=val?"\u21db\u21da":"\u21db \u21da";}
|
24 |
-
function clearMarks(editor,arr,classes){for(var i=0;i<arr.length;++i){var mark=arr[i];if(mark instanceof CodeMirror.TextMarker){mark.clear();}else if(mark.parent){editor.removeLineClass(mark,"background",classes.chunk);editor.removeLineClass(mark,"background",classes.start);editor.removeLineClass(mark,"background",classes.end);}}
|
25 |
-
arr.length=0;}
|
26 |
-
function updateMarks(editor,diff,state,type,classes){var vp=editor.getViewport();editor.operation(function(){if(state.from==state.to||vp.from-state.to>20||state.from-vp.to>20){clearMarks(editor,state.marked,classes);markChanges(editor,diff,type,state.marked,vp.from,vp.to,classes);state.from=vp.from;state.to=vp.to;}else{if(vp.from<state.from){markChanges(editor,diff,type,state.marked,vp.from,state.from,classes);state.from=vp.from;}
|
27 |
-
if(vp.to>state.to){markChanges(editor,diff,type,state.marked,state.to,vp.to,classes);state.to=vp.to;}}});}
|
28 |
-
function markChanges(editor,diff,type,marks,from,to,classes){var pos=Pos(0,0);var top=Pos(from,0),bot=editor.clipPos(Pos(to-1));var cls=type==DIFF_DELETE?classes.del:classes.insert;function markChunk(start,end){var bfrom=Math.max(from,start),bto=Math.min(to,end);for(var i=bfrom;i<bto;++i){var line=editor.addLineClass(i,"background",classes.chunk);if(i==start)editor.addLineClass(line,"background",classes.start);if(i==end-1)editor.addLineClass(line,"background",classes.end);marks.push(line);}
|
29 |
-
if(start==end&&bfrom==end&&bto==end){if(bfrom)
|
30 |
-
marks.push(editor.addLineClass(bfrom-1,"background",classes.end));else
|
31 |
-
marks.push(editor.addLineClass(bfrom,"background",classes.start));}}
|
32 |
-
var chunkStart=0;for(var i=0;i<diff.length;++i){var part=diff[i],tp=part[0],str=part[1];if(tp==DIFF_EQUAL){var cleanFrom=pos.line+(startOfLineClean(diff,i)?0:1);moveOver(pos,str);var cleanTo=pos.line+(endOfLineClean(diff,i)?1:0);if(cleanTo>cleanFrom){if(i)markChunk(chunkStart,cleanFrom);chunkStart=cleanTo;}}else{if(tp==type){var end=moveOver(pos,str,true);var a=posMax(top,pos),b=posMin(bot,end);if(!posEq(a,b))
|
33 |
-
marks.push(editor.markText(a,b,{className:cls}));pos=end;}}}
|
34 |
-
if(chunkStart<=pos.line)markChunk(chunkStart,pos.line+1);}
|
35 |
-
function makeConnections(dv){if(!dv.showDifferences)return;if(dv.svg){clear(dv.svg);var w=dv.gap.offsetWidth;attrs(dv.svg,"width",w,"height",dv.gap.offsetHeight);}
|
36 |
-
if(dv.copyButtons)clear(dv.copyButtons);var vpEdit=dv.edit.getViewport(),vpOrig=dv.orig.getViewport();var sTopEdit=dv.edit.getScrollInfo().top,sTopOrig=dv.orig.getScrollInfo().top;for(var i=0;i<dv.chunks.length;i++){var ch=dv.chunks[i];if(ch.editFrom<=vpEdit.to&&ch.editTo>=vpEdit.from&&ch.origFrom<=vpOrig.to&&ch.origTo>=vpOrig.from)
|
37 |
-
drawConnectorsForChunk(dv,ch,sTopOrig,sTopEdit,w);}}
|
38 |
-
function getMatchingOrigLine(editLine,chunks){var editStart=0,origStart=0;for(var i=0;i<chunks.length;i++){var chunk=chunks[i];if(chunk.editTo>editLine&&chunk.editFrom<=editLine)return null;if(chunk.editFrom>editLine)break;editStart=chunk.editTo;origStart=chunk.origTo;}
|
39 |
-
return origStart+(editLine-editStart);}
|
40 |
-
function findAlignedLines(dv,other){var linesToAlign=[];for(var i=0;i<dv.chunks.length;i++){var chunk=dv.chunks[i];linesToAlign.push([chunk.origTo,chunk.editTo,other?getMatchingOrigLine(chunk.editTo,other.chunks):null]);}
|
41 |
-
if(other){for(var i=0;i<other.chunks.length;i++){var chunk=other.chunks[i];for(var j=0;j<linesToAlign.length;j++){var align=linesToAlign[j];if(align[1]==chunk.editTo){j=-1;break;}else if(align[1]>chunk.editTo){break;}}
|
42 |
-
if(j>-1)
|
43 |
-
linesToAlign.splice(j-1,0,[getMatchingOrigLine(chunk.editTo,dv.chunks),chunk.editTo,chunk.origTo]);}}
|
44 |
-
return linesToAlign;}
|
45 |
-
function alignChunks(dv,force){if(!dv.dealigned&&!force)return;if(!dv.orig.curOp)return dv.orig.operation(function(){alignChunks(dv,force);});dv.dealigned=false;var other=dv.mv.left==dv?dv.mv.right:dv.mv.left;if(other){ensureDiff(other);other.dealigned=false;}
|
46 |
-
var linesToAlign=findAlignedLines(dv,other);var aligners=dv.mv.aligners;for(var i=0;i<aligners.length;i++)
|
47 |
-
aligners[i].clear();aligners.length=0;var cm=[dv.orig,dv.edit],scroll=[];if(other)cm.push(other.orig);for(var i=0;i<cm.length;i++)
|
48 |
-
scroll.push(cm[i].getScrollInfo().top);for(var ln=0;ln<linesToAlign.length;ln++)
|
49 |
-
alignLines(cm,linesToAlign[ln],aligners);for(var i=0;i<cm.length;i++)
|
50 |
-
cm[i].scrollTo(null,scroll[i]);}
|
51 |
-
function alignLines(cm,lines,aligners){var maxOffset=0,offset=[];for(var i=0;i<cm.length;i++)if(lines[i]!=null){var off=cm[i].heightAtLine(lines[i],"local");offset[i]=off;maxOffset=Math.max(maxOffset,off);}
|
52 |
-
for(var i=0;i<cm.length;i++)if(lines[i]!=null){var diff=maxOffset-offset[i];if(diff>1)
|
53 |
-
aligners.push(padAbove(cm[i],lines[i],diff));}}
|
54 |
-
function padAbove(cm,line,size){var above=true;if(line>cm.lastLine()){line--;above=false;}
|
55 |
-
var elt=document.createElement("div");elt.className="CodeMirror-merge-spacer";elt.style.height=size+"px";elt.style.minWidth="1px";return cm.addLineWidget(line,elt,{height:size,above:above});}
|
56 |
-
function drawConnectorsForChunk(dv,chunk,sTopOrig,sTopEdit,w){var flip=dv.type=="left";var top=dv.orig.heightAtLine(chunk.origFrom,"local")-sTopOrig;if(dv.svg){var topLpx=top;var topRpx=dv.edit.heightAtLine(chunk.editFrom,"local")-sTopEdit;if(flip){var tmp=topLpx;topLpx=topRpx;topRpx=tmp;}
|
57 |
-
var botLpx=dv.orig.heightAtLine(chunk.origTo,"local")-sTopOrig;var botRpx=dv.edit.heightAtLine(chunk.editTo,"local")-sTopEdit;if(flip){var tmp=botLpx;botLpx=botRpx;botRpx=tmp;}
|
58 |
-
var curveTop=" C "+w/2+" "+topRpx+" "+w/2+" "+topLpx+" "+(w+2)+" "+topLpx;var curveBot=" C "+w/2+" "+botLpx+" "+w/2+" "+botRpx+" -1 "+botRpx;attrs(dv.svg.appendChild(document.createElementNS(svgNS,"path")),"d","M -1 "+topRpx+curveTop+" L "+(w+2)+" "+botLpx+curveBot+" z","class",dv.classes.connect);}
|
59 |
-
if(dv.copyButtons){var copy=dv.copyButtons.appendChild(elt("div",dv.type=="left"?"\u21dd":"\u21dc","CodeMirror-merge-copy"));var editOriginals=dv.mv.options.allowEditingOriginals;copy.title=editOriginals?"Push to left":"Revert chunk";copy.chunk=chunk;copy.style.top=top+"px";if(editOriginals){var topReverse=dv.orig.heightAtLine(chunk.editFrom,"local")-sTopEdit;var copyReverse=dv.copyButtons.appendChild(elt("div",dv.type=="right"?"\u21dd":"\u21dc","CodeMirror-merge-copy-reverse"));copyReverse.title="Push to right";copyReverse.chunk={editFrom:chunk.origFrom,editTo:chunk.origTo,origFrom:chunk.editFrom,origTo:chunk.editTo};copyReverse.style.top=topReverse+"px";dv.type=="right"?copyReverse.style.left="2px":copyReverse.style.right="2px";}}}
|
60 |
-
function copyChunk(dv,to,from,chunk){if(dv.diffOutOfDate)return;to.replaceRange(from.getRange(Pos(chunk.origFrom,0),Pos(chunk.origTo,0)),Pos(chunk.editFrom,0),Pos(chunk.editTo,0));}
|
61 |
-
var MergeView=CodeMirror.MergeView=function(node,options){if(!(this instanceof MergeView))return new MergeView(node,options);this.options=options;var origLeft=options.origLeft,origRight=options.origRight==null?options.orig:options.origRight;var hasLeft=origLeft!=null,hasRight=origRight!=null;var panes=1+(hasLeft?1:0)+(hasRight?1:0);var wrap=[],left=this.left=null,right=this.right=null;var self=this;if(hasLeft){left=this.left=new DiffView(this,"left");var leftPane=elt("div",null,"CodeMirror-merge-pane");wrap.push(leftPane);wrap.push(buildGap(left));}
|
62 |
-
var editPane=elt("div",null,"CodeMirror-merge-pane");wrap.push(editPane);if(hasRight){right=this.right=new DiffView(this,"right");wrap.push(buildGap(right));var rightPane=elt("div",null,"CodeMirror-merge-pane");wrap.push(rightPane);}
|
63 |
-
(hasRight?rightPane:editPane).className+=" CodeMirror-merge-pane-rightmost";wrap.push(elt("div",null,null,"height: 0; clear: both;"));var wrapElt=this.wrap=node.appendChild(elt("div",wrap,"CodeMirror-merge CodeMirror-merge-"+panes+"pane"));this.edit=CodeMirror(editPane,copyObj(options));if(left)left.init(leftPane,origLeft,options);if(right)right.init(rightPane,origRight,options);if(options.collapseIdentical){updating=true;this.editor().operation(function(){collapseIdenticalStretches(self,options.collapseIdentical);});updating=false;}
|
64 |
-
if(options.connect=="align"){this.aligners=[];alignChunks(this.left||this.right,true);}
|
65 |
-
var onResize=function(){if(left)makeConnections(left);if(right)makeConnections(right);};CodeMirror.on(window,"resize",onResize);var resizeInterval=setInterval(function(){for(var p=wrapElt.parentNode;p&&p!=document.body;p=p.parentNode){}
|
66 |
-
if(!p){clearInterval(resizeInterval);CodeMirror.off(window,"resize",onResize);}},5000);};function buildGap(dv){var lock=dv.lockButton=elt("div",null,"CodeMirror-merge-scrolllock");lock.title="Toggle locked scrolling";var lockWrap=elt("div",[lock],"CodeMirror-merge-scrolllock-wrap");CodeMirror.on(lock,"click",function(){setScrollLock(dv,!dv.lockScroll);});var gapElts=[lockWrap];if(dv.mv.options.revertButtons!==false){dv.copyButtons=elt("div",null,"CodeMirror-merge-copybuttons-"+dv.type);CodeMirror.on(dv.copyButtons,"click",function(e){var node=e.target||e.srcElement;if(!node.chunk)return;if(node.className=="CodeMirror-merge-copy-reverse"){copyChunk(dv,dv.orig,dv.edit,node.chunk);return;}
|
67 |
-
copyChunk(dv,dv.edit,dv.orig,node.chunk);});gapElts.unshift(dv.copyButtons);}
|
68 |
-
if(dv.mv.options.connect!="align"){var svg=document.createElementNS&&document.createElementNS(svgNS,"svg");if(svg&&!svg.createSVGRect)svg=null;dv.svg=svg;if(svg)gapElts.push(svg);}
|
69 |
-
return dv.gap=elt("div",gapElts,"CodeMirror-merge-gap");}
|
70 |
-
MergeView.prototype={constuctor:MergeView,editor:function(){return this.edit;},rightOriginal:function(){return this.right&&this.right.orig;},leftOriginal:function(){return this.left&&this.left.orig;},setShowDifferences:function(val){if(this.right)this.right.setShowDifferences(val);if(this.left)this.left.setShowDifferences(val);},rightChunks:function(){if(this.right){ensureDiff(this.right);return this.right.chunks;}},leftChunks:function(){if(this.left){ensureDiff(this.left);return this.left.chunks;}}};function asString(obj){if(typeof obj=="string")return obj;else return obj.getValue();}
|
71 |
-
var dmp=new diff_match_patch();function getDiff(a,b){var diff=dmp.diff_main(a,b);dmp.diff_cleanupSemantic(diff);for(var i=0;i<diff.length;++i){var part=diff[i];if(!part[1]){diff.splice(i--,1);}else if(i&&diff[i-1][0]==part[0]){diff.splice(i--,1);diff[i][1]+=part[1];}}
|
72 |
-
return diff;}
|
73 |
-
function getChunks(diff){var chunks=[];var startEdit=0,startOrig=0;var edit=Pos(0,0),orig=Pos(0,0);for(var i=0;i<diff.length;++i){var part=diff[i],tp=part[0];if(tp==DIFF_EQUAL){var startOff=startOfLineClean(diff,i)?0:1;var cleanFromEdit=edit.line+startOff,cleanFromOrig=orig.line+startOff;moveOver(edit,part[1],null,orig);var endOff=endOfLineClean(diff,i)?1:0;var cleanToEdit=edit.line+endOff,cleanToOrig=orig.line+endOff;if(cleanToEdit>cleanFromEdit){if(i)chunks.push({origFrom:startOrig,origTo:cleanFromOrig,editFrom:startEdit,editTo:cleanFromEdit});startEdit=cleanToEdit;startOrig=cleanToOrig;}}else{moveOver(tp==DIFF_INSERT?edit:orig,part[1]);}}
|
74 |
-
if(startEdit<=edit.line||startOrig<=orig.line)
|
75 |
-
chunks.push({origFrom:startOrig,origTo:orig.line+1,editFrom:startEdit,editTo:edit.line+1});return chunks;}
|
76 |
-
function endOfLineClean(diff,i){if(i==diff.length-1)return true;var next=diff[i+1][1];if(next.length==1||next.charCodeAt(0)!=10)return false;if(i==diff.length-2)return true;next=diff[i+2][1];return next.length>1&&next.charCodeAt(0)==10;}
|
77 |
-
function startOfLineClean(diff,i){if(i==0)return true;var last=diff[i-1][1];if(last.charCodeAt(last.length-1)!=10)return false;if(i==1)return true;last=diff[i-2][1];return last.charCodeAt(last.length-1)==10;}
|
78 |
-
function chunkBoundariesAround(chunks,n,nInEdit){var beforeE,afterE,beforeO,afterO;for(var i=0;i<chunks.length;i++){var chunk=chunks[i];var fromLocal=nInEdit?chunk.editFrom:chunk.origFrom;var toLocal=nInEdit?chunk.editTo:chunk.origTo;if(afterE==null){if(fromLocal>n){afterE=chunk.editFrom;afterO=chunk.origFrom;}
|
79 |
-
else if(toLocal>n){afterE=chunk.editTo;afterO=chunk.origTo;}}
|
80 |
-
if(toLocal<=n){beforeE=chunk.editTo;beforeO=chunk.origTo;}
|
81 |
-
else if(fromLocal<=n){beforeE=chunk.editFrom;beforeO=chunk.origFrom;}}
|
82 |
-
return{edit:{before:beforeE,after:afterE},orig:{before:beforeO,after:afterO}};}
|
83 |
-
function collapseSingle(cm,from,to){cm.addLineClass(from,"wrap","CodeMirror-merge-collapsed-line");var widget=document.createElement("span");widget.className="CodeMirror-merge-collapsed-widget";widget.title="Identical text collapsed. Click to expand.";var mark=cm.markText(Pos(from,0),Pos(to-1),{inclusiveLeft:true,inclusiveRight:true,replacedWith:widget,clearOnEnter:true});function clear(){mark.clear();cm.removeLineClass(from,"wrap","CodeMirror-merge-collapsed-line");}
|
84 |
-
widget.addEventListener("click",clear);return{mark:mark,clear:clear};}
|
85 |
-
function collapseStretch(size,editors){var marks=[];function clear(){for(var i=0;i<marks.length;i++)marks[i].clear();}
|
86 |
-
for(var i=0;i<editors.length;i++){var editor=editors[i];var mark=collapseSingle(editor.cm,editor.line,editor.line+size);marks.push(mark);mark.mark.on("clear",clear);}
|
87 |
-
return marks[0].mark;}
|
88 |
-
function unclearNearChunks(dv,margin,off,clear){for(var i=0;i<dv.chunks.length;i++){var chunk=dv.chunks[i];for(var l=chunk.editFrom-margin;l<chunk.editTo+margin;l++){var pos=l+off;if(pos>=0&&pos<clear.length)clear[pos]=false;}}}
|
89 |
-
function collapseIdenticalStretches(mv,margin){if(typeof margin!="number")margin=2;var clear=[],edit=mv.editor(),off=edit.firstLine();for(var l=off,e=edit.lastLine();l<=e;l++)clear.push(true);if(mv.left)unclearNearChunks(mv.left,margin,off,clear);if(mv.right)unclearNearChunks(mv.right,margin,off,clear);for(var i=0;i<clear.length;i++){if(clear[i]){var line=i+off;for(var size=1;i<clear.length-1&&clear[i+1];i++,size++){}
|
90 |
-
if(size>margin){var editors=[{line:line,cm:edit}];if(mv.left)editors.push({line:getMatchingOrigLine(line,mv.left.chunks),cm:mv.left.orig});if(mv.right)editors.push({line:getMatchingOrigLine(line,mv.right.chunks),cm:mv.right.orig});var mark=collapseStretch(size,editors);if(mv.options.onCollapse)mv.options.onCollapse(mv,line,size,mark);}}}}
|
91 |
-
function elt(tag,content,className,style){var e=document.createElement(tag);if(className)e.className=className;if(style)e.style.cssText=style;if(typeof content=="string")e.appendChild(document.createTextNode(content));else if(content)for(var i=0;i<content.length;++i)e.appendChild(content[i]);return e;}
|
92 |
-
function clear(node){for(var count=node.childNodes.length;count>0;--count)
|
93 |
-
node.removeChild(node.firstChild);}
|
94 |
-
function attrs(elt){for(var i=1;i<arguments.length;i+=2)
|
95 |
-
elt.setAttribute(arguments[i],arguments[i+1]);}
|
96 |
-
function copyObj(obj,target){if(!target)target={};for(var prop in obj)if(obj.hasOwnProperty(prop))target[prop]=obj[prop];return target;}
|
97 |
-
function moveOver(pos,str,copy,other){var out=copy?Pos(pos.line,pos.ch):pos,at=0;for(;;){var nl=str.indexOf("\n",at);if(nl==-1)break;++out.line;if(other)++other.line;at=nl+1;}
|
98 |
-
out.ch=(at?0:out.ch)+(str.length-at);if(other)other.ch=(at?0:other.ch)+(str.length-at);return out;}
|
99 |
-
function posMin(a,b){return(a.line-b.line||a.ch-b.ch)<0?a:b;}
|
100 |
-
function posMax(a,b){return(a.line-b.line||a.ch-b.ch)>0?a:b;}
|
101 |
-
function posEq(a,b){return a.line==b.line&&a.ch==b.ch;}
|
102 |
-
function findPrevDiff(chunks,start,isOrig){for(var i=chunks.length-1;i>=0;i--){var chunk=chunks[i];var to=(isOrig?chunk.origTo:chunk.editTo)-1;if(to<start)return to;}}
|
103 |
-
function findNextDiff(chunks,start,isOrig){for(var i=0;i<chunks.length;i++){var chunk=chunks[i];var from=(isOrig?chunk.origFrom:chunk.editFrom);if(from>start)return from;}}
|
104 |
-
function goNearbyDiff(cm,dir){var found=null,views=cm.state.diffViews,line=cm.getCursor().line;if(views)for(var i=0;i<views.length;i++){var dv=views[i],isOrig=cm==dv.orig;ensureDiff(dv);var pos=dir<0?findPrevDiff(dv.chunks,line,isOrig):findNextDiff(dv.chunks,line,isOrig);if(pos!=null&&(found==null||(dir<0?pos>found:pos<found)))
|
105 |
-
found=pos;}
|
106 |
-
if(found!=null)
|
107 |
-
cm.setCursor(found,0);else
|
108 |
-
return CodeMirror.Pass;}
|
109 |
-
CodeMirror.commands.goNextDiff=function(cm){return goNearbyDiff(cm,1);};CodeMirror.commands.goPrevDiff=function(cm){return goNearbyDiff(cm,-1);};});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("diff_match_patch")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","diff_match_patch"],e):e(CodeMirror,diff_match_patch)}(function(e,t){"use strict";function r(e,t){this.mv=e,this.type=t,this.classes="left"==t?{chunk:"CodeMirror-merge-l-chunk",start:"CodeMirror-merge-l-chunk-start",end:"CodeMirror-merge-l-chunk-end",insert:"CodeMirror-merge-l-inserted",del:"CodeMirror-merge-l-deleted",connect:"CodeMirror-merge-l-connect"}:{chunk:"CodeMirror-merge-r-chunk",start:"CodeMirror-merge-r-chunk-start",end:"CodeMirror-merge-r-chunk-end",insert:"CodeMirror-merge-r-inserted",del:"CodeMirror-merge-r-deleted",connect:"CodeMirror-merge-r-connect"}}function i(t){t.diffOutOfDate&&(t.diff=w(t.orig.getValue(),t.edit.getValue()),t.chunks=y(t.diff),t.diffOutOfDate=!1,e.signal(t.edit,"updateDiff",t.diff))}function o(e){function t(t){j=!0,h=!1,"full"==t&&(e.svg&&N(e.svg),e.copyButtons&&N(e.copyButtons),c(e.edit,a.marked,e.classes),c(e.orig,s.marked,e.classes),a.from=a.to=s.from=s.to=0),i(e),e.showDifferences&&(f(e.edit,e.diff,a,DIFF_INSERT,e.classes),f(e.orig,e.diff,s,DIFF_DELETE,e.classes)),d(e),"align"==e.mv.options.connect&&v(e),j=!1}function r(t){j||(e.dealigned=!0,o(t))}function o(e){j||h||(clearTimeout(l),e===!0&&(h=!0),l=setTimeout(t,e===!0?20:250))}function n(t,i){e.diffOutOfDate||(e.diffOutOfDate=!0,a.from=a.to=s.from=s.to=0),r(i.text.length-1!=i.to.line-i.from.line)}var l,a={from:0,to:0,marked:[]},s={from:0,to:0,marked:[]},h=!1;return e.edit.on("change",n),e.orig.on("change",n),e.edit.on("markerAdded",r),e.edit.on("markerCleared",r),e.orig.on("markerAdded",r),e.orig.on("markerCleared",r),e.edit.on("viewportChange",function(){o(!1)}),e.orig.on("viewportChange",function(){o(!1)}),t(),t}function n(e){e.edit.on("scroll",function(){l(e,DIFF_INSERT)&&d(e)}),e.orig.on("scroll",function(){l(e,DIFF_DELETE)&&d(e)})}function l(e,t){if(e.diffOutOfDate)return!1;if(!e.lockScroll)return!0;var r,i,o=+new Date;if(t==DIFF_INSERT?(r=e.edit,i=e.orig):(r=e.orig,i=e.edit),r.state.scrollSetBy==e&&(r.state.scrollSetAt||0)+50>o)return!1;var n=r.getScrollInfo();if("align"==e.mv.options.connect)m=n.top;else{var l,s,c=.5*n.clientHeight,f=n.top+c,h=r.lineAtHeight(f,"local"),d=L(e.chunks,h,t==DIFF_INSERT),u=a(r,t==DIFF_INSERT?d.edit:d.orig),g=a(i,t==DIFF_INSERT?d.orig:d.edit),v=(f-u.top)/(u.bot-u.top),m=g.top-c+v*(g.bot-g.top);if(m>n.top&&(s=n.top/c)<1)m=m*s+n.top*(1-s);else if((l=n.height-n.clientHeight-n.top)<c){var p=i.getScrollInfo(),k=p.height-p.clientHeight-m;k>l&&(s=l/c)<1&&(m=m*s+(p.height-p.clientHeight-l)*(1-s))}}return i.scrollTo(n.left,m),i.state.scrollSetAt=o,i.state.scrollSetBy=e,!0}function a(e,t){var r=t.after;return null==r&&(r=e.lastLine()+1),{top:e.heightAtLine(t.before||0,"local"),bot:e.heightAtLine(r,"local")}}function s(e,t,r){e.lockScroll=t,t&&0!=r&&l(e,DIFF_INSERT)&&d(e),e.lockButton.innerHTML=t?"⇛⇚":"⇛ ⇚"}function c(t,r,i){for(var o=0;o<r.length;++o){var n=r[o];n instanceof e.TextMarker?n.clear():n.parent&&(t.removeLineClass(n,"background",i.chunk),t.removeLineClass(n,"background",i.start),t.removeLineClass(n,"background",i.end))}r.length=0}function f(e,t,r,i,o){var n=e.getViewport();e.operation(function(){r.from==r.to||n.from-r.to>20||r.from-n.to>20?(c(e,r.marked,o),h(e,t,i,r.marked,n.from,n.to,o),r.from=n.from,r.to=n.to):(n.from<r.from&&(h(e,t,i,r.marked,n.from,r.from,o),r.from=n.from),n.to>r.to&&(h(e,t,i,r.marked,r.to,n.to,o),r.to=n.to))})}function h(e,t,r,i,o,n,l){function a(t,r){for(var a=Math.max(o,t),s=Math.min(n,r),c=a;s>c;++c){var f=e.addLineClass(c,"background",l.chunk);c==t&&e.addLineClass(f,"background",l.start),c==r-1&&e.addLineClass(f,"background",l.end),i.push(f)}t==r&&a==r&&s==r&&(a?i.push(e.addLineClass(a-1,"background",l.end)):i.push(e.addLineClass(a,"background",l.start)))}for(var s=W(0,0),c=W(o,0),f=e.clipPos(W(n-1)),h=r==DIFF_DELETE?l.del:l.insert,d=0,u=0;u<t.length;++u){var g=t[u],v=g[0],m=g[1];if(v==DIFF_EQUAL){var p=s.line+(M(t,u)?0:1);x(s,m);var k=s.line+(D(t,u)?1:0);k>p&&(u&&a(d,p),d=k)}else if(v==r){var C=x(s,m,!0),T=R(c,s),F=B(f,C);V(T,F)||i.push(e.markText(T,F,{className:h})),s=C}}d<=s.line&&a(d,s.line+1)}function d(e){if(e.showDifferences){if(e.svg){N(e.svg);var t=e.gap.offsetWidth;_(e.svg,"width",t,"height",e.gap.offsetHeight)}e.copyButtons&&N(e.copyButtons);for(var r=e.edit.getViewport(),i=e.orig.getViewport(),o=e.edit.getScrollInfo().top,n=e.orig.getScrollInfo().top,l=0;l<e.chunks.length;l++){var a=e.chunks[l];a.editFrom<=r.to&&a.editTo>=r.from&&a.origFrom<=i.to&&a.origTo>=i.from&&k(e,a,n,o,t)}}}function u(e,t){for(var r=0,i=0,o=0;o<t.length;o++){var n=t[o];if(n.editTo>e&&n.editFrom<=e)return null;if(n.editFrom>e)break;r=n.editTo,i=n.origTo}return i+(e-r)}function g(e,t){for(var r=[],i=0;i<e.chunks.length;i++){var o=e.chunks[i];r.push([o.origTo,o.editTo,t?u(o.editTo,t.chunks):null])}if(t)for(var i=0;i<t.chunks.length;i++){for(var o=t.chunks[i],n=0;n<r.length;n++){var l=r[n];if(l[1]==o.editTo){n=-1;break}if(l[1]>o.editTo)break}n>-1&&r.splice(n-1,0,[u(o.editTo,e.chunks),o.editTo,o.origTo])}return r}function v(e,t){if(e.dealigned||t){if(!e.orig.curOp)return e.orig.operation(function(){v(e,t)});e.dealigned=!1;var r=e.mv.left==e?e.mv.right:e.mv.left;r&&(i(r),r.dealigned=!1);for(var o=g(e,r),n=e.mv.aligners,l=0;l<n.length;l++)n[l].clear();n.length=0;var a=[e.orig,e.edit],s=[];r&&a.push(r.orig);for(var l=0;l<a.length;l++)s.push(a[l].getScrollInfo().top);for(var c=0;c<o.length;c++)m(a,o[c],n);for(var l=0;l<a.length;l++)a[l].scrollTo(null,s[l])}}function m(e,t,r){for(var i=0,o=[],n=0;n<e.length;n++)if(null!=t[n]){var l=e[n].heightAtLine(t[n],"local");o[n]=l,i=Math.max(i,l)}for(var n=0;n<e.length;n++)if(null!=t[n]){var a=i-o[n];a>1&&r.push(p(e[n],t[n],a))}}function p(e,t,r){var i=!0;t>e.lastLine()&&(t--,i=!1);var o=document.createElement("div");return o.className="CodeMirror-merge-spacer",o.style.height=r+"px",o.style.minWidth="1px",e.addLineWidget(t,o,{height:r,above:i})}function k(e,t,r,i,o){var n="left"==e.type,l=e.orig.heightAtLine(t.origFrom,"local")-r;if(e.svg){var a=l,s=e.edit.heightAtLine(t.editFrom,"local")-i;if(n){var c=a;a=s,s=c}var f=e.orig.heightAtLine(t.origTo,"local")-r,h=e.edit.heightAtLine(t.editTo,"local")-i;if(n){var c=f;f=h,h=c}var d=" C "+o/2+" "+s+" "+o/2+" "+a+" "+(o+2)+" "+a,u=" C "+o/2+" "+f+" "+o/2+" "+h+" -1 "+h;_(e.svg.appendChild(document.createElementNS(z,"path")),"d","M -1 "+s+d+" L "+(o+2)+" "+f+u+" z","class",e.classes.connect)}if(e.copyButtons){var g=e.copyButtons.appendChild(O("div","left"==e.type?"⇝":"⇜","CodeMirror-merge-copy")),v=e.mv.options.allowEditingOriginals;if(g.title=v?"Push to left":"Revert chunk",g.chunk=t,g.style.top=l+"px",v){var m=e.orig.heightAtLine(t.editFrom,"local")-i,p=e.copyButtons.appendChild(O("div","right"==e.type?"⇝":"⇜","CodeMirror-merge-copy-reverse"));p.title="Push to right",p.chunk={editFrom:t.origFrom,editTo:t.origTo,origFrom:t.editFrom,origTo:t.editTo},p.style.top=m+"px","right"==e.type?p.style.left="2px":p.style.right="2px"}}}function C(e,t,r,i){e.diffOutOfDate||t.replaceRange(r.getRange(W(i.origFrom,0),W(i.origTo,0)),W(i.editFrom,0),W(i.editTo,0))}function T(t){var r=t.lockButton=O("div",null,"CodeMirror-merge-scrolllock");r.title="Toggle locked scrolling";var i=O("div",[r],"CodeMirror-merge-scrolllock-wrap");e.on(r,"click",function(){s(t,!t.lockScroll)});var o=[i];if(t.mv.options.revertButtons!==!1&&(t.copyButtons=O("div",null,"CodeMirror-merge-copybuttons-"+t.type),e.on(t.copyButtons,"click",function(e){var r=e.target||e.srcElement;if(r.chunk)return"CodeMirror-merge-copy-reverse"==r.className?void C(t,t.orig,t.edit,r.chunk):void C(t,t.edit,t.orig,r.chunk)}),o.unshift(t.copyButtons)),"align"!=t.mv.options.connect){var n=document.createElementNS&&document.createElementNS(z,"svg");n&&!n.createSVGRect&&(n=null),t.svg=n,n&&o.push(n)}return t.gap=O("div",o,"CodeMirror-merge-gap")}function F(e){return"string"==typeof e?e:e.getValue()}function w(e,t){var r=Q.diff_main(e,t);Q.diff_cleanupSemantic(r);for(var i=0;i<r.length;++i){var o=r[i];o[1]?i&&r[i-1][0]==o[0]&&(r.splice(i--,1),r[i][1]+=o[1]):r.splice(i--,1)}return r}function y(e){for(var t=[],r=0,i=0,o=W(0,0),n=W(0,0),l=0;l<e.length;++l){var a=e[l],s=a[0];if(s==DIFF_EQUAL){var c=M(e,l)?0:1,f=o.line+c,h=n.line+c;x(o,a[1],null,n);var d=D(e,l)?1:0,u=o.line+d,g=n.line+d;u>f&&(l&&t.push({origFrom:i,origTo:h,editFrom:r,editTo:f}),r=u,i=g)}else x(s==DIFF_INSERT?o:n,a[1])}return(r<=o.line||i<=n.line)&&t.push({origFrom:i,origTo:n.line+1,editFrom:r,editTo:o.line+1}),t}function D(e,t){if(t==e.length-1)return!0;var r=e[t+1][1];return 1==r.length||10!=r.charCodeAt(0)?!1:t==e.length-2?!0:(r=e[t+2][1],r.length>1&&10==r.charCodeAt(0))}function M(e,t){if(0==t)return!0;var r=e[t-1][1];return 10!=r.charCodeAt(r.length-1)?!1:1==t?!0:(r=e[t-2][1],10==r.charCodeAt(r.length-1))}function L(e,t,r){for(var i,o,n,l,a=0;a<e.length;a++){var s=e[a],c=r?s.editFrom:s.origFrom,f=r?s.editTo:s.origTo;null==o&&(c>t?(o=s.editFrom,l=s.origFrom):f>t&&(o=s.editTo,l=s.origTo)),t>=f?(i=s.editTo,n=s.origTo):t>=c&&(i=s.editFrom,n=s.origFrom)}return{edit:{before:i,after:o},orig:{before:n,after:l}}}function I(e,t,r){function i(){n.clear(),e.removeLineClass(t,"wrap","CodeMirror-merge-collapsed-line")}e.addLineClass(t,"wrap","CodeMirror-merge-collapsed-line");var o=document.createElement("span");o.className="CodeMirror-merge-collapsed-widget",o.title="Identical text collapsed. Click to expand.";var n=e.markText(W(t,0),W(r-1),{inclusiveLeft:!0,inclusiveRight:!0,replacedWith:o,clearOnEnter:!0});return o.addEventListener("click",i),{mark:n,clear:i}}function b(e,t){function r(){for(var e=0;e<i.length;e++)i[e].clear()}for(var i=[],o=0;o<t.length;o++){var n=t[o],l=I(n.cm,n.line,n.line+e);i.push(l),l.mark.on("clear",r)}return i[0].mark}function E(e,t,r,i){for(var o=0;o<e.chunks.length;o++)for(var n=e.chunks[o],l=n.editFrom-t;l<n.editTo+t;l++){var a=l+r;a>=0&&a<i.length&&(i[a]=!1)}}function S(e,t){"number"!=typeof t&&(t=2);for(var r=[],i=e.editor(),o=i.firstLine(),n=o,l=i.lastLine();l>=n;n++)r.push(!0);e.left&&E(e.left,t,o,r),e.right&&E(e.right,t,o,r);for(var a=0;a<r.length;a++)if(r[a]){for(var s=a+o,c=1;a<r.length-1&&r[a+1];a++,c++);if(c>t){var f=[{line:s,cm:i}];e.left&&f.push({line:u(s,e.left.chunks),cm:e.left.orig}),e.right&&f.push({line:u(s,e.right.chunks),cm:e.right.orig});var h=b(c,f);e.options.onCollapse&&e.options.onCollapse(e,s,c,h)}}}function O(e,t,r,i){var o=document.createElement(e);if(r&&(o.className=r),i&&(o.style.cssText=i),"string"==typeof t)o.appendChild(document.createTextNode(t));else if(t)for(var n=0;n<t.length;++n)o.appendChild(t[n]);return o}function N(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild)}function _(e){for(var t=1;t<arguments.length;t+=2)e.setAttribute(arguments[t],arguments[t+1])}function A(e,t){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function x(e,t,r,i){for(var o=r?W(e.line,e.ch):e,n=0;;){var l=t.indexOf("\n",n);if(-1==l)break;++o.line,i&&++i.line,n=l+1}return o.ch=(n?0:o.ch)+(t.length-n),i&&(i.ch=(n?0:i.ch)+(t.length-n)),o}function B(e,t){return(e.line-t.line||e.ch-t.ch)<0?e:t}function R(e,t){return(e.line-t.line||e.ch-t.ch)>0?e:t}function V(e,t){return e.line==t.line&&e.ch==t.ch}function H(e,t,r){for(var i=e.length-1;i>=0;i--){var o=e[i],n=(r?o.origTo:o.editTo)-1;if(t>n)return n}}function P(e,t,r){for(var i=0;i<e.length;i++){var o=e[i],n=r?o.origFrom:o.editFrom;if(n>t)return n}}function U(t,r){var o=null,n=t.state.diffViews,l=t.getCursor().line;if(n)for(var a=0;a<n.length;a++){var s=n[a],c=t==s.orig;i(s);var f=0>r?H(s.chunks,l,c):P(s.chunks,l,c);null==f||null!=o&&!(0>r?f>o:o>f)||(o=f)}return null==o?e.Pass:void t.setCursor(o,0)}var W=e.Pos,z="http://www.w3.org/2000/svg";r.prototype={constructor:r,init:function(t,r,i){this.edit=this.mv.edit,(this.edit.state.diffViews||(this.edit.state.diffViews=[])).push(this),this.orig=e(t,A({value:r,readOnly:!this.mv.options.allowEditingOriginals},A(i))),this.orig.state.diffViews=[this],this.diff=w(F(r),F(i.value)),this.chunks=y(this.diff),this.diffOutOfDate=this.dealigned=!1,this.showDifferences=i.showDifferences!==!1,this.forceUpdate=o(this),s(this,!0,!1),n(this)},setShowDifferences:function(e){e=e!==!1,e!=this.showDifferences&&(this.showDifferences=e,this.forceUpdate("full"))}};var j=!1,q=e.MergeView=function(t,i){if(!(this instanceof q))return new q(t,i);this.options=i;var o=i.origLeft,n=null==i.origRight?i.orig:i.origRight,l=null!=o,a=null!=n,s=1+(l?1:0)+(a?1:0),c=[],f=this.left=null,h=this.right=null,u=this;if(l){f=this.left=new r(this,"left");var g=O("div",null,"CodeMirror-merge-pane");c.push(g),c.push(T(f))}var m=O("div",null,"CodeMirror-merge-pane");if(c.push(m),a){h=this.right=new r(this,"right"),c.push(T(h));var p=O("div",null,"CodeMirror-merge-pane");c.push(p)}(a?p:m).className+=" CodeMirror-merge-pane-rightmost",c.push(O("div",null,null,"height: 0; clear: both;"));var k=this.wrap=t.appendChild(O("div",c,"CodeMirror-merge CodeMirror-merge-"+s+"pane"));this.edit=e(m,A(i)),f&&f.init(g,o,i),h&&h.init(p,n,i),i.collapseIdentical&&(j=!0,this.editor().operation(function(){S(u,i.collapseIdentical)}),j=!1),"align"==i.connect&&(this.aligners=[],v(this.left||this.right,!0));var C=function(){f&&d(f),h&&d(h)};e.on(window,"resize",C);var F=setInterval(function(){for(var t=k.parentNode;t&&t!=document.body;t=t.parentNode);t||(clearInterval(F),e.off(window,"resize",C))},5e3)};q.prototype={constuctor:q,editor:function(){return this.edit},rightOriginal:function(){return this.right&&this.right.orig},leftOriginal:function(){return this.left&&this.left.orig},setShowDifferences:function(e){this.right&&this.right.setShowDifferences(e),this.left&&this.left.setShowDifferences(e)},rightChunks:function(){return this.right?(i(this.right),this.right.chunks):void 0},leftChunks:function(){return this.left?(i(this.left),this.left.chunks):void 0}};var Q=new t;e.commands.goNextDiff=function(e){return U(e,1)},e.commands.goPrevDiff=function(e){return U(e,-1)}});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/lib/codemirror.min.js
CHANGED
@@ -1,1036 +1,5 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
module.exports=mod();else if(typeof define=="function"&&define.amd)
|
4 |
-
return define([],mod);else
|
5 |
-
this.CodeMirror=mod();})(function(){"use strict";var gecko=/gecko\/\d/i.test(navigator.userAgent);var ie_upto10=/MSIE \d/.test(navigator.userAgent);var ie_11up=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);var ie=ie_upto10||ie_11up;var ie_version=ie&&(ie_upto10?document.documentMode||6:ie_11up[1]);var webkit=/WebKit\//.test(navigator.userAgent);var qtwebkit=webkit&&/Qt\/\d+\.\d+/.test(navigator.userAgent);var chrome=/Chrome\//.test(navigator.userAgent);var presto=/Opera\//.test(navigator.userAgent);var safari=/Apple Computer/.test(navigator.vendor);var mac_geMountainLion=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);var phantom=/PhantomJS/.test(navigator.userAgent);var ios=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent);var mobile=ios||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent);var mac=ios||/Mac/.test(navigator.platform);var windows=/win/i.test(navigator.platform);var presto_version=presto&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);if(presto_version)presto_version=Number(presto_version[1]);if(presto_version&&presto_version>=15){presto=false;webkit=true;}
|
6 |
-
var flipCtrlCmd=mac&&(qtwebkit||presto&&(presto_version==null||presto_version<12.11));var captureRightClick=gecko||(ie&&ie_version>=9);var sawReadOnlySpans=false,sawCollapsedSpans=false;function CodeMirror(place,options){if(!(this instanceof CodeMirror))return new CodeMirror(place,options);this.options=options=options?copyObj(options):{};copyObj(defaults,options,false);setGuttersForLineNumbers(options);var doc=options.value;if(typeof doc=="string")doc=new Doc(doc,options.mode);this.doc=doc;var input=new CodeMirror.inputStyles[options.inputStyle](this);var display=this.display=new Display(place,doc,input);display.wrapper.CodeMirror=this;updateGutters(this);themeChanged(this);if(options.lineWrapping)
|
7 |
-
this.display.wrapper.className+=" CodeMirror-wrap";if(options.autofocus&&!mobile)display.input.focus();initScrollbars(this);this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:false,delayingBlurEvent:false,focused:false,suppressEdits:false,pasteIncoming:false,cutIncoming:false,draggingText:false,highlight:new Delayed(),keySeq:null,specialChars:null};var cm=this;if(ie&&ie_version<11)setTimeout(function(){cm.display.input.reset(true);},20);registerEventHandlers(this);ensureGlobalHandlers();startOperation(this);this.curOp.forceUpdate=true;attachDoc(this,doc);if((options.autofocus&&!mobile)||cm.hasFocus())
|
8 |
-
setTimeout(bind(onFocus,this),20);else
|
9 |
-
onBlur(this);for(var opt in optionHandlers)if(optionHandlers.hasOwnProperty(opt))
|
10 |
-
optionHandlers[opt](this,options[opt],Init);maybeUpdateLineNumberWidth(this);if(options.finishInit)options.finishInit(this);for(var i=0;i<initHooks.length;++i)initHooks[i](this);endOperation(this);if(webkit&&options.lineWrapping&&getComputedStyle(display.lineDiv).textRendering=="optimizelegibility")
|
11 |
-
display.lineDiv.style.textRendering="auto";}
|
12 |
-
function Display(place,doc,input){var d=this;this.input=input;d.scrollbarFiller=elt("div",null,"CodeMirror-scrollbar-filler");d.scrollbarFiller.setAttribute("cm-not-content","true");d.gutterFiller=elt("div",null,"CodeMirror-gutter-filler");d.gutterFiller.setAttribute("cm-not-content","true");d.lineDiv=elt("div",null,"CodeMirror-code");d.selectionDiv=elt("div",null,null,"position: relative; z-index: 1");d.cursorDiv=elt("div",null,"CodeMirror-cursors");d.measure=elt("div",null,"CodeMirror-measure");d.lineMeasure=elt("div",null,"CodeMirror-measure");d.lineSpace=elt("div",[d.measure,d.lineMeasure,d.selectionDiv,d.cursorDiv,d.lineDiv],null,"position: relative; outline: none");d.mover=elt("div",[elt("div",[d.lineSpace],"CodeMirror-lines")],null,"position: relative");d.sizer=elt("div",[d.mover],"CodeMirror-sizer");d.sizerWidth=null;d.heightForcer=elt("div",null,null,"position: absolute; height: "+scrollerGap+"px; width: 1px;");d.gutters=elt("div",null,"CodeMirror-gutters");d.lineGutter=null;d.scroller=elt("div",[d.sizer,d.heightForcer,d.gutters],"CodeMirror-scroll");d.scroller.setAttribute("tabIndex","-1");d.wrapper=elt("div",[d.scrollbarFiller,d.gutterFiller,d.scroller],"CodeMirror");if(ie&&ie_version<8){d.gutters.style.zIndex=-1;d.scroller.style.paddingRight=0;}
|
13 |
-
if(!webkit&&!(gecko&&mobile))d.scroller.draggable=true;if(place){if(place.appendChild)place.appendChild(d.wrapper);else place(d.wrapper);}
|
14 |
-
d.viewFrom=d.viewTo=doc.first;d.reportedViewFrom=d.reportedViewTo=doc.first;d.view=[];d.renderedView=null;d.externalMeasured=null;d.viewOffset=0;d.lastWrapHeight=d.lastWrapWidth=0;d.updateLineNumbers=null;d.nativeBarWidth=d.barHeight=d.barWidth=0;d.scrollbarsClipped=false;d.lineNumWidth=d.lineNumInnerWidth=d.lineNumChars=null;d.alignWidgets=false;d.cachedCharWidth=d.cachedTextHeight=d.cachedPaddingH=null;d.maxLine=null;d.maxLineLength=0;d.maxLineChanged=false;d.wheelDX=d.wheelDY=d.wheelStartX=d.wheelStartY=null;d.shift=false;d.selForContextMenu=null;d.activeTouch=null;input.init(d);}
|
15 |
-
function loadMode(cm){cm.doc.mode=CodeMirror.getMode(cm.options,cm.doc.modeOption);resetModeState(cm);}
|
16 |
-
function resetModeState(cm){cm.doc.iter(function(line){if(line.stateAfter)line.stateAfter=null;if(line.styles)line.styles=null;});cm.doc.frontier=cm.doc.first;startWorker(cm,100);cm.state.modeGen++;if(cm.curOp)regChange(cm);}
|
17 |
-
function wrappingChanged(cm){if(cm.options.lineWrapping){addClass(cm.display.wrapper,"CodeMirror-wrap");cm.display.sizer.style.minWidth="";cm.display.sizerWidth=null;}else{rmClass(cm.display.wrapper,"CodeMirror-wrap");findMaxLine(cm);}
|
18 |
-
estimateLineHeights(cm);regChange(cm);clearCaches(cm);setTimeout(function(){updateScrollbars(cm);},100);}
|
19 |
-
function estimateHeight(cm){var th=textHeight(cm.display),wrapping=cm.options.lineWrapping;var perLine=wrapping&&Math.max(5,cm.display.scroller.clientWidth/charWidth(cm.display)-3);return function(line){if(lineIsHidden(cm.doc,line))return 0;var widgetsHeight=0;if(line.widgets)for(var i=0;i<line.widgets.length;i++){if(line.widgets[i].height)widgetsHeight+=line.widgets[i].height;}
|
20 |
-
if(wrapping)
|
21 |
-
return widgetsHeight+(Math.ceil(line.text.length/perLine)||1)*th;else
|
22 |
-
return widgetsHeight+th;};}
|
23 |
-
function estimateLineHeights(cm){var doc=cm.doc,est=estimateHeight(cm);doc.iter(function(line){var estHeight=est(line);if(estHeight!=line.height)updateLineHeight(line,estHeight);});}
|
24 |
-
function themeChanged(cm){cm.display.wrapper.className=cm.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+
|
25 |
-
cm.options.theme.replace(/(^|\s)\s*/g," cm-s-");clearCaches(cm);}
|
26 |
-
function guttersChanged(cm){updateGutters(cm);regChange(cm);setTimeout(function(){alignHorizontally(cm);},20);}
|
27 |
-
function updateGutters(cm){var gutters=cm.display.gutters,specs=cm.options.gutters;removeChildren(gutters);for(var i=0;i<specs.length;++i){var gutterClass=specs[i];var gElt=gutters.appendChild(elt("div",null,"CodeMirror-gutter "+gutterClass));if(gutterClass=="CodeMirror-linenumbers"){cm.display.lineGutter=gElt;gElt.style.width=(cm.display.lineNumWidth||1)+"px";}}
|
28 |
-
gutters.style.display=i?"":"none";updateGutterSpace(cm);}
|
29 |
-
function updateGutterSpace(cm){var width=cm.display.gutters.offsetWidth;cm.display.sizer.style.marginLeft=width+"px";}
|
30 |
-
function lineLength(line){if(line.height==0)return 0;var len=line.text.length,merged,cur=line;while(merged=collapsedSpanAtStart(cur)){var found=merged.find(0,true);cur=found.from.line;len+=found.from.ch-found.to.ch;}
|
31 |
-
cur=line;while(merged=collapsedSpanAtEnd(cur)){var found=merged.find(0,true);len-=cur.text.length-found.from.ch;cur=found.to.line;len+=cur.text.length-found.to.ch;}
|
32 |
-
return len;}
|
33 |
-
function findMaxLine(cm){var d=cm.display,doc=cm.doc;d.maxLine=getLine(doc,doc.first);d.maxLineLength=lineLength(d.maxLine);d.maxLineChanged=true;doc.iter(function(line){var len=lineLength(line);if(len>d.maxLineLength){d.maxLineLength=len;d.maxLine=line;}});}
|
34 |
-
function setGuttersForLineNumbers(options){var found=indexOf(options.gutters,"CodeMirror-linenumbers");if(found==-1&&options.lineNumbers){options.gutters=options.gutters.concat(["CodeMirror-linenumbers"]);}else if(found>-1&&!options.lineNumbers){options.gutters=options.gutters.slice(0);options.gutters.splice(found,1);}}
|
35 |
-
function measureForScrollbars(cm){var d=cm.display,gutterW=d.gutters.offsetWidth;var docH=Math.round(cm.doc.height+paddingVert(cm.display));return{clientHeight:d.scroller.clientHeight,viewHeight:d.wrapper.clientHeight,scrollWidth:d.scroller.scrollWidth,clientWidth:d.scroller.clientWidth,viewWidth:d.wrapper.clientWidth,barLeft:cm.options.fixedGutter?gutterW:0,docHeight:docH,scrollHeight:docH+scrollGap(cm)+d.barHeight,nativeBarWidth:d.nativeBarWidth,gutterWidth:gutterW};}
|
36 |
-
function NativeScrollbars(place,scroll,cm){this.cm=cm;var vert=this.vert=elt("div",[elt("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar");var horiz=this.horiz=elt("div",[elt("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");place(vert);place(horiz);on(vert,"scroll",function(){if(vert.clientHeight)scroll(vert.scrollTop,"vertical");});on(horiz,"scroll",function(){if(horiz.clientWidth)scroll(horiz.scrollLeft,"horizontal");});this.checkedOverlay=false;if(ie&&ie_version<8)this.horiz.style.minHeight=this.vert.style.minWidth="18px";}
|
37 |
-
NativeScrollbars.prototype=copyObj({update:function(measure){var needsH=measure.scrollWidth>measure.clientWidth+1;var needsV=measure.scrollHeight>measure.clientHeight+1;var sWidth=measure.nativeBarWidth;if(needsV){this.vert.style.display="block";this.vert.style.bottom=needsH?sWidth+"px":"0";var totalHeight=measure.viewHeight-(needsH?sWidth:0);this.vert.firstChild.style.height=Math.max(0,measure.scrollHeight-measure.clientHeight+totalHeight)+"px";}else{this.vert.style.display="";this.vert.firstChild.style.height="0";}
|
38 |
-
if(needsH){this.horiz.style.display="block";this.horiz.style.right=needsV?sWidth+"px":"0";this.horiz.style.left=measure.barLeft+"px";var totalWidth=measure.viewWidth-measure.barLeft-(needsV?sWidth:0);this.horiz.firstChild.style.width=(measure.scrollWidth-measure.clientWidth+totalWidth)+"px";}else{this.horiz.style.display="";this.horiz.firstChild.style.width="0";}
|
39 |
-
if(!this.checkedOverlay&&measure.clientHeight>0){if(sWidth==0)this.overlayHack();this.checkedOverlay=true;}
|
40 |
-
return{right:needsV?sWidth:0,bottom:needsH?sWidth:0};},setScrollLeft:function(pos){if(this.horiz.scrollLeft!=pos)this.horiz.scrollLeft=pos;},setScrollTop:function(pos){if(this.vert.scrollTop!=pos)this.vert.scrollTop=pos;},overlayHack:function(){var w=mac&&!mac_geMountainLion?"12px":"18px";this.horiz.style.minHeight=this.vert.style.minWidth=w;var self=this;var barMouseDown=function(e){if(e_target(e)!=self.vert&&e_target(e)!=self.horiz)
|
41 |
-
operation(self.cm,onMouseDown)(e);};on(this.vert,"mousedown",barMouseDown);on(this.horiz,"mousedown",barMouseDown);},clear:function(){var parent=this.horiz.parentNode;parent.removeChild(this.horiz);parent.removeChild(this.vert);}},NativeScrollbars.prototype);function NullScrollbars(){}
|
42 |
-
NullScrollbars.prototype=copyObj({update:function(){return{bottom:0,right:0};},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},NullScrollbars.prototype);CodeMirror.scrollbarModel={"native":NativeScrollbars,"null":NullScrollbars};function initScrollbars(cm){if(cm.display.scrollbars){cm.display.scrollbars.clear();if(cm.display.scrollbars.addClass)
|
43 |
-
rmClass(cm.display.wrapper,cm.display.scrollbars.addClass);}
|
44 |
-
cm.display.scrollbars=new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node){cm.display.wrapper.insertBefore(node,cm.display.scrollbarFiller);on(node,"mousedown",function(){if(cm.state.focused)setTimeout(function(){cm.display.input.focus();},0);});node.setAttribute("cm-not-content","true");},function(pos,axis){if(axis=="horizontal")setScrollLeft(cm,pos);else setScrollTop(cm,pos);},cm);if(cm.display.scrollbars.addClass)
|
45 |
-
addClass(cm.display.wrapper,cm.display.scrollbars.addClass);}
|
46 |
-
function updateScrollbars(cm,measure){if(!measure)measure=measureForScrollbars(cm);var startWidth=cm.display.barWidth,startHeight=cm.display.barHeight;updateScrollbarsInner(cm,measure);for(var i=0;i<4&&startWidth!=cm.display.barWidth||startHeight!=cm.display.barHeight;i++){if(startWidth!=cm.display.barWidth&&cm.options.lineWrapping)
|
47 |
-
updateHeightsInViewport(cm);updateScrollbarsInner(cm,measureForScrollbars(cm));startWidth=cm.display.barWidth;startHeight=cm.display.barHeight;}}
|
48 |
-
function updateScrollbarsInner(cm,measure){var d=cm.display;var sizes=d.scrollbars.update(measure);d.sizer.style.paddingRight=(d.barWidth=sizes.right)+"px";d.sizer.style.paddingBottom=(d.barHeight=sizes.bottom)+"px";if(sizes.right&&sizes.bottom){d.scrollbarFiller.style.display="block";d.scrollbarFiller.style.height=sizes.bottom+"px";d.scrollbarFiller.style.width=sizes.right+"px";}else d.scrollbarFiller.style.display="";if(sizes.bottom&&cm.options.coverGutterNextToScrollbar&&cm.options.fixedGutter){d.gutterFiller.style.display="block";d.gutterFiller.style.height=sizes.bottom+"px";d.gutterFiller.style.width=measure.gutterWidth+"px";}else d.gutterFiller.style.display="";}
|
49 |
-
function visibleLines(display,doc,viewport){var top=viewport&&viewport.top!=null?Math.max(0,viewport.top):display.scroller.scrollTop;top=Math.floor(top-paddingTop(display));var bottom=viewport&&viewport.bottom!=null?viewport.bottom:top+display.wrapper.clientHeight;var from=lineAtHeight(doc,top),to=lineAtHeight(doc,bottom);if(viewport&&viewport.ensure){var ensureFrom=viewport.ensure.from.line,ensureTo=viewport.ensure.to.line;if(ensureFrom<from){from=ensureFrom;to=lineAtHeight(doc,heightAtLine(getLine(doc,ensureFrom))+display.wrapper.clientHeight);}else if(Math.min(ensureTo,doc.lastLine())>=to){from=lineAtHeight(doc,heightAtLine(getLine(doc,ensureTo))-display.wrapper.clientHeight);to=ensureTo;}}
|
50 |
-
return{from:from,to:Math.max(to,from+1)};}
|
51 |
-
function alignHorizontally(cm){var display=cm.display,view=display.view;if(!display.alignWidgets&&(!display.gutters.firstChild||!cm.options.fixedGutter))return;var comp=compensateForHScroll(display)-display.scroller.scrollLeft+cm.doc.scrollLeft;var gutterW=display.gutters.offsetWidth,left=comp+"px";for(var i=0;i<view.length;i++)if(!view[i].hidden){if(cm.options.fixedGutter&&view[i].gutter)
|
52 |
-
view[i].gutter.style.left=left;var align=view[i].alignable;if(align)for(var j=0;j<align.length;j++)
|
53 |
-
align[j].style.left=left;}
|
54 |
-
if(cm.options.fixedGutter)
|
55 |
-
display.gutters.style.left=(comp+gutterW)+"px";}
|
56 |
-
function maybeUpdateLineNumberWidth(cm){if(!cm.options.lineNumbers)return false;var doc=cm.doc,last=lineNumberFor(cm.options,doc.first+doc.size-1),display=cm.display;if(last.length!=display.lineNumChars){var test=display.measure.appendChild(elt("div",[elt("div",last)],"CodeMirror-linenumber CodeMirror-gutter-elt"));var innerW=test.firstChild.offsetWidth,padding=test.offsetWidth-innerW;display.lineGutter.style.width="";display.lineNumInnerWidth=Math.max(innerW,display.lineGutter.offsetWidth-padding)+1;display.lineNumWidth=display.lineNumInnerWidth+padding;display.lineNumChars=display.lineNumInnerWidth?last.length:-1;display.lineGutter.style.width=display.lineNumWidth+"px";updateGutterSpace(cm);return true;}
|
57 |
-
return false;}
|
58 |
-
function lineNumberFor(options,i){return String(options.lineNumberFormatter(i+options.firstLineNumber));}
|
59 |
-
function compensateForHScroll(display){return display.scroller.getBoundingClientRect().left-display.sizer.getBoundingClientRect().left;}
|
60 |
-
function DisplayUpdate(cm,viewport,force){var display=cm.display;this.viewport=viewport;this.visible=visibleLines(display,cm.doc,viewport);this.editorIsHidden=!display.wrapper.offsetWidth;this.wrapperHeight=display.wrapper.clientHeight;this.wrapperWidth=display.wrapper.clientWidth;this.oldDisplayWidth=displayWidth(cm);this.force=force;this.dims=getDimensions(cm);this.events=[];}
|
61 |
-
DisplayUpdate.prototype.signal=function(emitter,type){if(hasHandler(emitter,type))
|
62 |
-
this.events.push(arguments);};DisplayUpdate.prototype.finish=function(){for(var i=0;i<this.events.length;i++)
|
63 |
-
signal.apply(null,this.events[i]);};function maybeClipScrollbars(cm){var display=cm.display;if(!display.scrollbarsClipped&&display.scroller.offsetWidth){display.nativeBarWidth=display.scroller.offsetWidth-display.scroller.clientWidth;display.heightForcer.style.height=scrollGap(cm)+"px";display.sizer.style.marginBottom=-display.nativeBarWidth+"px";display.sizer.style.borderRightWidth=scrollGap(cm)+"px";display.scrollbarsClipped=true;}}
|
64 |
-
function updateDisplayIfNeeded(cm,update){var display=cm.display,doc=cm.doc;if(update.editorIsHidden){resetView(cm);return false;}
|
65 |
-
if(!update.force&&update.visible.from>=display.viewFrom&&update.visible.to<=display.viewTo&&(display.updateLineNumbers==null||display.updateLineNumbers>=display.viewTo)&&display.renderedView==display.view&&countDirtyView(cm)==0)
|
66 |
-
return false;if(maybeUpdateLineNumberWidth(cm)){resetView(cm);update.dims=getDimensions(cm);}
|
67 |
-
var end=doc.first+doc.size;var from=Math.max(update.visible.from-cm.options.viewportMargin,doc.first);var to=Math.min(end,update.visible.to+cm.options.viewportMargin);if(display.viewFrom<from&&from-display.viewFrom<20)from=Math.max(doc.first,display.viewFrom);if(display.viewTo>to&&display.viewTo-to<20)to=Math.min(end,display.viewTo);if(sawCollapsedSpans){from=visualLineNo(cm.doc,from);to=visualLineEndNo(cm.doc,to);}
|
68 |
-
var different=from!=display.viewFrom||to!=display.viewTo||display.lastWrapHeight!=update.wrapperHeight||display.lastWrapWidth!=update.wrapperWidth;adjustView(cm,from,to);display.viewOffset=heightAtLine(getLine(cm.doc,display.viewFrom));cm.display.mover.style.top=display.viewOffset+"px";var toUpdate=countDirtyView(cm);if(!different&&toUpdate==0&&!update.force&&display.renderedView==display.view&&(display.updateLineNumbers==null||display.updateLineNumbers>=display.viewTo))
|
69 |
-
return false;var focused=activeElt();if(toUpdate>4)display.lineDiv.style.display="none";patchDisplay(cm,display.updateLineNumbers,update.dims);if(toUpdate>4)display.lineDiv.style.display="";display.renderedView=display.view;if(focused&&activeElt()!=focused&&focused.offsetHeight)focused.focus();removeChildren(display.cursorDiv);removeChildren(display.selectionDiv);display.gutters.style.height=0;if(different){display.lastWrapHeight=update.wrapperHeight;display.lastWrapWidth=update.wrapperWidth;startWorker(cm,400);}
|
70 |
-
display.updateLineNumbers=null;return true;}
|
71 |
-
function postUpdateDisplay(cm,update){var force=update.force,viewport=update.viewport;for(var first=true;;first=false){if(first&&cm.options.lineWrapping&&update.oldDisplayWidth!=displayWidth(cm)){force=true;}else{force=false;if(viewport&&viewport.top!=null)
|
72 |
-
viewport={top:Math.min(cm.doc.height+paddingVert(cm.display)-displayHeight(cm),viewport.top)};update.visible=visibleLines(cm.display,cm.doc,viewport);if(update.visible.from>=cm.display.viewFrom&&update.visible.to<=cm.display.viewTo)
|
73 |
-
break;}
|
74 |
-
if(!updateDisplayIfNeeded(cm,update))break;updateHeightsInViewport(cm);var barMeasure=measureForScrollbars(cm);updateSelection(cm);setDocumentHeight(cm,barMeasure);updateScrollbars(cm,barMeasure);}
|
75 |
-
update.signal(cm,"update",cm);if(cm.display.viewFrom!=cm.display.reportedViewFrom||cm.display.viewTo!=cm.display.reportedViewTo){update.signal(cm,"viewportChange",cm,cm.display.viewFrom,cm.display.viewTo);cm.display.reportedViewFrom=cm.display.viewFrom;cm.display.reportedViewTo=cm.display.viewTo;}}
|
76 |
-
function updateDisplaySimple(cm,viewport){var update=new DisplayUpdate(cm,viewport);if(updateDisplayIfNeeded(cm,update)){updateHeightsInViewport(cm);postUpdateDisplay(cm,update);var barMeasure=measureForScrollbars(cm);updateSelection(cm);setDocumentHeight(cm,barMeasure);updateScrollbars(cm,barMeasure);update.finish();}}
|
77 |
-
function setDocumentHeight(cm,measure){cm.display.sizer.style.minHeight=measure.docHeight+"px";var total=measure.docHeight+cm.display.barHeight;cm.display.heightForcer.style.top=total+"px";cm.display.gutters.style.height=Math.max(total+scrollGap(cm),measure.clientHeight)+"px";}
|
78 |
-
function updateHeightsInViewport(cm){var display=cm.display;var prevBottom=display.lineDiv.offsetTop;for(var i=0;i<display.view.length;i++){var cur=display.view[i],height;if(cur.hidden)continue;if(ie&&ie_version<8){var bot=cur.node.offsetTop+cur.node.offsetHeight;height=bot-prevBottom;prevBottom=bot;}else{var box=cur.node.getBoundingClientRect();height=box.bottom-box.top;}
|
79 |
-
var diff=cur.line.height-height;if(height<2)height=textHeight(display);if(diff>.001||diff<-.001){updateLineHeight(cur.line,height);updateWidgetHeight(cur.line);if(cur.rest)for(var j=0;j<cur.rest.length;j++)
|
80 |
-
updateWidgetHeight(cur.rest[j]);}}}
|
81 |
-
function updateWidgetHeight(line){if(line.widgets)for(var i=0;i<line.widgets.length;++i)
|
82 |
-
line.widgets[i].height=line.widgets[i].node.offsetHeight;}
|
83 |
-
function getDimensions(cm){var d=cm.display,left={},width={};var gutterLeft=d.gutters.clientLeft;for(var n=d.gutters.firstChild,i=0;n;n=n.nextSibling,++i){left[cm.options.gutters[i]]=n.offsetLeft+n.clientLeft+gutterLeft;width[cm.options.gutters[i]]=n.clientWidth;}
|
84 |
-
return{fixedPos:compensateForHScroll(d),gutterTotalWidth:d.gutters.offsetWidth,gutterLeft:left,gutterWidth:width,wrapperWidth:d.wrapper.clientWidth};}
|
85 |
-
function patchDisplay(cm,updateNumbersFrom,dims){var display=cm.display,lineNumbers=cm.options.lineNumbers;var container=display.lineDiv,cur=container.firstChild;function rm(node){var next=node.nextSibling;if(webkit&&mac&&cm.display.currentWheelTarget==node)
|
86 |
-
node.style.display="none";else
|
87 |
-
node.parentNode.removeChild(node);return next;}
|
88 |
-
var view=display.view,lineN=display.viewFrom;for(var i=0;i<view.length;i++){var lineView=view[i];if(lineView.hidden){}else if(!lineView.node||lineView.node.parentNode!=container){var node=buildLineElement(cm,lineView,lineN,dims);container.insertBefore(node,cur);}else{while(cur!=lineView.node)cur=rm(cur);var updateNumber=lineNumbers&&updateNumbersFrom!=null&&updateNumbersFrom<=lineN&&lineView.lineNumber;if(lineView.changes){if(indexOf(lineView.changes,"gutter")>-1)updateNumber=false;updateLineForChanges(cm,lineView,lineN,dims);}
|
89 |
-
if(updateNumber){removeChildren(lineView.lineNumber);lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options,lineN)));}
|
90 |
-
cur=lineView.node.nextSibling;}
|
91 |
-
lineN+=lineView.size;}
|
92 |
-
while(cur)cur=rm(cur);}
|
93 |
-
function updateLineForChanges(cm,lineView,lineN,dims){for(var j=0;j<lineView.changes.length;j++){var type=lineView.changes[j];if(type=="text")updateLineText(cm,lineView);else if(type=="gutter")updateLineGutter(cm,lineView,lineN,dims);else if(type=="class")updateLineClasses(lineView);else if(type=="widget")updateLineWidgets(cm,lineView,dims);}
|
94 |
-
lineView.changes=null;}
|
95 |
-
function ensureLineWrapped(lineView){if(lineView.node==lineView.text){lineView.node=elt("div",null,null,"position: relative");if(lineView.text.parentNode)
|
96 |
-
lineView.text.parentNode.replaceChild(lineView.node,lineView.text);lineView.node.appendChild(lineView.text);if(ie&&ie_version<8)lineView.node.style.zIndex=2;}
|
97 |
-
return lineView.node;}
|
98 |
-
function updateLineBackground(lineView){var cls=lineView.bgClass?lineView.bgClass+" "+(lineView.line.bgClass||""):lineView.line.bgClass;if(cls)cls+=" CodeMirror-linebackground";if(lineView.background){if(cls)lineView.background.className=cls;else{lineView.background.parentNode.removeChild(lineView.background);lineView.background=null;}}else if(cls){var wrap=ensureLineWrapped(lineView);lineView.background=wrap.insertBefore(elt("div",null,cls),wrap.firstChild);}}
|
99 |
-
function getLineContent(cm,lineView){var ext=cm.display.externalMeasured;if(ext&&ext.line==lineView.line){cm.display.externalMeasured=null;lineView.measure=ext.measure;return ext.built;}
|
100 |
-
return buildLineContent(cm,lineView);}
|
101 |
-
function updateLineText(cm,lineView){var cls=lineView.text.className;var built=getLineContent(cm,lineView);if(lineView.text==lineView.node)lineView.node=built.pre;lineView.text.parentNode.replaceChild(built.pre,lineView.text);lineView.text=built.pre;if(built.bgClass!=lineView.bgClass||built.textClass!=lineView.textClass){lineView.bgClass=built.bgClass;lineView.textClass=built.textClass;updateLineClasses(lineView);}else if(cls){lineView.text.className=cls;}}
|
102 |
-
function updateLineClasses(lineView){updateLineBackground(lineView);if(lineView.line.wrapClass)
|
103 |
-
ensureLineWrapped(lineView).className=lineView.line.wrapClass;else if(lineView.node!=lineView.text)
|
104 |
-
lineView.node.className="";var textClass=lineView.textClass?lineView.textClass+" "+(lineView.line.textClass||""):lineView.line.textClass;lineView.text.className=textClass||"";}
|
105 |
-
function updateLineGutter(cm,lineView,lineN,dims){if(lineView.gutter){lineView.node.removeChild(lineView.gutter);lineView.gutter=null;}
|
106 |
-
var markers=lineView.line.gutterMarkers;if(cm.options.lineNumbers||markers){var wrap=ensureLineWrapped(lineView);var gutterWrap=lineView.gutter=elt("div",null,"CodeMirror-gutter-wrapper","left: "+
|
107 |
-
(cm.options.fixedGutter?dims.fixedPos:-dims.gutterTotalWidth)+"px; width: "+dims.gutterTotalWidth+"px");cm.display.input.setUneditable(gutterWrap);wrap.insertBefore(gutterWrap,lineView.text);if(lineView.line.gutterClass)
|
108 |
-
gutterWrap.className+=" "+lineView.line.gutterClass;if(cm.options.lineNumbers&&(!markers||!markers["CodeMirror-linenumbers"]))
|
109 |
-
lineView.lineNumber=gutterWrap.appendChild(elt("div",lineNumberFor(cm.options,lineN),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+dims.gutterLeft["CodeMirror-linenumbers"]+"px; width: "
|
110 |
-
+cm.display.lineNumInnerWidth+"px"));if(markers)for(var k=0;k<cm.options.gutters.length;++k){var id=cm.options.gutters[k],found=markers.hasOwnProperty(id)&&markers[id];if(found)
|
111 |
-
gutterWrap.appendChild(elt("div",[found],"CodeMirror-gutter-elt","left: "+
|
112 |
-
dims.gutterLeft[id]+"px; width: "+dims.gutterWidth[id]+"px"));}}}
|
113 |
-
function updateLineWidgets(cm,lineView,dims){if(lineView.alignable)lineView.alignable=null;for(var node=lineView.node.firstChild,next;node;node=next){var next=node.nextSibling;if(node.className=="CodeMirror-linewidget")
|
114 |
-
lineView.node.removeChild(node);}
|
115 |
-
insertLineWidgets(cm,lineView,dims);}
|
116 |
-
function buildLineElement(cm,lineView,lineN,dims){var built=getLineContent(cm,lineView);lineView.text=lineView.node=built.pre;if(built.bgClass)lineView.bgClass=built.bgClass;if(built.textClass)lineView.textClass=built.textClass;updateLineClasses(lineView);updateLineGutter(cm,lineView,lineN,dims);insertLineWidgets(cm,lineView,dims);return lineView.node;}
|
117 |
-
function insertLineWidgets(cm,lineView,dims){insertLineWidgetsFor(cm,lineView.line,lineView,dims,true);if(lineView.rest)for(var i=0;i<lineView.rest.length;i++)
|
118 |
-
insertLineWidgetsFor(cm,lineView.rest[i],lineView,dims,false);}
|
119 |
-
function insertLineWidgetsFor(cm,line,lineView,dims,allowAbove){if(!line.widgets)return;var wrap=ensureLineWrapped(lineView);for(var i=0,ws=line.widgets;i<ws.length;++i){var widget=ws[i],node=elt("div",[widget.node],"CodeMirror-linewidget");if(!widget.handleMouseEvents)node.setAttribute("cm-ignore-events","true");positionLineWidget(widget,node,lineView,dims);cm.display.input.setUneditable(node);if(allowAbove&&widget.above)
|
120 |
-
wrap.insertBefore(node,lineView.gutter||lineView.text);else
|
121 |
-
wrap.appendChild(node);signalLater(widget,"redraw");}}
|
122 |
-
function positionLineWidget(widget,node,lineView,dims){if(widget.noHScroll){(lineView.alignable||(lineView.alignable=[])).push(node);var width=dims.wrapperWidth;node.style.left=dims.fixedPos+"px";if(!widget.coverGutter){width-=dims.gutterTotalWidth;node.style.paddingLeft=dims.gutterTotalWidth+"px";}
|
123 |
-
node.style.width=width+"px";}
|
124 |
-
if(widget.coverGutter){node.style.zIndex=5;node.style.position="relative";if(!widget.noHScroll)node.style.marginLeft=-dims.gutterTotalWidth+"px";}}
|
125 |
-
var Pos=CodeMirror.Pos=function(line,ch){if(!(this instanceof Pos))return new Pos(line,ch);this.line=line;this.ch=ch;};var cmp=CodeMirror.cmpPos=function(a,b){return a.line-b.line||a.ch-b.ch;};function copyPos(x){return Pos(x.line,x.ch);}
|
126 |
-
function maxPos(a,b){return cmp(a,b)<0?b:a;}
|
127 |
-
function minPos(a,b){return cmp(a,b)<0?a:b;}
|
128 |
-
function ensureFocus(cm){if(!cm.state.focused){cm.display.input.focus();onFocus(cm);}}
|
129 |
-
function isReadOnly(cm){return cm.options.readOnly||cm.doc.cantEdit;}
|
130 |
-
var lastCopied=null;function applyTextInput(cm,inserted,deleted,sel,origin){var doc=cm.doc;cm.display.shift=false;if(!sel)sel=doc.sel;var textLines=splitLines(inserted),multiPaste=null;if(cm.state.pasteIncoming&&sel.ranges.length>1){if(lastCopied&&lastCopied.join("\n")==inserted)
|
131 |
-
multiPaste=sel.ranges.length%lastCopied.length==0&&map(lastCopied,splitLines);else if(textLines.length==sel.ranges.length)
|
132 |
-
multiPaste=map(textLines,function(l){return[l];});}
|
133 |
-
for(var i=sel.ranges.length-1;i>=0;i--){var range=sel.ranges[i];var from=range.from(),to=range.to();if(range.empty()){if(deleted&&deleted>0)
|
134 |
-
from=Pos(from.line,from.ch-deleted);else if(cm.state.overwrite&&!cm.state.pasteIncoming)
|
135 |
-
to=Pos(to.line,Math.min(getLine(doc,to.line).text.length,to.ch+lst(textLines).length));}
|
136 |
-
var updateInput=cm.curOp.updateInput;var changeEvent={from:from,to:to,text:multiPaste?multiPaste[i%multiPaste.length]:textLines,origin:origin||(cm.state.pasteIncoming?"paste":cm.state.cutIncoming?"cut":"+input")};makeChange(cm.doc,changeEvent);signalLater(cm,"inputRead",cm,changeEvent);if(inserted&&!cm.state.pasteIncoming&&cm.options.electricChars&&cm.options.smartIndent&&range.head.ch<100&&(!i||sel.ranges[i-1].head.line!=range.head.line)){var mode=cm.getModeAt(range.head);var end=changeEnd(changeEvent);var indented=false;if(mode.electricChars){for(var j=0;j<mode.electricChars.length;j++)
|
137 |
-
if(inserted.indexOf(mode.electricChars.charAt(j))>-1){indented=indentLine(cm,end.line,"smart");break;}}else if(mode.electricInput){if(mode.electricInput.test(getLine(doc,end.line).text.slice(0,end.ch)))
|
138 |
-
indented=indentLine(cm,end.line,"smart");}
|
139 |
-
if(indented)signalLater(cm,"electricInput",cm,end.line);}}
|
140 |
-
ensureCursorVisible(cm);cm.curOp.updateInput=updateInput;cm.curOp.typing=true;cm.state.pasteIncoming=cm.state.cutIncoming=false;}
|
141 |
-
function copyableRanges(cm){var text=[],ranges=[];for(var i=0;i<cm.doc.sel.ranges.length;i++){var line=cm.doc.sel.ranges[i].head.line;var lineRange={anchor:Pos(line,0),head:Pos(line+1,0)};ranges.push(lineRange);text.push(cm.getRange(lineRange.anchor,lineRange.head));}
|
142 |
-
return{text:text,ranges:ranges};}
|
143 |
-
function disableBrowserMagic(field){field.setAttribute("autocorrect","off");field.setAttribute("autocapitalize","off");field.setAttribute("spellcheck","false");}
|
144 |
-
function TextareaInput(cm){this.cm=cm;this.prevInput="";this.pollingFast=false;this.polling=new Delayed();this.inaccurateSelection=false;this.hasSelection=false;this.composing=null;};function hiddenTextarea(){var te=elt("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none");var div=elt("div",[te],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");if(webkit)te.style.width="1000px";else te.setAttribute("wrap","off");if(ios)te.style.border="1px solid black";disableBrowserMagic(te);return div;}
|
145 |
-
TextareaInput.prototype=copyObj({init:function(display){var input=this,cm=this.cm;var div=this.wrapper=hiddenTextarea();var te=this.textarea=div.firstChild;display.wrapper.insertBefore(div,display.wrapper.firstChild);if(ios)te.style.width="0px";on(te,"input",function(){if(ie&&ie_version>=9&&input.hasSelection)input.hasSelection=null;input.poll();});on(te,"paste",function(){if(webkit&&!cm.state.fakedLastChar&&!(new Date-cm.state.lastMiddleDown<200)){var start=te.selectionStart,end=te.selectionEnd;te.value+="$";te.selectionEnd=end;te.selectionStart=start;cm.state.fakedLastChar=true;}
|
146 |
-
cm.state.pasteIncoming=true;input.fastPoll();});function prepareCopyCut(e){if(cm.somethingSelected()){lastCopied=cm.getSelections();if(input.inaccurateSelection){input.prevInput="";input.inaccurateSelection=false;te.value=lastCopied.join("\n");selectInput(te);}}else if(!cm.options.lineWiseCopyCut){return;}else{var ranges=copyableRanges(cm);lastCopied=ranges.text;if(e.type=="cut"){cm.setSelections(ranges.ranges,null,sel_dontScroll);}else{input.prevInput="";te.value=ranges.text.join("\n");selectInput(te);}}
|
147 |
-
if(e.type=="cut")cm.state.cutIncoming=true;}
|
148 |
-
on(te,"cut",prepareCopyCut);on(te,"copy",prepareCopyCut);on(display.scroller,"paste",function(e){if(eventInWidget(display,e))return;cm.state.pasteIncoming=true;input.focus();});on(display.lineSpace,"selectstart",function(e){if(!eventInWidget(display,e))e_preventDefault(e);});on(te,"compositionstart",function(){var start=cm.getCursor("from");input.composing={start:start,range:cm.markText(start,cm.getCursor("to"),{className:"CodeMirror-composing"})};});on(te,"compositionend",function(){if(input.composing){input.poll();input.composing.range.clear();input.composing=null;}});},prepareSelection:function(){var cm=this.cm,display=cm.display,doc=cm.doc;var result=prepareSelection(cm);if(cm.options.moveInputWithCursor){var headPos=cursorCoords(cm,doc.sel.primary().head,"div");var wrapOff=display.wrapper.getBoundingClientRect(),lineOff=display.lineDiv.getBoundingClientRect();result.teTop=Math.max(0,Math.min(display.wrapper.clientHeight-10,headPos.top+lineOff.top-wrapOff.top));result.teLeft=Math.max(0,Math.min(display.wrapper.clientWidth-10,headPos.left+lineOff.left-wrapOff.left));}
|
149 |
-
return result;},showSelection:function(drawn){var cm=this.cm,display=cm.display;removeChildrenAndAdd(display.cursorDiv,drawn.cursors);removeChildrenAndAdd(display.selectionDiv,drawn.selection);if(drawn.teTop!=null){this.wrapper.style.top=drawn.teTop+"px";this.wrapper.style.left=drawn.teLeft+"px";}},reset:function(typing){if(this.contextMenuPending)return;var minimal,selected,cm=this.cm,doc=cm.doc;if(cm.somethingSelected()){this.prevInput="";var range=doc.sel.primary();minimal=hasCopyEvent&&(range.to().line-range.from().line>100||(selected=cm.getSelection()).length>1000);var content=minimal?"-":selected||cm.getSelection();this.textarea.value=content;if(cm.state.focused)selectInput(this.textarea);if(ie&&ie_version>=9)this.hasSelection=content;}else if(!typing){this.prevInput=this.textarea.value="";if(ie&&ie_version>=9)this.hasSelection=null;}
|
150 |
-
this.inaccurateSelection=minimal;},getField:function(){return this.textarea;},supportsTouch:function(){return false;},focus:function(){if(this.cm.options.readOnly!="nocursor"&&(!mobile||activeElt()!=this.textarea)){try{this.textarea.focus();}
|
151 |
-
catch(e){}}},blur:function(){this.textarea.blur();},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0;},receivedFocus:function(){this.slowPoll();},slowPoll:function(){var input=this;if(input.pollingFast)return;input.polling.set(this.cm.options.pollInterval,function(){input.poll();if(input.cm.state.focused)input.slowPoll();});},fastPoll:function(){var missed=false,input=this;input.pollingFast=true;function p(){var changed=input.poll();if(!changed&&!missed){missed=true;input.polling.set(60,p);}
|
152 |
-
else{input.pollingFast=false;input.slowPoll();}}
|
153 |
-
input.polling.set(20,p);},poll:function(){var cm=this.cm,input=this.textarea,prevInput=this.prevInput;if(!cm.state.focused||(hasSelection(input)&&!prevInput)||isReadOnly(cm)||cm.options.disableInput||cm.state.keySeq)
|
154 |
-
return false;if(cm.state.pasteIncoming&&cm.state.fakedLastChar){input.value=input.value.substring(0,input.value.length-1);cm.state.fakedLastChar=false;}
|
155 |
-
var text=input.value;if(text==prevInput&&!cm.somethingSelected())return false;if(ie&&ie_version>=9&&this.hasSelection===text||mac&&/[\uf700-\uf7ff]/.test(text)){cm.display.input.reset();return false;}
|
156 |
-
if(cm.doc.sel==cm.display.selForContextMenu){var first=text.charCodeAt(0);if(first==0x200b&&!prevInput)prevInput="\u200b";if(first==0x21da){this.reset();return this.cm.execCommand("undo");}}
|
157 |
-
var same=0,l=Math.min(prevInput.length,text.length);while(same<l&&prevInput.charCodeAt(same)==text.charCodeAt(same))++same;var self=this;runInOp(cm,function(){applyTextInput(cm,text.slice(same),prevInput.length-same,null,self.composing?"*compose":null);if(text.length>1000||text.indexOf("\n")>-1)input.value=self.prevInput="";else self.prevInput=text;if(self.composing){self.composing.range.clear();self.composing.range=cm.markText(self.composing.start,cm.getCursor("to"),{className:"CodeMirror-composing"});}});return true;},ensurePolled:function(){if(this.pollingFast&&this.poll())this.pollingFast=false;},onKeyPress:function(){if(ie&&ie_version>=9)this.hasSelection=null;this.fastPoll();},onContextMenu:function(e){var input=this,cm=input.cm,display=cm.display,te=input.textarea;var pos=posFromMouse(cm,e),scrollPos=display.scroller.scrollTop;if(!pos||presto)return;var reset=cm.options.resetSelectionOnContextMenu;if(reset&&cm.doc.sel.contains(pos)==-1)
|
158 |
-
operation(cm,setSelection)(cm.doc,simpleSelection(pos),sel_dontScroll);var oldCSS=te.style.cssText;input.wrapper.style.position="absolute";te.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: "+
|
159 |
-
(ie?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";if(webkit)var oldScrollY=window.scrollY;display.input.focus();if(webkit)window.scrollTo(null,oldScrollY);display.input.reset();if(!cm.somethingSelected())te.value=input.prevInput=" ";input.contextMenuPending=true;display.selForContextMenu=cm.doc.sel;clearTimeout(display.detectingSelectAll);function prepareSelectAllHack(){if(te.selectionStart!=null){var selected=cm.somethingSelected();var extval="\u200b"+(selected?te.value:"");te.value="\u21da";te.value=extval;input.prevInput=selected?"":"\u200b";te.selectionStart=1;te.selectionEnd=extval.length;display.selForContextMenu=cm.doc.sel;}}
|
160 |
-
function rehide(){input.contextMenuPending=false;input.wrapper.style.position="relative";te.style.cssText=oldCSS;if(ie&&ie_version<9)display.scrollbars.setScrollTop(display.scroller.scrollTop=scrollPos);if(te.selectionStart!=null){if(!ie||(ie&&ie_version<9))prepareSelectAllHack();var i=0,poll=function(){if(display.selForContextMenu==cm.doc.sel&&te.selectionStart==0&&te.selectionEnd>0&&input.prevInput=="\u200b")
|
161 |
-
operation(cm,commands.selectAll)(cm);else if(i++<10)display.detectingSelectAll=setTimeout(poll,500);else display.input.reset();};display.detectingSelectAll=setTimeout(poll,200);}}
|
162 |
-
if(ie&&ie_version>=9)prepareSelectAllHack();if(captureRightClick){e_stop(e);var mouseup=function(){off(window,"mouseup",mouseup);setTimeout(rehide,20);};on(window,"mouseup",mouseup);}else{setTimeout(rehide,50);}},setUneditable:nothing,needsContentAttribute:false},TextareaInput.prototype);function ContentEditableInput(cm){this.cm=cm;this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null;this.polling=new Delayed();this.gracePeriod=false;}
|
163 |
-
ContentEditableInput.prototype=copyObj({init:function(display){var input=this,cm=input.cm;var div=input.div=display.lineDiv;div.contentEditable="true";disableBrowserMagic(div);on(div,"paste",function(e){var pasted=e.clipboardData&&e.clipboardData.getData("text/plain");if(pasted){e.preventDefault();cm.replaceSelection(pasted,null,"paste");}});on(div,"compositionstart",function(e){var data=e.data;input.composing={sel:cm.doc.sel,data:data,startData:data};if(!data)return;var prim=cm.doc.sel.primary();var line=cm.getLine(prim.head.line);var found=line.indexOf(data,Math.max(0,prim.head.ch-data.length));if(found>-1&&found<=prim.head.ch)
|
164 |
-
input.composing.sel=simpleSelection(Pos(prim.head.line,found),Pos(prim.head.line,found+data.length));});on(div,"compositionupdate",function(e){input.composing.data=e.data;});on(div,"compositionend",function(e){var ours=input.composing;if(!ours)return;if(e.data!=ours.startData&&!/\u200b/.test(e.data))
|
165 |
-
ours.data=e.data;setTimeout(function(){if(!ours.handled)
|
166 |
-
input.applyComposition(ours);if(input.composing==ours)
|
167 |
-
input.composing=null;},50);});on(div,"touchstart",function(){input.forceCompositionEnd();});on(div,"input",function(){if(input.composing)return;if(!input.pollContent())
|
168 |
-
runInOp(input.cm,function(){regChange(cm);});});function onCopyCut(e){if(cm.somethingSelected()){lastCopied=cm.getSelections();if(e.type=="cut")cm.replaceSelection("",null,"cut");}else if(!cm.options.lineWiseCopyCut){return;}else{var ranges=copyableRanges(cm);lastCopied=ranges.text;if(e.type=="cut"){cm.operation(function(){cm.setSelections(ranges.ranges,0,sel_dontScroll);cm.replaceSelection("",null,"cut");});}}
|
169 |
-
if(e.clipboardData&&!ios){e.preventDefault();e.clipboardData.clearData();e.clipboardData.setData("text/plain",lastCopied.join("\n"));}else{var kludge=hiddenTextarea(),te=kludge.firstChild;cm.display.lineSpace.insertBefore(kludge,cm.display.lineSpace.firstChild);te.value=lastCopied.join("\n");var hadFocus=document.activeElement;selectInput(te);setTimeout(function(){cm.display.lineSpace.removeChild(kludge);hadFocus.focus();},50);}}
|
170 |
-
on(div,"copy",onCopyCut);on(div,"cut",onCopyCut);},prepareSelection:function(){var result=prepareSelection(this.cm,false);result.focus=this.cm.state.focused;return result;},showSelection:function(info){if(!info||!this.cm.display.view.length)return;if(info.focus)this.showPrimarySelection();this.showMultipleSelections(info);},showPrimarySelection:function(){var sel=window.getSelection(),prim=this.cm.doc.sel.primary();var curAnchor=domToPos(this.cm,sel.anchorNode,sel.anchorOffset);var curFocus=domToPos(this.cm,sel.focusNode,sel.focusOffset);if(curAnchor&&!curAnchor.bad&&curFocus&&!curFocus.bad&&cmp(minPos(curAnchor,curFocus),prim.from())==0&&cmp(maxPos(curAnchor,curFocus),prim.to())==0)
|
171 |
-
return;var start=posToDOM(this.cm,prim.from());var end=posToDOM(this.cm,prim.to());if(!start&&!end)return;var view=this.cm.display.view;var old=sel.rangeCount&&sel.getRangeAt(0);if(!start){start={node:view[0].measure.map[2],offset:0};}else if(!end){var measure=view[view.length-1].measure;var map=measure.maps?measure.maps[measure.maps.length-1]:measure.map;end={node:map[map.length-1],offset:map[map.length-2]-map[map.length-3]};}
|
172 |
-
try{var rng=range(start.node,start.offset,end.offset,end.node);}
|
173 |
-
catch(e){}
|
174 |
-
if(rng){sel.removeAllRanges();sel.addRange(rng);if(old&&sel.anchorNode==null)sel.addRange(old);else if(gecko)this.startGracePeriod();}
|
175 |
-
this.rememberSelection();},startGracePeriod:function(){var input=this;clearTimeout(this.gracePeriod);this.gracePeriod=setTimeout(function(){input.gracePeriod=false;if(input.selectionChanged())
|
176 |
-
input.cm.operation(function(){input.cm.curOp.selectionChanged=true;});},20);},showMultipleSelections:function(info){removeChildrenAndAdd(this.cm.display.cursorDiv,info.cursors);removeChildrenAndAdd(this.cm.display.selectionDiv,info.selection);},rememberSelection:function(){var sel=window.getSelection();this.lastAnchorNode=sel.anchorNode;this.lastAnchorOffset=sel.anchorOffset;this.lastFocusNode=sel.focusNode;this.lastFocusOffset=sel.focusOffset;},selectionInEditor:function(){var sel=window.getSelection();if(!sel.rangeCount)return false;var node=sel.getRangeAt(0).commonAncestorContainer;return contains(this.div,node);},focus:function(){if(this.cm.options.readOnly!="nocursor")this.div.focus();},blur:function(){this.div.blur();},getField:function(){return this.div;},supportsTouch:function(){return true;},receivedFocus:function(){var input=this;if(this.selectionInEditor())
|
177 |
-
this.pollSelection();else
|
178 |
-
runInOp(this.cm,function(){input.cm.curOp.selectionChanged=true;});function poll(){if(input.cm.state.focused){input.pollSelection();input.polling.set(input.cm.options.pollInterval,poll);}}
|
179 |
-
this.polling.set(this.cm.options.pollInterval,poll);},selectionChanged:function(){var sel=window.getSelection();return sel.anchorNode!=this.lastAnchorNode||sel.anchorOffset!=this.lastAnchorOffset||sel.focusNode!=this.lastFocusNode||sel.focusOffset!=this.lastFocusOffset;},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var sel=window.getSelection(),cm=this.cm;this.rememberSelection();var anchor=domToPos(cm,sel.anchorNode,sel.anchorOffset);var head=domToPos(cm,sel.focusNode,sel.focusOffset);if(anchor&&head)runInOp(cm,function(){setSelection(cm.doc,simpleSelection(anchor,head),sel_dontScroll);if(anchor.bad||head.bad)cm.curOp.selectionChanged=true;});}},pollContent:function(){var cm=this.cm,display=cm.display,sel=cm.doc.sel.primary();var from=sel.from(),to=sel.to();if(from.line<display.viewFrom||to.line>display.viewTo-1)return false;var fromIndex;if(from.line==display.viewFrom||(fromIndex=findViewIndex(cm,from.line))==0){var fromLine=lineNo(display.view[0].line);var fromNode=display.view[0].node;}else{var fromLine=lineNo(display.view[fromIndex].line);var fromNode=display.view[fromIndex-1].node.nextSibling;}
|
180 |
-
var toIndex=findViewIndex(cm,to.line);if(toIndex==display.view.length-1){var toLine=display.viewTo-1;var toNode=display.view[toIndex].node;}else{var toLine=lineNo(display.view[toIndex+1].line)-1;var toNode=display.view[toIndex+1].node.previousSibling;}
|
181 |
-
var newText=splitLines(domTextBetween(cm,fromNode,toNode,fromLine,toLine));var oldText=getBetween(cm.doc,Pos(fromLine,0),Pos(toLine,getLine(cm.doc,toLine).text.length));while(newText.length>1&&oldText.length>1){if(lst(newText)==lst(oldText)){newText.pop();oldText.pop();toLine--;}
|
182 |
-
else if(newText[0]==oldText[0]){newText.shift();oldText.shift();fromLine++;}
|
183 |
-
else break;}
|
184 |
-
var cutFront=0,cutEnd=0;var newTop=newText[0],oldTop=oldText[0],maxCutFront=Math.min(newTop.length,oldTop.length);while(cutFront<maxCutFront&&newTop.charCodeAt(cutFront)==oldTop.charCodeAt(cutFront))
|
185 |
-
++cutFront;var newBot=lst(newText),oldBot=lst(oldText);var maxCutEnd=Math.min(newBot.length-(newText.length==1?cutFront:0),oldBot.length-(oldText.length==1?cutFront:0));while(cutEnd<maxCutEnd&&newBot.charCodeAt(newBot.length-cutEnd-1)==oldBot.charCodeAt(oldBot.length-cutEnd-1))
|
186 |
-
++cutEnd;newText[newText.length-1]=newBot.slice(0,newBot.length-cutEnd);newText[0]=newText[0].slice(cutFront);var chFrom=Pos(fromLine,cutFront);var chTo=Pos(toLine,oldText.length?lst(oldText).length-cutEnd:0);if(newText.length>1||newText[0]||cmp(chFrom,chTo)){replaceRange(cm.doc,newText,chFrom,chTo,"+input");return true;}},ensurePolled:function(){this.forceCompositionEnd();},reset:function(){this.forceCompositionEnd();},forceCompositionEnd:function(){if(!this.composing||this.composing.handled)return;this.applyComposition(this.composing);this.composing.handled=true;this.div.blur();this.div.focus();},applyComposition:function(composing){if(composing.data&&composing.data!=composing.startData)
|
187 |
-
operation(this.cm,applyTextInput)(this.cm,composing.data,0,composing.sel);},setUneditable:function(node){node.setAttribute("contenteditable","false");},onKeyPress:function(e){e.preventDefault();operation(this.cm,applyTextInput)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0);},onContextMenu:nothing,resetPosition:nothing,needsContentAttribute:true},ContentEditableInput.prototype);function posToDOM(cm,pos){var view=findViewForLine(cm,pos.line);if(!view||view.hidden)return null;var line=getLine(cm.doc,pos.line);var info=mapFromLineView(view,line,pos.line);var order=getOrder(line),side="left";if(order){var partPos=getBidiPartAt(order,pos.ch);side=partPos%2?"right":"left";}
|
188 |
-
var result=nodeAndOffsetInLineMap(info.map,pos.ch,"left");result.offset=result.collapse=="right"?result.end:result.start;return result;}
|
189 |
-
function badPos(pos,bad){if(bad)pos.bad=true;return pos;}
|
190 |
-
function domToPos(cm,node,offset){var lineNode;if(node==cm.display.lineDiv){lineNode=cm.display.lineDiv.childNodes[offset];if(!lineNode)return badPos(cm.clipPos(Pos(cm.display.viewTo-1)),true);node=null;offset=0;}else{for(lineNode=node;;lineNode=lineNode.parentNode){if(!lineNode||lineNode==cm.display.lineDiv)return null;if(lineNode.parentNode&&lineNode.parentNode==cm.display.lineDiv)break;}}
|
191 |
-
for(var i=0;i<cm.display.view.length;i++){var lineView=cm.display.view[i];if(lineView.node==lineNode)
|
192 |
-
return locateNodeInLineView(lineView,node,offset);}}
|
193 |
-
function locateNodeInLineView(lineView,node,offset){var wrapper=lineView.text.firstChild,bad=false;if(!node||!contains(wrapper,node))return badPos(Pos(lineNo(lineView.line),0),true);if(node==wrapper){bad=true;node=wrapper.childNodes[offset];offset=0;if(!node){var line=lineView.rest?lst(lineView.rest):lineView.line;return badPos(Pos(lineNo(line),line.text.length),bad);}}
|
194 |
-
var textNode=node.nodeType==3?node:null,topNode=node;if(!textNode&&node.childNodes.length==1&&node.firstChild.nodeType==3){textNode=node.firstChild;if(offset)offset=textNode.nodeValue.length;}
|
195 |
-
while(topNode.parentNode!=wrapper)topNode=topNode.parentNode;var measure=lineView.measure,maps=measure.maps;function find(textNode,topNode,offset){for(var i=-1;i<(maps?maps.length:0);i++){var map=i<0?measure.map:maps[i];for(var j=0;j<map.length;j+=3){var curNode=map[j+2];if(curNode==textNode||curNode==topNode){var line=lineNo(i<0?lineView.line:lineView.rest[i]);var ch=map[j]+offset;if(offset<0||curNode!=textNode)ch=map[j+(offset?1:0)];return Pos(line,ch);}}}}
|
196 |
-
var found=find(textNode,topNode,offset);if(found)return badPos(found,bad);for(var after=topNode.nextSibling,dist=textNode?textNode.nodeValue.length-offset:0;after;after=after.nextSibling){found=find(after,after.firstChild,0);if(found)
|
197 |
-
return badPos(Pos(found.line,found.ch-dist),bad);else
|
198 |
-
dist+=after.textContent.length;}
|
199 |
-
for(var before=topNode.previousSibling,dist=offset;before;before=before.previousSibling){found=find(before,before.firstChild,-1);if(found)
|
200 |
-
return badPos(Pos(found.line,found.ch+dist),bad);else
|
201 |
-
dist+=after.textContent.length;}}
|
202 |
-
function domTextBetween(cm,from,to,fromLine,toLine){var text="",closing=false;function recognizeMarker(id){return function(marker){return marker.id==id;};}
|
203 |
-
function walk(node){if(node.nodeType==1){var cmText=node.getAttribute("cm-text");if(cmText!=null){if(cmText=="")cmText=node.textContent.replace(/\u200b/g,"");text+=cmText;return;}
|
204 |
-
var markerID=node.getAttribute("cm-marker"),range;if(markerID){var found=cm.findMarks(Pos(fromLine,0),Pos(toLine+1,0),recognizeMarker(+markerID));if(found.length&&(range=found[0].find()))
|
205 |
-
text+=getBetween(cm.doc,range.from,range.to).join("\n");return;}
|
206 |
-
if(node.getAttribute("contenteditable")=="false")return;for(var i=0;i<node.childNodes.length;i++)
|
207 |
-
walk(node.childNodes[i]);if(/^(pre|div|p)$/i.test(node.nodeName))
|
208 |
-
closing=true;}else if(node.nodeType==3){var val=node.nodeValue;if(!val)return;if(closing){text+="\n";closing=false;}
|
209 |
-
text+=val;}}
|
210 |
-
for(;;){walk(from);if(from==to)break;from=from.nextSibling;}
|
211 |
-
return text;}
|
212 |
-
CodeMirror.inputStyles={"textarea":TextareaInput,"contenteditable":ContentEditableInput};function Selection(ranges,primIndex){this.ranges=ranges;this.primIndex=primIndex;}
|
213 |
-
Selection.prototype={primary:function(){return this.ranges[this.primIndex];},equals:function(other){if(other==this)return true;if(other.primIndex!=this.primIndex||other.ranges.length!=this.ranges.length)return false;for(var i=0;i<this.ranges.length;i++){var here=this.ranges[i],there=other.ranges[i];if(cmp(here.anchor,there.anchor)!=0||cmp(here.head,there.head)!=0)return false;}
|
214 |
-
return true;},deepCopy:function(){for(var out=[],i=0;i<this.ranges.length;i++)
|
215 |
-
out[i]=new Range(copyPos(this.ranges[i].anchor),copyPos(this.ranges[i].head));return new Selection(out,this.primIndex);},somethingSelected:function(){for(var i=0;i<this.ranges.length;i++)
|
216 |
-
if(!this.ranges[i].empty())return true;return false;},contains:function(pos,end){if(!end)end=pos;for(var i=0;i<this.ranges.length;i++){var range=this.ranges[i];if(cmp(end,range.from())>=0&&cmp(pos,range.to())<=0)
|
217 |
-
return i;}
|
218 |
-
return-1;}};function Range(anchor,head){this.anchor=anchor;this.head=head;}
|
219 |
-
Range.prototype={from:function(){return minPos(this.anchor,this.head);},to:function(){return maxPos(this.anchor,this.head);},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch;}};function normalizeSelection(ranges,primIndex){var prim=ranges[primIndex];ranges.sort(function(a,b){return cmp(a.from(),b.from());});primIndex=indexOf(ranges,prim);for(var i=1;i<ranges.length;i++){var cur=ranges[i],prev=ranges[i-1];if(cmp(prev.to(),cur.from())>=0){var from=minPos(prev.from(),cur.from()),to=maxPos(prev.to(),cur.to());var inv=prev.empty()?cur.from()==cur.head:prev.from()==prev.head;if(i<=primIndex)--primIndex;ranges.splice(--i,2,new Range(inv?to:from,inv?from:to));}}
|
220 |
-
return new Selection(ranges,primIndex);}
|
221 |
-
function simpleSelection(anchor,head){return new Selection([new Range(anchor,head||anchor)],0);}
|
222 |
-
function clipLine(doc,n){return Math.max(doc.first,Math.min(n,doc.first+doc.size-1));}
|
223 |
-
function clipPos(doc,pos){if(pos.line<doc.first)return Pos(doc.first,0);var last=doc.first+doc.size-1;if(pos.line>last)return Pos(last,getLine(doc,last).text.length);return clipToLen(pos,getLine(doc,pos.line).text.length);}
|
224 |
-
function clipToLen(pos,linelen){var ch=pos.ch;if(ch==null||ch>linelen)return Pos(pos.line,linelen);else if(ch<0)return Pos(pos.line,0);else return pos;}
|
225 |
-
function isLine(doc,l){return l>=doc.first&&l<doc.first+doc.size;}
|
226 |
-
function clipPosArray(doc,array){for(var out=[],i=0;i<array.length;i++)out[i]=clipPos(doc,array[i]);return out;}
|
227 |
-
function extendRange(doc,range,head,other){if(doc.cm&&doc.cm.display.shift||doc.extend){var anchor=range.anchor;if(other){var posBefore=cmp(head,anchor)<0;if(posBefore!=(cmp(other,anchor)<0)){anchor=head;head=other;}else if(posBefore!=(cmp(head,other)<0)){head=other;}}
|
228 |
-
return new Range(anchor,head);}else{return new Range(other||head,head);}}
|
229 |
-
function extendSelection(doc,head,other,options){setSelection(doc,new Selection([extendRange(doc,doc.sel.primary(),head,other)],0),options);}
|
230 |
-
function extendSelections(doc,heads,options){for(var out=[],i=0;i<doc.sel.ranges.length;i++)
|
231 |
-
out[i]=extendRange(doc,doc.sel.ranges[i],heads[i],null);var newSel=normalizeSelection(out,doc.sel.primIndex);setSelection(doc,newSel,options);}
|
232 |
-
function replaceOneSelection(doc,i,range,options){var ranges=doc.sel.ranges.slice(0);ranges[i]=range;setSelection(doc,normalizeSelection(ranges,doc.sel.primIndex),options);}
|
233 |
-
function setSimpleSelection(doc,anchor,head,options){setSelection(doc,simpleSelection(anchor,head),options);}
|
234 |
-
function filterSelectionChange(doc,sel){var obj={ranges:sel.ranges,update:function(ranges){this.ranges=[];for(var i=0;i<ranges.length;i++)
|
235 |
-
this.ranges[i]=new Range(clipPos(doc,ranges[i].anchor),clipPos(doc,ranges[i].head));}};signal(doc,"beforeSelectionChange",doc,obj);if(doc.cm)signal(doc.cm,"beforeSelectionChange",doc.cm,obj);if(obj.ranges!=sel.ranges)return normalizeSelection(obj.ranges,obj.ranges.length-1);else return sel;}
|
236 |
-
function setSelectionReplaceHistory(doc,sel,options){var done=doc.history.done,last=lst(done);if(last&&last.ranges){done[done.length-1]=sel;setSelectionNoUndo(doc,sel,options);}else{setSelection(doc,sel,options);}}
|
237 |
-
function setSelection(doc,sel,options){setSelectionNoUndo(doc,sel,options);addSelectionToHistory(doc,doc.sel,doc.cm?doc.cm.curOp.id:NaN,options);}
|
238 |
-
function setSelectionNoUndo(doc,sel,options){if(hasHandler(doc,"beforeSelectionChange")||doc.cm&&hasHandler(doc.cm,"beforeSelectionChange"))
|
239 |
-
sel=filterSelectionChange(doc,sel);var bias=options&&options.bias||(cmp(sel.primary().head,doc.sel.primary().head)<0?-1:1);setSelectionInner(doc,skipAtomicInSelection(doc,sel,bias,true));if(!(options&&options.scroll===false)&&doc.cm)
|
240 |
-
ensureCursorVisible(doc.cm);}
|
241 |
-
function setSelectionInner(doc,sel){if(sel.equals(doc.sel))return;doc.sel=sel;if(doc.cm){doc.cm.curOp.updateInput=doc.cm.curOp.selectionChanged=true;signalCursorActivity(doc.cm);}
|
242 |
-
signalLater(doc,"cursorActivity",doc);}
|
243 |
-
function reCheckSelection(doc){setSelectionInner(doc,skipAtomicInSelection(doc,doc.sel,null,false),sel_dontScroll);}
|
244 |
-
function skipAtomicInSelection(doc,sel,bias,mayClear){var out;for(var i=0;i<sel.ranges.length;i++){var range=sel.ranges[i];var newAnchor=skipAtomic(doc,range.anchor,bias,mayClear);var newHead=skipAtomic(doc,range.head,bias,mayClear);if(out||newAnchor!=range.anchor||newHead!=range.head){if(!out)out=sel.ranges.slice(0,i);out[i]=new Range(newAnchor,newHead);}}
|
245 |
-
return out?normalizeSelection(out,sel.primIndex):sel;}
|
246 |
-
function skipAtomic(doc,pos,bias,mayClear){var flipped=false,curPos=pos;var dir=bias||1;doc.cantEdit=false;search:for(;;){var line=getLine(doc,curPos.line);if(line.markedSpans){for(var i=0;i<line.markedSpans.length;++i){var sp=line.markedSpans[i],m=sp.marker;if((sp.from==null||(m.inclusiveLeft?sp.from<=curPos.ch:sp.from<curPos.ch))&&(sp.to==null||(m.inclusiveRight?sp.to>=curPos.ch:sp.to>curPos.ch))){if(mayClear){signal(m,"beforeCursorEnter");if(m.explicitlyCleared){if(!line.markedSpans)break;else{--i;continue;}}}
|
247 |
-
if(!m.atomic)continue;var newPos=m.find(dir<0?-1:1);if(cmp(newPos,curPos)==0){newPos.ch+=dir;if(newPos.ch<0){if(newPos.line>doc.first)newPos=clipPos(doc,Pos(newPos.line-1));else newPos=null;}else if(newPos.ch>line.text.length){if(newPos.line<doc.first+doc.size-1)newPos=Pos(newPos.line+1,0);else newPos=null;}
|
248 |
-
if(!newPos){if(flipped){if(!mayClear)return skipAtomic(doc,pos,bias,true);doc.cantEdit=true;return Pos(doc.first,0);}
|
249 |
-
flipped=true;newPos=pos;dir=-dir;}}
|
250 |
-
curPos=newPos;continue search;}}}
|
251 |
-
return curPos;}}
|
252 |
-
function updateSelection(cm){cm.display.input.showSelection(cm.display.input.prepareSelection());}
|
253 |
-
function prepareSelection(cm,primary){var doc=cm.doc,result={};var curFragment=result.cursors=document.createDocumentFragment();var selFragment=result.selection=document.createDocumentFragment();for(var i=0;i<doc.sel.ranges.length;i++){if(primary===false&&i==doc.sel.primIndex)continue;var range=doc.sel.ranges[i];var collapsed=range.empty();if(collapsed||cm.options.showCursorWhenSelecting)
|
254 |
-
drawSelectionCursor(cm,range,curFragment);if(!collapsed)
|
255 |
-
drawSelectionRange(cm,range,selFragment);}
|
256 |
-
return result;}
|
257 |
-
function drawSelectionCursor(cm,range,output){var pos=cursorCoords(cm,range.head,"div",null,null,!cm.options.singleCursorHeightPerLine);var cursor=output.appendChild(elt("div","\u00a0","CodeMirror-cursor"));cursor.style.left=pos.left+"px";cursor.style.top=pos.top+"px";cursor.style.height=Math.max(0,pos.bottom-pos.top)*cm.options.cursorHeight+"px";if(pos.other){var otherCursor=output.appendChild(elt("div","\u00a0","CodeMirror-cursor CodeMirror-secondarycursor"));otherCursor.style.display="";otherCursor.style.left=pos.other.left+"px";otherCursor.style.top=pos.other.top+"px";otherCursor.style.height=(pos.other.bottom-pos.other.top)*.85+"px";}}
|
258 |
-
function drawSelectionRange(cm,range,output){var display=cm.display,doc=cm.doc;var fragment=document.createDocumentFragment();var padding=paddingH(cm.display),leftSide=padding.left;var rightSide=Math.max(display.sizerWidth,displayWidth(cm)-display.sizer.offsetLeft)-padding.right;function add(left,top,width,bottom){if(top<0)top=0;top=Math.round(top);bottom=Math.round(bottom);fragment.appendChild(elt("div",null,"CodeMirror-selected","position: absolute; left: "+left+"px; top: "+top+"px; width: "+(width==null?rightSide-left:width)+"px; height: "+(bottom-top)+"px"));}
|
259 |
-
function drawForLine(line,fromArg,toArg){var lineObj=getLine(doc,line);var lineLen=lineObj.text.length;var start,end;function coords(ch,bias){return charCoords(cm,Pos(line,ch),"div",lineObj,bias);}
|
260 |
-
iterateBidiSections(getOrder(lineObj),fromArg||0,toArg==null?lineLen:toArg,function(from,to,dir){var leftPos=coords(from,"left"),rightPos,left,right;if(from==to){rightPos=leftPos;left=right=leftPos.left;}else{rightPos=coords(to-1,"right");if(dir=="rtl"){var tmp=leftPos;leftPos=rightPos;rightPos=tmp;}
|
261 |
-
left=leftPos.left;right=rightPos.right;}
|
262 |
-
if(fromArg==null&&from==0)left=leftSide;if(rightPos.top-leftPos.top>3){add(left,leftPos.top,null,leftPos.bottom);left=leftSide;if(leftPos.bottom<rightPos.top)add(left,leftPos.bottom,null,rightPos.top);}
|
263 |
-
if(toArg==null&&to==lineLen)right=rightSide;if(!start||leftPos.top<start.top||leftPos.top==start.top&&leftPos.left<start.left)
|
264 |
-
start=leftPos;if(!end||rightPos.bottom>end.bottom||rightPos.bottom==end.bottom&&rightPos.right>end.right)
|
265 |
-
end=rightPos;if(left<leftSide+1)left=leftSide;add(left,rightPos.top,right-left,rightPos.bottom);});return{start:start,end:end};}
|
266 |
-
var sFrom=range.from(),sTo=range.to();if(sFrom.line==sTo.line){drawForLine(sFrom.line,sFrom.ch,sTo.ch);}else{var fromLine=getLine(doc,sFrom.line),toLine=getLine(doc,sTo.line);var singleVLine=visualLine(fromLine)==visualLine(toLine);var leftEnd=drawForLine(sFrom.line,sFrom.ch,singleVLine?fromLine.text.length+1:null).end;var rightStart=drawForLine(sTo.line,singleVLine?0:null,sTo.ch).start;if(singleVLine){if(leftEnd.top<rightStart.top-2){add(leftEnd.right,leftEnd.top,null,leftEnd.bottom);add(leftSide,rightStart.top,rightStart.left,rightStart.bottom);}else{add(leftEnd.right,leftEnd.top,rightStart.left-leftEnd.right,leftEnd.bottom);}}
|
267 |
-
if(leftEnd.bottom<rightStart.top)
|
268 |
-
add(leftSide,leftEnd.bottom,null,rightStart.top);}
|
269 |
-
output.appendChild(fragment);}
|
270 |
-
function restartBlink(cm){if(!cm.state.focused)return;var display=cm.display;clearInterval(display.blinker);var on=true;display.cursorDiv.style.visibility="";if(cm.options.cursorBlinkRate>0)
|
271 |
-
display.blinker=setInterval(function(){display.cursorDiv.style.visibility=(on=!on)?"":"hidden";},cm.options.cursorBlinkRate);else if(cm.options.cursorBlinkRate<0)
|
272 |
-
display.cursorDiv.style.visibility="hidden";}
|
273 |
-
function startWorker(cm,time){if(cm.doc.mode.startState&&cm.doc.frontier<cm.display.viewTo)
|
274 |
-
cm.state.highlight.set(time,bind(highlightWorker,cm));}
|
275 |
-
function highlightWorker(cm){var doc=cm.doc;if(doc.frontier<doc.first)doc.frontier=doc.first;if(doc.frontier>=cm.display.viewTo)return;var end=+new Date+cm.options.workTime;var state=copyState(doc.mode,getStateBefore(cm,doc.frontier));var changedLines=[];doc.iter(doc.frontier,Math.min(doc.first+doc.size,cm.display.viewTo+500),function(line){if(doc.frontier>=cm.display.viewFrom){var oldStyles=line.styles;var highlighted=highlightLine(cm,line,state,true);line.styles=highlighted.styles;var oldCls=line.styleClasses,newCls=highlighted.classes;if(newCls)line.styleClasses=newCls;else if(oldCls)line.styleClasses=null;var ischange=!oldStyles||oldStyles.length!=line.styles.length||oldCls!=newCls&&(!oldCls||!newCls||oldCls.bgClass!=newCls.bgClass||oldCls.textClass!=newCls.textClass);for(var i=0;!ischange&&i<oldStyles.length;++i)ischange=oldStyles[i]!=line.styles[i];if(ischange)changedLines.push(doc.frontier);line.stateAfter=copyState(doc.mode,state);}else{processLine(cm,line.text,state);line.stateAfter=doc.frontier%5==0?copyState(doc.mode,state):null;}
|
276 |
-
++doc.frontier;if(+new Date>end){startWorker(cm,cm.options.workDelay);return true;}});if(changedLines.length)runInOp(cm,function(){for(var i=0;i<changedLines.length;i++)
|
277 |
-
regLineChange(cm,changedLines[i],"text");});}
|
278 |
-
function findStartLine(cm,n,precise){var minindent,minline,doc=cm.doc;var lim=precise?-1:n-(cm.doc.mode.innerMode?1000:100);for(var search=n;search>lim;--search){if(search<=doc.first)return doc.first;var line=getLine(doc,search-1);if(line.stateAfter&&(!precise||search<=doc.frontier))return search;var indented=countColumn(line.text,null,cm.options.tabSize);if(minline==null||minindent>indented){minline=search-1;minindent=indented;}}
|
279 |
-
return minline;}
|
280 |
-
function getStateBefore(cm,n,precise){var doc=cm.doc,display=cm.display;if(!doc.mode.startState)return true;var pos=findStartLine(cm,n,precise),state=pos>doc.first&&getLine(doc,pos-1).stateAfter;if(!state)state=startState(doc.mode);else state=copyState(doc.mode,state);doc.iter(pos,n,function(line){processLine(cm,line.text,state);var save=pos==n-1||pos%5==0||pos>=display.viewFrom&&pos<display.viewTo;line.stateAfter=save?copyState(doc.mode,state):null;++pos;});if(precise)doc.frontier=pos;return state;}
|
281 |
-
function paddingTop(display){return display.lineSpace.offsetTop;}
|
282 |
-
function paddingVert(display){return display.mover.offsetHeight-display.lineSpace.offsetHeight;}
|
283 |
-
function paddingH(display){if(display.cachedPaddingH)return display.cachedPaddingH;var e=removeChildrenAndAdd(display.measure,elt("pre","x"));var style=window.getComputedStyle?window.getComputedStyle(e):e.currentStyle;var data={left:parseInt(style.paddingLeft),right:parseInt(style.paddingRight)};if(!isNaN(data.left)&&!isNaN(data.right))display.cachedPaddingH=data;return data;}
|
284 |
-
function scrollGap(cm){return scrollerGap-cm.display.nativeBarWidth;}
|
285 |
-
function displayWidth(cm){return cm.display.scroller.clientWidth-scrollGap(cm)-cm.display.barWidth;}
|
286 |
-
function displayHeight(cm){return cm.display.scroller.clientHeight-scrollGap(cm)-cm.display.barHeight;}
|
287 |
-
function ensureLineHeights(cm,lineView,rect){var wrapping=cm.options.lineWrapping;var curWidth=wrapping&&displayWidth(cm);if(!lineView.measure.heights||wrapping&&lineView.measure.width!=curWidth){var heights=lineView.measure.heights=[];if(wrapping){lineView.measure.width=curWidth;var rects=lineView.text.firstChild.getClientRects();for(var i=0;i<rects.length-1;i++){var cur=rects[i],next=rects[i+1];if(Math.abs(cur.bottom-next.bottom)>2)
|
288 |
-
heights.push((cur.bottom+next.top)/2-rect.top);}}
|
289 |
-
heights.push(rect.bottom-rect.top);}}
|
290 |
-
function mapFromLineView(lineView,line,lineN){if(lineView.line==line)
|
291 |
-
return{map:lineView.measure.map,cache:lineView.measure.cache};for(var i=0;i<lineView.rest.length;i++)
|
292 |
-
if(lineView.rest[i]==line)
|
293 |
-
return{map:lineView.measure.maps[i],cache:lineView.measure.caches[i]};for(var i=0;i<lineView.rest.length;i++)
|
294 |
-
if(lineNo(lineView.rest[i])>lineN)
|
295 |
-
return{map:lineView.measure.maps[i],cache:lineView.measure.caches[i],before:true};}
|
296 |
-
function updateExternalMeasurement(cm,line){line=visualLine(line);var lineN=lineNo(line);var view=cm.display.externalMeasured=new LineView(cm.doc,line,lineN);view.lineN=lineN;var built=view.built=buildLineContent(cm,view);view.text=built.pre;removeChildrenAndAdd(cm.display.lineMeasure,built.pre);return view;}
|
297 |
-
function measureChar(cm,line,ch,bias){return measureCharPrepared(cm,prepareMeasureForLine(cm,line),ch,bias);}
|
298 |
-
function findViewForLine(cm,lineN){if(lineN>=cm.display.viewFrom&&lineN<cm.display.viewTo)
|
299 |
-
return cm.display.view[findViewIndex(cm,lineN)];var ext=cm.display.externalMeasured;if(ext&&lineN>=ext.lineN&&lineN<ext.lineN+ext.size)
|
300 |
-
return ext;}
|
301 |
-
function prepareMeasureForLine(cm,line){var lineN=lineNo(line);var view=findViewForLine(cm,lineN);if(view&&!view.text)
|
302 |
-
view=null;else if(view&&view.changes)
|
303 |
-
updateLineForChanges(cm,view,lineN,getDimensions(cm));if(!view)
|
304 |
-
view=updateExternalMeasurement(cm,line);var info=mapFromLineView(view,line,lineN);return{line:line,view:view,rect:null,map:info.map,cache:info.cache,before:info.before,hasHeights:false};}
|
305 |
-
function measureCharPrepared(cm,prepared,ch,bias,varHeight){if(prepared.before)ch=-1;var key=ch+(bias||""),found;if(prepared.cache.hasOwnProperty(key)){found=prepared.cache[key];}else{if(!prepared.rect)
|
306 |
-
prepared.rect=prepared.view.text.getBoundingClientRect();if(!prepared.hasHeights){ensureLineHeights(cm,prepared.view,prepared.rect);prepared.hasHeights=true;}
|
307 |
-
found=measureCharInner(cm,prepared,ch,bias);if(!found.bogus)prepared.cache[key]=found;}
|
308 |
-
return{left:found.left,right:found.right,top:varHeight?found.rtop:found.top,bottom:varHeight?found.rbottom:found.bottom};}
|
309 |
-
var nullRect={left:0,right:0,top:0,bottom:0};function nodeAndOffsetInLineMap(map,ch,bias){var node,start,end,collapse;for(var i=0;i<map.length;i+=3){var mStart=map[i],mEnd=map[i+1];if(ch<mStart){start=0;end=1;collapse="left";}else if(ch<mEnd){start=ch-mStart;end=start+1;}else if(i==map.length-3||ch==mEnd&&map[i+3]>ch){end=mEnd-mStart;start=end-1;if(ch>=mEnd)collapse="right";}
|
310 |
-
if(start!=null){node=map[i+2];if(mStart==mEnd&&bias==(node.insertLeft?"left":"right"))
|
311 |
-
collapse=bias;if(bias=="left"&&start==0)
|
312 |
-
while(i&&map[i-2]==map[i-3]&&map[i-1].insertLeft){node=map[(i-=3)+2];collapse="left";}
|
313 |
-
if(bias=="right"&&start==mEnd-mStart)
|
314 |
-
while(i<map.length-3&&map[i+3]==map[i+4]&&!map[i+5].insertLeft){node=map[(i+=3)+2];collapse="right";}
|
315 |
-
break;}}
|
316 |
-
return{node:node,start:start,end:end,collapse:collapse,coverStart:mStart,coverEnd:mEnd};}
|
317 |
-
function measureCharInner(cm,prepared,ch,bias){var place=nodeAndOffsetInLineMap(prepared.map,ch,bias);var node=place.node,start=place.start,end=place.end,collapse=place.collapse;var rect;if(node.nodeType==3){for(var i=0;i<4;i++){while(start&&isExtendingChar(prepared.line.text.charAt(place.coverStart+start)))--start;while(place.coverStart+end<place.coverEnd&&isExtendingChar(prepared.line.text.charAt(place.coverStart+end)))++end;if(ie&&ie_version<9&&start==0&&end==place.coverEnd-place.coverStart){rect=node.parentNode.getBoundingClientRect();}else if(ie&&cm.options.lineWrapping){var rects=range(node,start,end).getClientRects();if(rects.length)
|
318 |
-
rect=rects[bias=="right"?rects.length-1:0];else
|
319 |
-
rect=nullRect;}else{rect=range(node,start,end).getBoundingClientRect()||nullRect;}
|
320 |
-
if(rect.left||rect.right||start==0)break;end=start;start=start-1;collapse="right";}
|
321 |
-
if(ie&&ie_version<11)rect=maybeUpdateRectForZooming(cm.display.measure,rect);}else{if(start>0)collapse=bias="right";var rects;if(cm.options.lineWrapping&&(rects=node.getClientRects()).length>1)
|
322 |
-
rect=rects[bias=="right"?rects.length-1:0];else
|
323 |
-
rect=node.getBoundingClientRect();}
|
324 |
-
if(ie&&ie_version<9&&!start&&(!rect||!rect.left&&!rect.right)){var rSpan=node.parentNode.getClientRects()[0];if(rSpan)
|
325 |
-
rect={left:rSpan.left,right:rSpan.left+charWidth(cm.display),top:rSpan.top,bottom:rSpan.bottom};else
|
326 |
-
rect=nullRect;}
|
327 |
-
var rtop=rect.top-prepared.rect.top,rbot=rect.bottom-prepared.rect.top;var mid=(rtop+rbot)/2;var heights=prepared.view.measure.heights;for(var i=0;i<heights.length-1;i++)
|
328 |
-
if(mid<heights[i])break;var top=i?heights[i-1]:0,bot=heights[i];var result={left:(collapse=="right"?rect.right:rect.left)-prepared.rect.left,right:(collapse=="left"?rect.left:rect.right)-prepared.rect.left,top:top,bottom:bot};if(!rect.left&&!rect.right)result.bogus=true;if(!cm.options.singleCursorHeightPerLine){result.rtop=rtop;result.rbottom=rbot;}
|
329 |
-
return result;}
|
330 |
-
function maybeUpdateRectForZooming(measure,rect){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!hasBadZoomedRects(measure))
|
331 |
-
return rect;var scaleX=screen.logicalXDPI/screen.deviceXDPI;var scaleY=screen.logicalYDPI/screen.deviceYDPI;return{left:rect.left*scaleX,right:rect.right*scaleX,top:rect.top*scaleY,bottom:rect.bottom*scaleY};}
|
332 |
-
function clearLineMeasurementCacheFor(lineView){if(lineView.measure){lineView.measure.cache={};lineView.measure.heights=null;if(lineView.rest)for(var i=0;i<lineView.rest.length;i++)
|
333 |
-
lineView.measure.caches[i]={};}}
|
334 |
-
function clearLineMeasurementCache(cm){cm.display.externalMeasure=null;removeChildren(cm.display.lineMeasure);for(var i=0;i<cm.display.view.length;i++)
|
335 |
-
clearLineMeasurementCacheFor(cm.display.view[i]);}
|
336 |
-
function clearCaches(cm){clearLineMeasurementCache(cm);cm.display.cachedCharWidth=cm.display.cachedTextHeight=cm.display.cachedPaddingH=null;if(!cm.options.lineWrapping)cm.display.maxLineChanged=true;cm.display.lineNumChars=null;}
|
337 |
-
function pageScrollX(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft;}
|
338 |
-
function pageScrollY(){return window.pageYOffset||(document.documentElement||document.body).scrollTop;}
|
339 |
-
function intoCoordSystem(cm,lineObj,rect,context){if(lineObj.widgets)for(var i=0;i<lineObj.widgets.length;++i)if(lineObj.widgets[i].above){var size=widgetHeight(lineObj.widgets[i]);rect.top+=size;rect.bottom+=size;}
|
340 |
-
if(context=="line")return rect;if(!context)context="local";var yOff=heightAtLine(lineObj);if(context=="local")yOff+=paddingTop(cm.display);else yOff-=cm.display.viewOffset;if(context=="page"||context=="window"){var lOff=cm.display.lineSpace.getBoundingClientRect();yOff+=lOff.top+(context=="window"?0:pageScrollY());var xOff=lOff.left+(context=="window"?0:pageScrollX());rect.left+=xOff;rect.right+=xOff;}
|
341 |
-
rect.top+=yOff;rect.bottom+=yOff;return rect;}
|
342 |
-
function fromCoordSystem(cm,coords,context){if(context=="div")return coords;var left=coords.left,top=coords.top;if(context=="page"){left-=pageScrollX();top-=pageScrollY();}else if(context=="local"||!context){var localBox=cm.display.sizer.getBoundingClientRect();left+=localBox.left;top+=localBox.top;}
|
343 |
-
var lineSpaceBox=cm.display.lineSpace.getBoundingClientRect();return{left:left-lineSpaceBox.left,top:top-lineSpaceBox.top};}
|
344 |
-
function charCoords(cm,pos,context,lineObj,bias){if(!lineObj)lineObj=getLine(cm.doc,pos.line);return intoCoordSystem(cm,lineObj,measureChar(cm,lineObj,pos.ch,bias),context);}
|
345 |
-
function cursorCoords(cm,pos,context,lineObj,preparedMeasure,varHeight){lineObj=lineObj||getLine(cm.doc,pos.line);if(!preparedMeasure)preparedMeasure=prepareMeasureForLine(cm,lineObj);function get(ch,right){var m=measureCharPrepared(cm,preparedMeasure,ch,right?"right":"left",varHeight);if(right)m.left=m.right;else m.right=m.left;return intoCoordSystem(cm,lineObj,m,context);}
|
346 |
-
function getBidi(ch,partPos){var part=order[partPos],right=part.level%2;if(ch==bidiLeft(part)&&partPos&&part.level<order[partPos-1].level){part=order[--partPos];ch=bidiRight(part)-(part.level%2?0:1);right=true;}else if(ch==bidiRight(part)&&partPos<order.length-1&&part.level<order[partPos+1].level){part=order[++partPos];ch=bidiLeft(part)-part.level%2;right=false;}
|
347 |
-
if(right&&ch==part.to&&ch>part.from)return get(ch-1);return get(ch,right);}
|
348 |
-
var order=getOrder(lineObj),ch=pos.ch;if(!order)return get(ch);var partPos=getBidiPartAt(order,ch);var val=getBidi(ch,partPos);if(bidiOther!=null)val.other=getBidi(ch,bidiOther);return val;}
|
349 |
-
function estimateCoords(cm,pos){var left=0,pos=clipPos(cm.doc,pos);if(!cm.options.lineWrapping)left=charWidth(cm.display)*pos.ch;var lineObj=getLine(cm.doc,pos.line);var top=heightAtLine(lineObj)+paddingTop(cm.display);return{left:left,right:left,top:top,bottom:top+lineObj.height};}
|
350 |
-
function PosWithInfo(line,ch,outside,xRel){var pos=Pos(line,ch);pos.xRel=xRel;if(outside)pos.outside=true;return pos;}
|
351 |
-
function coordsChar(cm,x,y){var doc=cm.doc;y+=cm.display.viewOffset;if(y<0)return PosWithInfo(doc.first,0,true,-1);var lineN=lineAtHeight(doc,y),last=doc.first+doc.size-1;if(lineN>last)
|
352 |
-
return PosWithInfo(doc.first+doc.size-1,getLine(doc,last).text.length,true,1);if(x<0)x=0;var lineObj=getLine(doc,lineN);for(;;){var found=coordsCharInner(cm,lineObj,lineN,x,y);var merged=collapsedSpanAtEnd(lineObj);var mergedPos=merged&&merged.find(0,true);if(merged&&(found.ch>mergedPos.from.ch||found.ch==mergedPos.from.ch&&found.xRel>0))
|
353 |
-
lineN=lineNo(lineObj=mergedPos.to.line);else
|
354 |
-
return found;}}
|
355 |
-
function coordsCharInner(cm,lineObj,lineNo,x,y){var innerOff=y-heightAtLine(lineObj);var wrongLine=false,adjust=2*cm.display.wrapper.clientWidth;var preparedMeasure=prepareMeasureForLine(cm,lineObj);function getX(ch){var sp=cursorCoords(cm,Pos(lineNo,ch),"line",lineObj,preparedMeasure);wrongLine=true;if(innerOff>sp.bottom)return sp.left-adjust;else if(innerOff<sp.top)return sp.left+adjust;else wrongLine=false;return sp.left;}
|
356 |
-
var bidi=getOrder(lineObj),dist=lineObj.text.length;var from=lineLeft(lineObj),to=lineRight(lineObj);var fromX=getX(from),fromOutside=wrongLine,toX=getX(to),toOutside=wrongLine;if(x>toX)return PosWithInfo(lineNo,to,toOutside,1);for(;;){if(bidi?to==from||to==moveVisually(lineObj,from,1):to-from<=1){var ch=x<fromX||x-fromX<=toX-x?from:to;var xDiff=x-(ch==from?fromX:toX);while(isExtendingChar(lineObj.text.charAt(ch)))++ch;var pos=PosWithInfo(lineNo,ch,ch==from?fromOutside:toOutside,xDiff<-1?-1:xDiff>1?1:0);return pos;}
|
357 |
-
var step=Math.ceil(dist/2),middle=from+step;if(bidi){middle=from;for(var i=0;i<step;++i)middle=moveVisually(lineObj,middle,1);}
|
358 |
-
var middleX=getX(middle);if(middleX>x){to=middle;toX=middleX;if(toOutside=wrongLine)toX+=1000;dist=step;}
|
359 |
-
else{from=middle;fromX=middleX;fromOutside=wrongLine;dist-=step;}}}
|
360 |
-
var measureText;function textHeight(display){if(display.cachedTextHeight!=null)return display.cachedTextHeight;if(measureText==null){measureText=elt("pre");for(var i=0;i<49;++i){measureText.appendChild(document.createTextNode("x"));measureText.appendChild(elt("br"));}
|
361 |
-
measureText.appendChild(document.createTextNode("x"));}
|
362 |
-
removeChildrenAndAdd(display.measure,measureText);var height=measureText.offsetHeight/50;if(height>3)display.cachedTextHeight=height;removeChildren(display.measure);return height||1;}
|
363 |
-
function charWidth(display){if(display.cachedCharWidth!=null)return display.cachedCharWidth;var anchor=elt("span","xxxxxxxxxx");var pre=elt("pre",[anchor]);removeChildrenAndAdd(display.measure,pre);var rect=anchor.getBoundingClientRect(),width=(rect.right-rect.left)/10;if(width>2)display.cachedCharWidth=width;return width||10;}
|
364 |
-
var operationGroup=null;var nextOpId=0;function startOperation(cm){cm.curOp={cm:cm,viewChanged:false,startHeight:cm.doc.height,forceUpdate:false,updateInput:null,typing:false,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:false,updateMaxLine:false,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:false,id:++nextOpId};if(operationGroup){operationGroup.ops.push(cm.curOp);}else{cm.curOp.ownsGroup=operationGroup={ops:[cm.curOp],delayedCallbacks:[]};}}
|
365 |
-
function fireCallbacksForOps(group){var callbacks=group.delayedCallbacks,i=0;do{for(;i<callbacks.length;i++)
|
366 |
-
callbacks[i]();for(var j=0;j<group.ops.length;j++){var op=group.ops[j];if(op.cursorActivityHandlers)
|
367 |
-
while(op.cursorActivityCalled<op.cursorActivityHandlers.length)
|
368 |
-
op.cursorActivityHandlers[op.cursorActivityCalled++](op.cm);}}while(i<callbacks.length);}
|
369 |
-
function endOperation(cm){var op=cm.curOp,group=op.ownsGroup;if(!group)return;try{fireCallbacksForOps(group);}
|
370 |
-
finally{operationGroup=null;for(var i=0;i<group.ops.length;i++)
|
371 |
-
group.ops[i].cm.curOp=null;endOperations(group);}}
|
372 |
-
function endOperations(group){var ops=group.ops;for(var i=0;i<ops.length;i++)
|
373 |
-
endOperation_R1(ops[i]);for(var i=0;i<ops.length;i++)
|
374 |
-
endOperation_W1(ops[i]);for(var i=0;i<ops.length;i++)
|
375 |
-
endOperation_R2(ops[i]);for(var i=0;i<ops.length;i++)
|
376 |
-
endOperation_W2(ops[i]);for(var i=0;i<ops.length;i++)
|
377 |
-
endOperation_finish(ops[i]);}
|
378 |
-
function endOperation_R1(op){var cm=op.cm,display=cm.display;maybeClipScrollbars(cm);if(op.updateMaxLine)findMaxLine(cm);op.mustUpdate=op.viewChanged||op.forceUpdate||op.scrollTop!=null||op.scrollToPos&&(op.scrollToPos.from.line<display.viewFrom||op.scrollToPos.to.line>=display.viewTo)||display.maxLineChanged&&cm.options.lineWrapping;op.update=op.mustUpdate&&new DisplayUpdate(cm,op.mustUpdate&&{top:op.scrollTop,ensure:op.scrollToPos},op.forceUpdate);}
|
379 |
-
function endOperation_W1(op){op.updatedDisplay=op.mustUpdate&&updateDisplayIfNeeded(op.cm,op.update);}
|
380 |
-
function endOperation_R2(op){var cm=op.cm,display=cm.display;if(op.updatedDisplay)updateHeightsInViewport(cm);op.barMeasure=measureForScrollbars(cm);if(display.maxLineChanged&&!cm.options.lineWrapping){op.adjustWidthTo=measureChar(cm,display.maxLine,display.maxLine.text.length).left+3;cm.display.sizerWidth=op.adjustWidthTo;op.barMeasure.scrollWidth=Math.max(display.scroller.clientWidth,display.sizer.offsetLeft+op.adjustWidthTo+scrollGap(cm)+cm.display.barWidth);op.maxScrollLeft=Math.max(0,display.sizer.offsetLeft+op.adjustWidthTo-displayWidth(cm));}
|
381 |
-
if(op.updatedDisplay||op.selectionChanged)
|
382 |
-
op.preparedSelection=display.input.prepareSelection();}
|
383 |
-
function endOperation_W2(op){var cm=op.cm;if(op.adjustWidthTo!=null){cm.display.sizer.style.minWidth=op.adjustWidthTo+"px";if(op.maxScrollLeft<cm.doc.scrollLeft)
|
384 |
-
setScrollLeft(cm,Math.min(cm.display.scroller.scrollLeft,op.maxScrollLeft),true);cm.display.maxLineChanged=false;}
|
385 |
-
if(op.preparedSelection)
|
386 |
-
cm.display.input.showSelection(op.preparedSelection);if(op.updatedDisplay)
|
387 |
-
setDocumentHeight(cm,op.barMeasure);if(op.updatedDisplay||op.startHeight!=cm.doc.height)
|
388 |
-
updateScrollbars(cm,op.barMeasure);if(op.selectionChanged)restartBlink(cm);if(cm.state.focused&&op.updateInput)
|
389 |
-
cm.display.input.reset(op.typing);if(op.focus&&op.focus==activeElt())ensureFocus(op.cm);}
|
390 |
-
function endOperation_finish(op){var cm=op.cm,display=cm.display,doc=cm.doc;if(op.updatedDisplay)postUpdateDisplay(cm,op.update);if(display.wheelStartX!=null&&(op.scrollTop!=null||op.scrollLeft!=null||op.scrollToPos))
|
391 |
-
display.wheelStartX=display.wheelStartY=null;if(op.scrollTop!=null&&(display.scroller.scrollTop!=op.scrollTop||op.forceScroll)){doc.scrollTop=Math.max(0,Math.min(display.scroller.scrollHeight-display.scroller.clientHeight,op.scrollTop));display.scrollbars.setScrollTop(doc.scrollTop);display.scroller.scrollTop=doc.scrollTop;}
|
392 |
-
if(op.scrollLeft!=null&&(display.scroller.scrollLeft!=op.scrollLeft||op.forceScroll)){doc.scrollLeft=Math.max(0,Math.min(display.scroller.scrollWidth-displayWidth(cm),op.scrollLeft));display.scrollbars.setScrollLeft(doc.scrollLeft);display.scroller.scrollLeft=doc.scrollLeft;alignHorizontally(cm);}
|
393 |
-
if(op.scrollToPos){var coords=scrollPosIntoView(cm,clipPos(doc,op.scrollToPos.from),clipPos(doc,op.scrollToPos.to),op.scrollToPos.margin);if(op.scrollToPos.isCursor&&cm.state.focused)maybeScrollWindow(cm,coords);}
|
394 |
-
var hidden=op.maybeHiddenMarkers,unhidden=op.maybeUnhiddenMarkers;if(hidden)for(var i=0;i<hidden.length;++i)
|
395 |
-
if(!hidden[i].lines.length)signal(hidden[i],"hide");if(unhidden)for(var i=0;i<unhidden.length;++i)
|
396 |
-
if(unhidden[i].lines.length)signal(unhidden[i],"unhide");if(display.wrapper.offsetHeight)
|
397 |
-
doc.scrollTop=cm.display.scroller.scrollTop;if(op.changeObjs)
|
398 |
-
signal(cm,"changes",cm,op.changeObjs);if(op.update)
|
399 |
-
op.update.finish();}
|
400 |
-
function runInOp(cm,f){if(cm.curOp)return f();startOperation(cm);try{return f();}
|
401 |
-
finally{endOperation(cm);}}
|
402 |
-
function operation(cm,f){return function(){if(cm.curOp)return f.apply(cm,arguments);startOperation(cm);try{return f.apply(cm,arguments);}
|
403 |
-
finally{endOperation(cm);}};}
|
404 |
-
function methodOp(f){return function(){if(this.curOp)return f.apply(this,arguments);startOperation(this);try{return f.apply(this,arguments);}
|
405 |
-
finally{endOperation(this);}};}
|
406 |
-
function docMethodOp(f){return function(){var cm=this.cm;if(!cm||cm.curOp)return f.apply(this,arguments);startOperation(cm);try{return f.apply(this,arguments);}
|
407 |
-
finally{endOperation(cm);}};}
|
408 |
-
function LineView(doc,line,lineN){this.line=line;this.rest=visualLineContinued(line);this.size=this.rest?lineNo(lst(this.rest))-lineN+1:1;this.node=this.text=null;this.hidden=lineIsHidden(doc,line);}
|
409 |
-
function buildViewArray(cm,from,to){var array=[],nextPos;for(var pos=from;pos<to;pos=nextPos){var view=new LineView(cm.doc,getLine(cm.doc,pos),pos);nextPos=pos+view.size;array.push(view);}
|
410 |
-
return array;}
|
411 |
-
function regChange(cm,from,to,lendiff){if(from==null)from=cm.doc.first;if(to==null)to=cm.doc.first+cm.doc.size;if(!lendiff)lendiff=0;var display=cm.display;if(lendiff&&to<display.viewTo&&(display.updateLineNumbers==null||display.updateLineNumbers>from))
|
412 |
-
display.updateLineNumbers=from;cm.curOp.viewChanged=true;if(from>=display.viewTo){if(sawCollapsedSpans&&visualLineNo(cm.doc,from)<display.viewTo)
|
413 |
-
resetView(cm);}else if(to<=display.viewFrom){if(sawCollapsedSpans&&visualLineEndNo(cm.doc,to+lendiff)>display.viewFrom){resetView(cm);}else{display.viewFrom+=lendiff;display.viewTo+=lendiff;}}else if(from<=display.viewFrom&&to>=display.viewTo){resetView(cm);}else if(from<=display.viewFrom){var cut=viewCuttingPoint(cm,to,to+lendiff,1);if(cut){display.view=display.view.slice(cut.index);display.viewFrom=cut.lineN;display.viewTo+=lendiff;}else{resetView(cm);}}else if(to>=display.viewTo){var cut=viewCuttingPoint(cm,from,from,-1);if(cut){display.view=display.view.slice(0,cut.index);display.viewTo=cut.lineN;}else{resetView(cm);}}else{var cutTop=viewCuttingPoint(cm,from,from,-1);var cutBot=viewCuttingPoint(cm,to,to+lendiff,1);if(cutTop&&cutBot){display.view=display.view.slice(0,cutTop.index).concat(buildViewArray(cm,cutTop.lineN,cutBot.lineN)).concat(display.view.slice(cutBot.index));display.viewTo+=lendiff;}else{resetView(cm);}}
|
414 |
-
var ext=display.externalMeasured;if(ext){if(to<ext.lineN)
|
415 |
-
ext.lineN+=lendiff;else if(from<ext.lineN+ext.size)
|
416 |
-
display.externalMeasured=null;}}
|
417 |
-
function regLineChange(cm,line,type){cm.curOp.viewChanged=true;var display=cm.display,ext=cm.display.externalMeasured;if(ext&&line>=ext.lineN&&line<ext.lineN+ext.size)
|
418 |
-
display.externalMeasured=null;if(line<display.viewFrom||line>=display.viewTo)return;var lineView=display.view[findViewIndex(cm,line)];if(lineView.node==null)return;var arr=lineView.changes||(lineView.changes=[]);if(indexOf(arr,type)==-1)arr.push(type);}
|
419 |
-
function resetView(cm){cm.display.viewFrom=cm.display.viewTo=cm.doc.first;cm.display.view=[];cm.display.viewOffset=0;}
|
420 |
-
function findViewIndex(cm,n){if(n>=cm.display.viewTo)return null;n-=cm.display.viewFrom;if(n<0)return null;var view=cm.display.view;for(var i=0;i<view.length;i++){n-=view[i].size;if(n<0)return i;}}
|
421 |
-
function viewCuttingPoint(cm,oldN,newN,dir){var index=findViewIndex(cm,oldN),diff,view=cm.display.view;if(!sawCollapsedSpans||newN==cm.doc.first+cm.doc.size)
|
422 |
-
return{index:index,lineN:newN};for(var i=0,n=cm.display.viewFrom;i<index;i++)
|
423 |
-
n+=view[i].size;if(n!=oldN){if(dir>0){if(index==view.length-1)return null;diff=(n+view[index].size)-oldN;index++;}else{diff=n-oldN;}
|
424 |
-
oldN+=diff;newN+=diff;}
|
425 |
-
while(visualLineNo(cm.doc,newN)!=newN){if(index==(dir<0?0:view.length-1))return null;newN+=dir*view[index-(dir<0?1:0)].size;index+=dir;}
|
426 |
-
return{index:index,lineN:newN};}
|
427 |
-
function adjustView(cm,from,to){var display=cm.display,view=display.view;if(view.length==0||from>=display.viewTo||to<=display.viewFrom){display.view=buildViewArray(cm,from,to);display.viewFrom=from;}else{if(display.viewFrom>from)
|
428 |
-
display.view=buildViewArray(cm,from,display.viewFrom).concat(display.view);else if(display.viewFrom<from)
|
429 |
-
display.view=display.view.slice(findViewIndex(cm,from));display.viewFrom=from;if(display.viewTo<to)
|
430 |
-
display.view=display.view.concat(buildViewArray(cm,display.viewTo,to));else if(display.viewTo>to)
|
431 |
-
display.view=display.view.slice(0,findViewIndex(cm,to));}
|
432 |
-
display.viewTo=to;}
|
433 |
-
function countDirtyView(cm){var view=cm.display.view,dirty=0;for(var i=0;i<view.length;i++){var lineView=view[i];if(!lineView.hidden&&(!lineView.node||lineView.changes))++dirty;}
|
434 |
-
return dirty;}
|
435 |
-
function registerEventHandlers(cm){var d=cm.display;on(d.scroller,"mousedown",operation(cm,onMouseDown));if(ie&&ie_version<11)
|
436 |
-
on(d.scroller,"dblclick",operation(cm,function(e){if(signalDOMEvent(cm,e))return;var pos=posFromMouse(cm,e);if(!pos||clickInGutter(cm,e)||eventInWidget(cm.display,e))return;e_preventDefault(e);var word=cm.findWordAt(pos);extendSelection(cm.doc,word.anchor,word.head);}));else
|
437 |
-
on(d.scroller,"dblclick",function(e){signalDOMEvent(cm,e)||e_preventDefault(e);});if(!captureRightClick)on(d.scroller,"contextmenu",function(e){onContextMenu(cm,e);});var touchFinished,prevTouch={end:0};function finishTouch(){if(d.activeTouch){touchFinished=setTimeout(function(){d.activeTouch=null;},1000);prevTouch=d.activeTouch;prevTouch.end=+new Date;}};function isMouseLikeTouchEvent(e){if(e.touches.length!=1)return false;var touch=e.touches[0];return touch.radiusX<=1&&touch.radiusY<=1;}
|
438 |
-
function farAway(touch,other){if(other.left==null)return true;var dx=other.left-touch.left,dy=other.top-touch.top;return dx*dx+dy*dy>20*20;}
|
439 |
-
on(d.scroller,"touchstart",function(e){if(!isMouseLikeTouchEvent(e)){clearTimeout(touchFinished);var now=+new Date;d.activeTouch={start:now,moved:false,prev:now-prevTouch.end<=300?prevTouch:null};if(e.touches.length==1){d.activeTouch.left=e.touches[0].pageX;d.activeTouch.top=e.touches[0].pageY;}}});on(d.scroller,"touchmove",function(){if(d.activeTouch)d.activeTouch.moved=true;});on(d.scroller,"touchend",function(e){var touch=d.activeTouch;if(touch&&!eventInWidget(d,e)&&touch.left!=null&&!touch.moved&&new Date-touch.start<300){var pos=cm.coordsChar(d.activeTouch,"page"),range;if(!touch.prev||farAway(touch,touch.prev))
|
440 |
-
range=new Range(pos,pos);else if(!touch.prev.prev||farAway(touch,touch.prev.prev))
|
441 |
-
range=cm.findWordAt(pos);else
|
442 |
-
range=new Range(Pos(pos.line,0),clipPos(cm.doc,Pos(pos.line+1,0)));cm.setSelection(range.anchor,range.head);cm.focus();e_preventDefault(e);}
|
443 |
-
finishTouch();});on(d.scroller,"touchcancel",finishTouch);on(d.scroller,"scroll",function(){if(d.scroller.clientHeight){setScrollTop(cm,d.scroller.scrollTop);setScrollLeft(cm,d.scroller.scrollLeft,true);signal(cm,"scroll",cm);}});on(d.scroller,"mousewheel",function(e){onScrollWheel(cm,e);});on(d.scroller,"DOMMouseScroll",function(e){onScrollWheel(cm,e);});on(d.wrapper,"scroll",function(){d.wrapper.scrollTop=d.wrapper.scrollLeft=0;});d.dragFunctions={simple:function(e){if(!signalDOMEvent(cm,e))e_stop(e);},start:function(e){onDragStart(cm,e);},drop:operation(cm,onDrop)};var inp=d.input.getField();on(inp,"keyup",function(e){onKeyUp.call(cm,e);});on(inp,"keydown",operation(cm,onKeyDown));on(inp,"keypress",operation(cm,onKeyPress));on(inp,"focus",bind(onFocus,cm));on(inp,"blur",bind(onBlur,cm));}
|
444 |
-
function dragDropChanged(cm,value,old){var wasOn=old&&old!=CodeMirror.Init;if(!value!=!wasOn){var funcs=cm.display.dragFunctions;var toggle=value?on:off;toggle(cm.display.scroller,"dragstart",funcs.start);toggle(cm.display.scroller,"dragenter",funcs.simple);toggle(cm.display.scroller,"dragover",funcs.simple);toggle(cm.display.scroller,"drop",funcs.drop);}}
|
445 |
-
function onResize(cm){var d=cm.display;if(d.lastWrapHeight==d.wrapper.clientHeight&&d.lastWrapWidth==d.wrapper.clientWidth)
|
446 |
-
return;d.cachedCharWidth=d.cachedTextHeight=d.cachedPaddingH=null;d.scrollbarsClipped=false;cm.setSize();}
|
447 |
-
function eventInWidget(display,e){for(var n=e_target(e);n!=display.wrapper;n=n.parentNode){if(!n||(n.nodeType==1&&n.getAttribute("cm-ignore-events")=="true")||(n.parentNode==display.sizer&&n!=display.mover))
|
448 |
-
return true;}}
|
449 |
-
function posFromMouse(cm,e,liberal,forRect){var display=cm.display;if(!liberal&&e_target(e).getAttribute("cm-not-content")=="true")return null;var x,y,space=display.lineSpace.getBoundingClientRect();try{x=e.clientX-space.left;y=e.clientY-space.top;}
|
450 |
-
catch(e){return null;}
|
451 |
-
var coords=coordsChar(cm,x,y),line;if(forRect&&coords.xRel==1&&(line=getLine(cm.doc,coords.line).text).length==coords.ch){var colDiff=countColumn(line,line.length,cm.options.tabSize)-line.length;coords=Pos(coords.line,Math.max(0,Math.round((x-paddingH(cm.display).left)/charWidth(cm.display))-colDiff));}
|
452 |
-
return coords;}
|
453 |
-
function onMouseDown(e){var cm=this,display=cm.display;if(display.activeTouch&&display.input.supportsTouch()||signalDOMEvent(cm,e))return;display.shift=e.shiftKey;if(eventInWidget(display,e)){if(!webkit){display.scroller.draggable=false;setTimeout(function(){display.scroller.draggable=true;},100);}
|
454 |
-
return;}
|
455 |
-
if(clickInGutter(cm,e))return;var start=posFromMouse(cm,e);window.focus();switch(e_button(e)){case 1:if(start)
|
456 |
-
leftButtonDown(cm,e,start);else if(e_target(e)==display.scroller)
|
457 |
-
e_preventDefault(e);break;case 2:if(webkit)cm.state.lastMiddleDown=+new Date;if(start)extendSelection(cm.doc,start);setTimeout(function(){display.input.focus();},20);e_preventDefault(e);break;case 3:if(captureRightClick)onContextMenu(cm,e);else delayBlurEvent(cm);break;}}
|
458 |
-
var lastClick,lastDoubleClick;function leftButtonDown(cm,e,start){if(ie)setTimeout(bind(ensureFocus,cm),0);else cm.curOp.focus=activeElt();var now=+new Date,type;if(lastDoubleClick&&lastDoubleClick.time>now-400&&cmp(lastDoubleClick.pos,start)==0){type="triple";}else if(lastClick&&lastClick.time>now-400&&cmp(lastClick.pos,start)==0){type="double";lastDoubleClick={time:now,pos:start};}else{type="single";lastClick={time:now,pos:start};}
|
459 |
-
var sel=cm.doc.sel,modifier=mac?e.metaKey:e.ctrlKey,contained;if(cm.options.dragDrop&&dragAndDrop&&!isReadOnly(cm)&&type=="single"&&(contained=sel.contains(start))>-1&&!sel.ranges[contained].empty())
|
460 |
-
leftButtonStartDrag(cm,e,start,modifier);else
|
461 |
-
leftButtonSelect(cm,e,start,type,modifier);}
|
462 |
-
function leftButtonStartDrag(cm,e,start,modifier){var display=cm.display,startTime=+new Date;var dragEnd=operation(cm,function(e2){if(webkit)display.scroller.draggable=false;cm.state.draggingText=false;off(document,"mouseup",dragEnd);off(display.scroller,"drop",dragEnd);if(Math.abs(e.clientX-e2.clientX)+Math.abs(e.clientY-e2.clientY)<10){e_preventDefault(e2);if(!modifier&&+new Date-200<startTime)
|
463 |
-
extendSelection(cm.doc,start);if(webkit||ie&&ie_version==9)
|
464 |
-
setTimeout(function(){document.body.focus();display.input.focus();},20);else
|
465 |
-
display.input.focus();}});if(webkit)display.scroller.draggable=true;cm.state.draggingText=dragEnd;if(display.scroller.dragDrop)display.scroller.dragDrop();on(document,"mouseup",dragEnd);on(display.scroller,"drop",dragEnd);}
|
466 |
-
function leftButtonSelect(cm,e,start,type,addNew){var display=cm.display,doc=cm.doc;e_preventDefault(e);var ourRange,ourIndex,startSel=doc.sel,ranges=startSel.ranges;if(addNew&&!e.shiftKey){ourIndex=doc.sel.contains(start);if(ourIndex>-1)
|
467 |
-
ourRange=ranges[ourIndex];else
|
468 |
-
ourRange=new Range(start,start);}else{ourRange=doc.sel.primary();ourIndex=doc.sel.primIndex;}
|
469 |
-
if(e.altKey){type="rect";if(!addNew)ourRange=new Range(start,start);start=posFromMouse(cm,e,true,true);ourIndex=-1;}else if(type=="double"){var word=cm.findWordAt(start);if(cm.display.shift||doc.extend)
|
470 |
-
ourRange=extendRange(doc,ourRange,word.anchor,word.head);else
|
471 |
-
ourRange=word;}else if(type=="triple"){var line=new Range(Pos(start.line,0),clipPos(doc,Pos(start.line+1,0)));if(cm.display.shift||doc.extend)
|
472 |
-
ourRange=extendRange(doc,ourRange,line.anchor,line.head);else
|
473 |
-
ourRange=line;}else{ourRange=extendRange(doc,ourRange,start);}
|
474 |
-
if(!addNew){ourIndex=0;setSelection(doc,new Selection([ourRange],0),sel_mouse);startSel=doc.sel;}else if(ourIndex==-1){ourIndex=ranges.length;setSelection(doc,normalizeSelection(ranges.concat([ourRange]),ourIndex),{scroll:false,origin:"*mouse"});}else if(ranges.length>1&&ranges[ourIndex].empty()&&type=="single"&&!e.shiftKey){setSelection(doc,normalizeSelection(ranges.slice(0,ourIndex).concat(ranges.slice(ourIndex+1)),0));startSel=doc.sel;}else{replaceOneSelection(doc,ourIndex,ourRange,sel_mouse);}
|
475 |
-
var lastPos=start;function extendTo(pos){if(cmp(lastPos,pos)==0)return;lastPos=pos;if(type=="rect"){var ranges=[],tabSize=cm.options.tabSize;var startCol=countColumn(getLine(doc,start.line).text,start.ch,tabSize);var posCol=countColumn(getLine(doc,pos.line).text,pos.ch,tabSize);var left=Math.min(startCol,posCol),right=Math.max(startCol,posCol);for(var line=Math.min(start.line,pos.line),end=Math.min(cm.lastLine(),Math.max(start.line,pos.line));line<=end;line++){var text=getLine(doc,line).text,leftPos=findColumn(text,left,tabSize);if(left==right)
|
476 |
-
ranges.push(new Range(Pos(line,leftPos),Pos(line,leftPos)));else if(text.length>leftPos)
|
477 |
-
ranges.push(new Range(Pos(line,leftPos),Pos(line,findColumn(text,right,tabSize))));}
|
478 |
-
if(!ranges.length)ranges.push(new Range(start,start));setSelection(doc,normalizeSelection(startSel.ranges.slice(0,ourIndex).concat(ranges),ourIndex),{origin:"*mouse",scroll:false});cm.scrollIntoView(pos);}else{var oldRange=ourRange;var anchor=oldRange.anchor,head=pos;if(type!="single"){if(type=="double")
|
479 |
-
var range=cm.findWordAt(pos);else
|
480 |
-
var range=new Range(Pos(pos.line,0),clipPos(doc,Pos(pos.line+1,0)));if(cmp(range.anchor,anchor)>0){head=range.head;anchor=minPos(oldRange.from(),range.anchor);}else{head=range.anchor;anchor=maxPos(oldRange.to(),range.head);}}
|
481 |
-
var ranges=startSel.ranges.slice(0);ranges[ourIndex]=new Range(clipPos(doc,anchor),head);setSelection(doc,normalizeSelection(ranges,ourIndex),sel_mouse);}}
|
482 |
-
var editorSize=display.wrapper.getBoundingClientRect();var counter=0;function extend(e){var curCount=++counter;var cur=posFromMouse(cm,e,true,type=="rect");if(!cur)return;if(cmp(cur,lastPos)!=0){cm.curOp.focus=activeElt();extendTo(cur);var visible=visibleLines(display,doc);if(cur.line>=visible.to||cur.line<visible.from)
|
483 |
-
setTimeout(operation(cm,function(){if(counter==curCount)extend(e);}),150);}else{var outside=e.clientY<editorSize.top?-20:e.clientY>editorSize.bottom?20:0;if(outside)setTimeout(operation(cm,function(){if(counter!=curCount)return;display.scroller.scrollTop+=outside;extend(e);}),50);}}
|
484 |
-
function done(e){counter=Infinity;e_preventDefault(e);display.input.focus();off(document,"mousemove",move);off(document,"mouseup",up);doc.history.lastSelOrigin=null;}
|
485 |
-
var move=operation(cm,function(e){if(!e_button(e))done(e);else extend(e);});var up=operation(cm,done);on(document,"mousemove",move);on(document,"mouseup",up);}
|
486 |
-
function gutterEvent(cm,e,type,prevent,signalfn){try{var mX=e.clientX,mY=e.clientY;}
|
487 |
-
catch(e){return false;}
|
488 |
-
if(mX>=Math.floor(cm.display.gutters.getBoundingClientRect().right))return false;if(prevent)e_preventDefault(e);var display=cm.display;var lineBox=display.lineDiv.getBoundingClientRect();if(mY>lineBox.bottom||!hasHandler(cm,type))return e_defaultPrevented(e);mY-=lineBox.top-display.viewOffset;for(var i=0;i<cm.options.gutters.length;++i){var g=display.gutters.childNodes[i];if(g&&g.getBoundingClientRect().right>=mX){var line=lineAtHeight(cm.doc,mY);var gutter=cm.options.gutters[i];signalfn(cm,type,cm,line,gutter,e);return e_defaultPrevented(e);}}}
|
489 |
-
function clickInGutter(cm,e){return gutterEvent(cm,e,"gutterClick",true,signalLater);}
|
490 |
-
var lastDrop=0;function onDrop(e){var cm=this;if(signalDOMEvent(cm,e)||eventInWidget(cm.display,e))
|
491 |
-
return;e_preventDefault(e);if(ie)lastDrop=+new Date;var pos=posFromMouse(cm,e,true),files=e.dataTransfer.files;if(!pos||isReadOnly(cm))return;if(files&&files.length&&window.FileReader&&window.File){var n=files.length,text=Array(n),read=0;var loadFile=function(file,i){var reader=new FileReader;reader.onload=operation(cm,function(){text[i]=reader.result;if(++read==n){pos=clipPos(cm.doc,pos);var change={from:pos,to:pos,text:splitLines(text.join("\n")),origin:"paste"};makeChange(cm.doc,change);setSelectionReplaceHistory(cm.doc,simpleSelection(pos,changeEnd(change)));}});reader.readAsText(file);};for(var i=0;i<n;++i)loadFile(files[i],i);}else{if(cm.state.draggingText&&cm.doc.sel.contains(pos)>-1){cm.state.draggingText(e);setTimeout(function(){cm.display.input.focus();},20);return;}
|
492 |
-
try{var text=e.dataTransfer.getData("Text");if(text){if(cm.state.draggingText&&!(mac?e.altKey:e.ctrlKey))
|
493 |
-
var selected=cm.listSelections();setSelectionNoUndo(cm.doc,simpleSelection(pos,pos));if(selected)for(var i=0;i<selected.length;++i)
|
494 |
-
replaceRange(cm.doc,"",selected[i].anchor,selected[i].head,"drag");cm.replaceSelection(text,"around","paste");cm.display.input.focus();}}
|
495 |
-
catch(e){}}}
|
496 |
-
function onDragStart(cm,e){if(ie&&(!cm.state.draggingText||+new Date-lastDrop<100)){e_stop(e);return;}
|
497 |
-
if(signalDOMEvent(cm,e)||eventInWidget(cm.display,e))return;e.dataTransfer.setData("Text",cm.getSelection());if(e.dataTransfer.setDragImage&&!safari){var img=elt("img",null,null,"position: fixed; left: 0; top: 0;");img.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";if(presto){img.width=img.height=1;cm.display.wrapper.appendChild(img);img._top=img.offsetTop;}
|
498 |
-
e.dataTransfer.setDragImage(img,0,0);if(presto)img.parentNode.removeChild(img);}}
|
499 |
-
function setScrollTop(cm,val){if(Math.abs(cm.doc.scrollTop-val)<2)return;cm.doc.scrollTop=val;if(!gecko)updateDisplaySimple(cm,{top:val});if(cm.display.scroller.scrollTop!=val)cm.display.scroller.scrollTop=val;cm.display.scrollbars.setScrollTop(val);if(gecko)updateDisplaySimple(cm);startWorker(cm,100);}
|
500 |
-
function setScrollLeft(cm,val,isScroller){if(isScroller?val==cm.doc.scrollLeft:Math.abs(cm.doc.scrollLeft-val)<2)return;val=Math.min(val,cm.display.scroller.scrollWidth-cm.display.scroller.clientWidth);cm.doc.scrollLeft=val;alignHorizontally(cm);if(cm.display.scroller.scrollLeft!=val)cm.display.scroller.scrollLeft=val;cm.display.scrollbars.setScrollLeft(val);}
|
501 |
-
var wheelSamples=0,wheelPixelsPerUnit=null;if(ie)wheelPixelsPerUnit=-.53;else if(gecko)wheelPixelsPerUnit=15;else if(chrome)wheelPixelsPerUnit=-.7;else if(safari)wheelPixelsPerUnit=-1/3;var wheelEventDelta=function(e){var dx=e.wheelDeltaX,dy=e.wheelDeltaY;if(dx==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS)dx=e.detail;if(dy==null&&e.detail&&e.axis==e.VERTICAL_AXIS)dy=e.detail;else if(dy==null)dy=e.wheelDelta;return{x:dx,y:dy};};CodeMirror.wheelEventPixels=function(e){var delta=wheelEventDelta(e);delta.x*=wheelPixelsPerUnit;delta.y*=wheelPixelsPerUnit;return delta;};function onScrollWheel(cm,e){var delta=wheelEventDelta(e),dx=delta.x,dy=delta.y;var display=cm.display,scroll=display.scroller;if(!(dx&&scroll.scrollWidth>scroll.clientWidth||dy&&scroll.scrollHeight>scroll.clientHeight))return;if(dy&&mac&&webkit){outer:for(var cur=e.target,view=display.view;cur!=scroll;cur=cur.parentNode){for(var i=0;i<view.length;i++){if(view[i].node==cur){cm.display.currentWheelTarget=cur;break outer;}}}}
|
502 |
-
if(dx&&!gecko&&!presto&&wheelPixelsPerUnit!=null){if(dy)
|
503 |
-
setScrollTop(cm,Math.max(0,Math.min(scroll.scrollTop+dy*wheelPixelsPerUnit,scroll.scrollHeight-scroll.clientHeight)));setScrollLeft(cm,Math.max(0,Math.min(scroll.scrollLeft+dx*wheelPixelsPerUnit,scroll.scrollWidth-scroll.clientWidth)));e_preventDefault(e);display.wheelStartX=null;return;}
|
504 |
-
if(dy&&wheelPixelsPerUnit!=null){var pixels=dy*wheelPixelsPerUnit;var top=cm.doc.scrollTop,bot=top+display.wrapper.clientHeight;if(pixels<0)top=Math.max(0,top+pixels-50);else bot=Math.min(cm.doc.height,bot+pixels+50);updateDisplaySimple(cm,{top:top,bottom:bot});}
|
505 |
-
if(wheelSamples<20){if(display.wheelStartX==null){display.wheelStartX=scroll.scrollLeft;display.wheelStartY=scroll.scrollTop;display.wheelDX=dx;display.wheelDY=dy;setTimeout(function(){if(display.wheelStartX==null)return;var movedX=scroll.scrollLeft-display.wheelStartX;var movedY=scroll.scrollTop-display.wheelStartY;var sample=(movedY&&display.wheelDY&&movedY/display.wheelDY)||(movedX&&display.wheelDX&&movedX/display.wheelDX);display.wheelStartX=display.wheelStartY=null;if(!sample)return;wheelPixelsPerUnit=(wheelPixelsPerUnit*wheelSamples+sample)/(wheelSamples+1);++wheelSamples;},200);}else{display.wheelDX+=dx;display.wheelDY+=dy;}}}
|
506 |
-
function doHandleBinding(cm,bound,dropShift){if(typeof bound=="string"){bound=commands[bound];if(!bound)return false;}
|
507 |
-
cm.display.input.ensurePolled();var prevShift=cm.display.shift,done=false;try{if(isReadOnly(cm))cm.state.suppressEdits=true;if(dropShift)cm.display.shift=false;done=bound(cm)!=Pass;}finally{cm.display.shift=prevShift;cm.state.suppressEdits=false;}
|
508 |
-
return done;}
|
509 |
-
function lookupKeyForEditor(cm,name,handle){for(var i=0;i<cm.state.keyMaps.length;i++){var result=lookupKey(name,cm.state.keyMaps[i],handle,cm);if(result)return result;}
|
510 |
-
return(cm.options.extraKeys&&lookupKey(name,cm.options.extraKeys,handle,cm))||lookupKey(name,cm.options.keyMap,handle,cm);}
|
511 |
-
var stopSeq=new Delayed;function dispatchKey(cm,name,e,handle){var seq=cm.state.keySeq;if(seq){if(isModifierKey(name))return"handled";stopSeq.set(50,function(){if(cm.state.keySeq==seq){cm.state.keySeq=null;cm.display.input.reset();}});name=seq+" "+name;}
|
512 |
-
var result=lookupKeyForEditor(cm,name,handle);if(result=="multi")
|
513 |
-
cm.state.keySeq=name;if(result=="handled")
|
514 |
-
signalLater(cm,"keyHandled",cm,name,e);if(result=="handled"||result=="multi"){e_preventDefault(e);restartBlink(cm);}
|
515 |
-
if(seq&&!result&&/\'$/.test(name)){e_preventDefault(e);return true;}
|
516 |
-
return!!result;}
|
517 |
-
function handleKeyBinding(cm,e){var name=keyName(e,true);if(!name)return false;if(e.shiftKey&&!cm.state.keySeq){return dispatchKey(cm,"Shift-"+name,e,function(b){return doHandleBinding(cm,b,true);})||dispatchKey(cm,name,e,function(b){if(typeof b=="string"?/^go[A-Z]/.test(b):b.motion)
|
518 |
-
return doHandleBinding(cm,b);});}else{return dispatchKey(cm,name,e,function(b){return doHandleBinding(cm,b);});}}
|
519 |
-
function handleCharBinding(cm,e,ch){return dispatchKey(cm,"'"+ch+"'",e,function(b){return doHandleBinding(cm,b,true);});}
|
520 |
-
var lastStoppedKey=null;function onKeyDown(e){var cm=this;cm.curOp.focus=activeElt();if(signalDOMEvent(cm,e))return;if(ie&&ie_version<11&&e.keyCode==27)e.returnValue=false;var code=e.keyCode;cm.display.shift=code==16||e.shiftKey;var handled=handleKeyBinding(cm,e);if(presto){lastStoppedKey=handled?code:null;if(!handled&&code==88&&!hasCopyEvent&&(mac?e.metaKey:e.ctrlKey))
|
521 |
-
cm.replaceSelection("",null,"cut");}
|
522 |
-
if(code==18&&!/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
|
523 |
-
showCrossHair(cm);}
|
524 |
-
function showCrossHair(cm){var lineDiv=cm.display.lineDiv;addClass(lineDiv,"CodeMirror-crosshair");function up(e){if(e.keyCode==18||!e.altKey){rmClass(lineDiv,"CodeMirror-crosshair");off(document,"keyup",up);off(document,"mouseover",up);}}
|
525 |
-
on(document,"keyup",up);on(document,"mouseover",up);}
|
526 |
-
function onKeyUp(e){if(e.keyCode==16)this.doc.sel.shift=false;signalDOMEvent(this,e);}
|
527 |
-
function onKeyPress(e){var cm=this;if(eventInWidget(cm.display,e)||signalDOMEvent(cm,e)||e.ctrlKey&&!e.altKey||mac&&e.metaKey)return;var keyCode=e.keyCode,charCode=e.charCode;if(presto&&keyCode==lastStoppedKey){lastStoppedKey=null;e_preventDefault(e);return;}
|
528 |
-
if((presto&&(!e.which||e.which<10))&&handleKeyBinding(cm,e))return;var ch=String.fromCharCode(charCode==null?keyCode:charCode);if(handleCharBinding(cm,e,ch))return;cm.display.input.onKeyPress(e);}
|
529 |
-
function delayBlurEvent(cm){cm.state.delayingBlurEvent=true;setTimeout(function(){if(cm.state.delayingBlurEvent){cm.state.delayingBlurEvent=false;onBlur(cm);}},100);}
|
530 |
-
function onFocus(cm){if(cm.state.delayingBlurEvent)cm.state.delayingBlurEvent=false;if(cm.options.readOnly=="nocursor")return;if(!cm.state.focused){signal(cm,"focus",cm);cm.state.focused=true;addClass(cm.display.wrapper,"CodeMirror-focused");if(!cm.curOp&&cm.display.selForContextMenu!=cm.doc.sel){cm.display.input.reset();if(webkit)setTimeout(function(){cm.display.input.reset(true);},20);}
|
531 |
-
cm.display.input.receivedFocus();}
|
532 |
-
restartBlink(cm);}
|
533 |
-
function onBlur(cm){if(cm.state.delayingBlurEvent)return;if(cm.state.focused){signal(cm,"blur",cm);cm.state.focused=false;rmClass(cm.display.wrapper,"CodeMirror-focused");}
|
534 |
-
clearInterval(cm.display.blinker);setTimeout(function(){if(!cm.state.focused)cm.display.shift=false;},150);}
|
535 |
-
function onContextMenu(cm,e){if(eventInWidget(cm.display,e)||contextMenuInGutter(cm,e))return;cm.display.input.onContextMenu(e);}
|
536 |
-
function contextMenuInGutter(cm,e){if(!hasHandler(cm,"gutterContextMenu"))return false;return gutterEvent(cm,e,"gutterContextMenu",false,signal);}
|
537 |
-
var changeEnd=CodeMirror.changeEnd=function(change){if(!change.text)return change.to;return Pos(change.from.line+change.text.length-1,lst(change.text).length+(change.text.length==1?change.from.ch:0));};function adjustForChange(pos,change){if(cmp(pos,change.from)<0)return pos;if(cmp(pos,change.to)<=0)return changeEnd(change);var line=pos.line+change.text.length-(change.to.line-change.from.line)-1,ch=pos.ch;if(pos.line==change.to.line)ch+=changeEnd(change).ch-change.to.ch;return Pos(line,ch);}
|
538 |
-
function computeSelAfterChange(doc,change){var out=[];for(var i=0;i<doc.sel.ranges.length;i++){var range=doc.sel.ranges[i];out.push(new Range(adjustForChange(range.anchor,change),adjustForChange(range.head,change)));}
|
539 |
-
return normalizeSelection(out,doc.sel.primIndex);}
|
540 |
-
function offsetPos(pos,old,nw){if(pos.line==old.line)
|
541 |
-
return Pos(nw.line,pos.ch-old.ch+nw.ch);else
|
542 |
-
return Pos(nw.line+(pos.line-old.line),pos.ch);}
|
543 |
-
function computeReplacedSel(doc,changes,hint){var out=[];var oldPrev=Pos(doc.first,0),newPrev=oldPrev;for(var i=0;i<changes.length;i++){var change=changes[i];var from=offsetPos(change.from,oldPrev,newPrev);var to=offsetPos(changeEnd(change),oldPrev,newPrev);oldPrev=change.to;newPrev=to;if(hint=="around"){var range=doc.sel.ranges[i],inv=cmp(range.head,range.anchor)<0;out[i]=new Range(inv?to:from,inv?from:to);}else{out[i]=new Range(from,from);}}
|
544 |
-
return new Selection(out,doc.sel.primIndex);}
|
545 |
-
function filterChange(doc,change,update){var obj={canceled:false,from:change.from,to:change.to,text:change.text,origin:change.origin,cancel:function(){this.canceled=true;}};if(update)obj.update=function(from,to,text,origin){if(from)this.from=clipPos(doc,from);if(to)this.to=clipPos(doc,to);if(text)this.text=text;if(origin!==undefined)this.origin=origin;};signal(doc,"beforeChange",doc,obj);if(doc.cm)signal(doc.cm,"beforeChange",doc.cm,obj);if(obj.canceled)return null;return{from:obj.from,to:obj.to,text:obj.text,origin:obj.origin};}
|
546 |
-
function makeChange(doc,change,ignoreReadOnly){if(doc.cm){if(!doc.cm.curOp)return operation(doc.cm,makeChange)(doc,change,ignoreReadOnly);if(doc.cm.state.suppressEdits)return;}
|
547 |
-
if(hasHandler(doc,"beforeChange")||doc.cm&&hasHandler(doc.cm,"beforeChange")){change=filterChange(doc,change,true);if(!change)return;}
|
548 |
-
var split=sawReadOnlySpans&&!ignoreReadOnly&&removeReadOnlyRanges(doc,change.from,change.to);if(split){for(var i=split.length-1;i>=0;--i)
|
549 |
-
makeChangeInner(doc,{from:split[i].from,to:split[i].to,text:i?[""]:change.text});}else{makeChangeInner(doc,change);}}
|
550 |
-
function makeChangeInner(doc,change){if(change.text.length==1&&change.text[0]==""&&cmp(change.from,change.to)==0)return;var selAfter=computeSelAfterChange(doc,change);addChangeToHistory(doc,change,selAfter,doc.cm?doc.cm.curOp.id:NaN);makeChangeSingleDoc(doc,change,selAfter,stretchSpansOverChange(doc,change));var rebased=[];linkedDocs(doc,function(doc,sharedHist){if(!sharedHist&&indexOf(rebased,doc.history)==-1){rebaseHist(doc.history,change);rebased.push(doc.history);}
|
551 |
-
makeChangeSingleDoc(doc,change,null,stretchSpansOverChange(doc,change));});}
|
552 |
-
function makeChangeFromHistory(doc,type,allowSelectionOnly){if(doc.cm&&doc.cm.state.suppressEdits)return;var hist=doc.history,event,selAfter=doc.sel;var source=type=="undo"?hist.done:hist.undone,dest=type=="undo"?hist.undone:hist.done;for(var i=0;i<source.length;i++){event=source[i];if(allowSelectionOnly?event.ranges&&!event.equals(doc.sel):!event.ranges)
|
553 |
-
break;}
|
554 |
-
if(i==source.length)return;hist.lastOrigin=hist.lastSelOrigin=null;for(;;){event=source.pop();if(event.ranges){pushSelectionToHistory(event,dest);if(allowSelectionOnly&&!event.equals(doc.sel)){setSelection(doc,event,{clearRedo:false});return;}
|
555 |
-
selAfter=event;}
|
556 |
-
else break;}
|
557 |
-
var antiChanges=[];pushSelectionToHistory(selAfter,dest);dest.push({changes:antiChanges,generation:hist.generation});hist.generation=event.generation||++hist.maxGeneration;var filter=hasHandler(doc,"beforeChange")||doc.cm&&hasHandler(doc.cm,"beforeChange");for(var i=event.changes.length-1;i>=0;--i){var change=event.changes[i];change.origin=type;if(filter&&!filterChange(doc,change,false)){source.length=0;return;}
|
558 |
-
antiChanges.push(historyChangeFromChange(doc,change));var after=i?computeSelAfterChange(doc,change):lst(source);makeChangeSingleDoc(doc,change,after,mergeOldSpans(doc,change));if(!i&&doc.cm)doc.cm.scrollIntoView({from:change.from,to:changeEnd(change)});var rebased=[];linkedDocs(doc,function(doc,sharedHist){if(!sharedHist&&indexOf(rebased,doc.history)==-1){rebaseHist(doc.history,change);rebased.push(doc.history);}
|
559 |
-
makeChangeSingleDoc(doc,change,null,mergeOldSpans(doc,change));});}}
|
560 |
-
function shiftDoc(doc,distance){if(distance==0)return;doc.first+=distance;doc.sel=new Selection(map(doc.sel.ranges,function(range){return new Range(Pos(range.anchor.line+distance,range.anchor.ch),Pos(range.head.line+distance,range.head.ch));}),doc.sel.primIndex);if(doc.cm){regChange(doc.cm,doc.first,doc.first-distance,distance);for(var d=doc.cm.display,l=d.viewFrom;l<d.viewTo;l++)
|
561 |
-
regLineChange(doc.cm,l,"gutter");}}
|
562 |
-
function makeChangeSingleDoc(doc,change,selAfter,spans){if(doc.cm&&!doc.cm.curOp)
|
563 |
-
return operation(doc.cm,makeChangeSingleDoc)(doc,change,selAfter,spans);if(change.to.line<doc.first){shiftDoc(doc,change.text.length-1-(change.to.line-change.from.line));return;}
|
564 |
-
if(change.from.line>doc.lastLine())return;if(change.from.line<doc.first){var shift=change.text.length-1-(doc.first-change.from.line);shiftDoc(doc,shift);change={from:Pos(doc.first,0),to:Pos(change.to.line+shift,change.to.ch),text:[lst(change.text)],origin:change.origin};}
|
565 |
-
var last=doc.lastLine();if(change.to.line>last){change={from:change.from,to:Pos(last,getLine(doc,last).text.length),text:[change.text[0]],origin:change.origin};}
|
566 |
-
change.removed=getBetween(doc,change.from,change.to);if(!selAfter)selAfter=computeSelAfterChange(doc,change);if(doc.cm)makeChangeSingleDocInEditor(doc.cm,change,spans);else updateDoc(doc,change,spans);setSelectionNoUndo(doc,selAfter,sel_dontScroll);}
|
567 |
-
function makeChangeSingleDocInEditor(cm,change,spans){var doc=cm.doc,display=cm.display,from=change.from,to=change.to;var recomputeMaxLength=false,checkWidthStart=from.line;if(!cm.options.lineWrapping){checkWidthStart=lineNo(visualLine(getLine(doc,from.line)));doc.iter(checkWidthStart,to.line+1,function(line){if(line==display.maxLine){recomputeMaxLength=true;return true;}});}
|
568 |
-
if(doc.sel.contains(change.from,change.to)>-1)
|
569 |
-
signalCursorActivity(cm);updateDoc(doc,change,spans,estimateHeight(cm));if(!cm.options.lineWrapping){doc.iter(checkWidthStart,from.line+change.text.length,function(line){var len=lineLength(line);if(len>display.maxLineLength){display.maxLine=line;display.maxLineLength=len;display.maxLineChanged=true;recomputeMaxLength=false;}});if(recomputeMaxLength)cm.curOp.updateMaxLine=true;}
|
570 |
-
doc.frontier=Math.min(doc.frontier,from.line);startWorker(cm,400);var lendiff=change.text.length-(to.line-from.line)-1;if(change.full)
|
571 |
-
regChange(cm);else if(from.line==to.line&&change.text.length==1&&!isWholeLineUpdate(cm.doc,change))
|
572 |
-
regLineChange(cm,from.line,"text");else
|
573 |
-
regChange(cm,from.line,to.line+1,lendiff);var changesHandler=hasHandler(cm,"changes"),changeHandler=hasHandler(cm,"change");if(changeHandler||changesHandler){var obj={from:from,to:to,text:change.text,removed:change.removed,origin:change.origin};if(changeHandler)signalLater(cm,"change",cm,obj);if(changesHandler)(cm.curOp.changeObjs||(cm.curOp.changeObjs=[])).push(obj);}
|
574 |
-
cm.display.selForContextMenu=null;}
|
575 |
-
function replaceRange(doc,code,from,to,origin){if(!to)to=from;if(cmp(to,from)<0){var tmp=to;to=from;from=tmp;}
|
576 |
-
if(typeof code=="string")code=splitLines(code);makeChange(doc,{from:from,to:to,text:code,origin:origin});}
|
577 |
-
function maybeScrollWindow(cm,coords){if(signalDOMEvent(cm,"scrollCursorIntoView"))return;var display=cm.display,box=display.sizer.getBoundingClientRect(),doScroll=null;if(coords.top+box.top<0)doScroll=true;else if(coords.bottom+box.top>(window.innerHeight||document.documentElement.clientHeight))doScroll=false;if(doScroll!=null&&!phantom){var scrollNode=elt("div","\u200b",null,"position: absolute; top: "+
|
578 |
-
(coords.top-display.viewOffset-paddingTop(cm.display))+"px; height: "+
|
579 |
-
(coords.bottom-coords.top+scrollGap(cm)+display.barHeight)+"px; left: "+
|
580 |
-
coords.left+"px; width: 2px;");cm.display.lineSpace.appendChild(scrollNode);scrollNode.scrollIntoView(doScroll);cm.display.lineSpace.removeChild(scrollNode);}}
|
581 |
-
function scrollPosIntoView(cm,pos,end,margin){if(margin==null)margin=0;for(var limit=0;limit<5;limit++){var changed=false,coords=cursorCoords(cm,pos);var endCoords=!end||end==pos?coords:cursorCoords(cm,end);var scrollPos=calculateScrollPos(cm,Math.min(coords.left,endCoords.left),Math.min(coords.top,endCoords.top)-margin,Math.max(coords.left,endCoords.left),Math.max(coords.bottom,endCoords.bottom)+margin);var startTop=cm.doc.scrollTop,startLeft=cm.doc.scrollLeft;if(scrollPos.scrollTop!=null){setScrollTop(cm,scrollPos.scrollTop);if(Math.abs(cm.doc.scrollTop-startTop)>1)changed=true;}
|
582 |
-
if(scrollPos.scrollLeft!=null){setScrollLeft(cm,scrollPos.scrollLeft);if(Math.abs(cm.doc.scrollLeft-startLeft)>1)changed=true;}
|
583 |
-
if(!changed)break;}
|
584 |
-
return coords;}
|
585 |
-
function scrollIntoView(cm,x1,y1,x2,y2){var scrollPos=calculateScrollPos(cm,x1,y1,x2,y2);if(scrollPos.scrollTop!=null)setScrollTop(cm,scrollPos.scrollTop);if(scrollPos.scrollLeft!=null)setScrollLeft(cm,scrollPos.scrollLeft);}
|
586 |
-
function calculateScrollPos(cm,x1,y1,x2,y2){var display=cm.display,snapMargin=textHeight(cm.display);if(y1<0)y1=0;var screentop=cm.curOp&&cm.curOp.scrollTop!=null?cm.curOp.scrollTop:display.scroller.scrollTop;var screen=displayHeight(cm),result={};if(y2-y1>screen)y2=y1+screen;var docBottom=cm.doc.height+paddingVert(display);var atTop=y1<snapMargin,atBottom=y2>docBottom-snapMargin;if(y1<screentop){result.scrollTop=atTop?0:y1;}else if(y2>screentop+screen){var newTop=Math.min(y1,(atBottom?docBottom:y2)-screen);if(newTop!=screentop)result.scrollTop=newTop;}
|
587 |
-
var screenleft=cm.curOp&&cm.curOp.scrollLeft!=null?cm.curOp.scrollLeft:display.scroller.scrollLeft;var screenw=displayWidth(cm)-(cm.options.fixedGutter?display.gutters.offsetWidth:0);var tooWide=x2-x1>screenw;if(tooWide)x2=x1+screenw;if(x1<10)
|
588 |
-
result.scrollLeft=0;else if(x1<screenleft)
|
589 |
-
result.scrollLeft=Math.max(0,x1-(tooWide?0:10));else if(x2>screenw+screenleft-3)
|
590 |
-
result.scrollLeft=x2+(tooWide?0:10)-screenw;return result;}
|
591 |
-
function addToScrollPos(cm,left,top){if(left!=null||top!=null)resolveScrollToPos(cm);if(left!=null)
|
592 |
-
cm.curOp.scrollLeft=(cm.curOp.scrollLeft==null?cm.doc.scrollLeft:cm.curOp.scrollLeft)+left;if(top!=null)
|
593 |
-
cm.curOp.scrollTop=(cm.curOp.scrollTop==null?cm.doc.scrollTop:cm.curOp.scrollTop)+top;}
|
594 |
-
function ensureCursorVisible(cm){resolveScrollToPos(cm);var cur=cm.getCursor(),from=cur,to=cur;if(!cm.options.lineWrapping){from=cur.ch?Pos(cur.line,cur.ch-1):cur;to=Pos(cur.line,cur.ch+1);}
|
595 |
-
cm.curOp.scrollToPos={from:from,to:to,margin:cm.options.cursorScrollMargin,isCursor:true};}
|
596 |
-
function resolveScrollToPos(cm){var range=cm.curOp.scrollToPos;if(range){cm.curOp.scrollToPos=null;var from=estimateCoords(cm,range.from),to=estimateCoords(cm,range.to);var sPos=calculateScrollPos(cm,Math.min(from.left,to.left),Math.min(from.top,to.top)-range.margin,Math.max(from.right,to.right),Math.max(from.bottom,to.bottom)+range.margin);cm.scrollTo(sPos.scrollLeft,sPos.scrollTop);}}
|
597 |
-
function indentLine(cm,n,how,aggressive){var doc=cm.doc,state;if(how==null)how="add";if(how=="smart"){if(!doc.mode.indent)how="prev";else state=getStateBefore(cm,n);}
|
598 |
-
var tabSize=cm.options.tabSize;var line=getLine(doc,n),curSpace=countColumn(line.text,null,tabSize);if(line.stateAfter)line.stateAfter=null;var curSpaceString=line.text.match(/^\s*/)[0],indentation;if(!aggressive&&!/\S/.test(line.text)){indentation=0;how="not";}else if(how=="smart"){indentation=doc.mode.indent(state,line.text.slice(curSpaceString.length),line.text);if(indentation==Pass||indentation>150){if(!aggressive)return;how="prev";}}
|
599 |
-
if(how=="prev"){if(n>doc.first)indentation=countColumn(getLine(doc,n-1).text,null,tabSize);else indentation=0;}else if(how=="add"){indentation=curSpace+cm.options.indentUnit;}else if(how=="subtract"){indentation=curSpace-cm.options.indentUnit;}else if(typeof how=="number"){indentation=curSpace+how;}
|
600 |
-
indentation=Math.max(0,indentation);var indentString="",pos=0;if(cm.options.indentWithTabs)
|
601 |
-
for(var i=Math.floor(indentation/tabSize);i;--i){pos+=tabSize;indentString+="\t";}
|
602 |
-
if(pos<indentation)indentString+=spaceStr(indentation-pos);if(indentString!=curSpaceString){replaceRange(doc,indentString,Pos(n,0),Pos(n,curSpaceString.length),"+input");line.stateAfter=null;return true;}else{for(var i=0;i<doc.sel.ranges.length;i++){var range=doc.sel.ranges[i];if(range.head.line==n&&range.head.ch<curSpaceString.length){var pos=Pos(n,curSpaceString.length);replaceOneSelection(doc,i,new Range(pos,pos));break;}}}}
|
603 |
-
function changeLine(doc,handle,changeType,op){var no=handle,line=handle;if(typeof handle=="number")line=getLine(doc,clipLine(doc,handle));else no=lineNo(handle);if(no==null)return null;if(op(line,no)&&doc.cm)regLineChange(doc.cm,no,changeType);return line;}
|
604 |
-
function deleteNearSelection(cm,compute){var ranges=cm.doc.sel.ranges,kill=[];for(var i=0;i<ranges.length;i++){var toKill=compute(ranges[i]);while(kill.length&&cmp(toKill.from,lst(kill).to)<=0){var replaced=kill.pop();if(cmp(replaced.from,toKill.from)<0){toKill.from=replaced.from;break;}}
|
605 |
-
kill.push(toKill);}
|
606 |
-
runInOp(cm,function(){for(var i=kill.length-1;i>=0;i--)
|
607 |
-
replaceRange(cm.doc,"",kill[i].from,kill[i].to,"+delete");ensureCursorVisible(cm);});}
|
608 |
-
function findPosH(doc,pos,dir,unit,visually){var line=pos.line,ch=pos.ch,origDir=dir;var lineObj=getLine(doc,line);var possible=true;function findNextLine(){var l=line+dir;if(l<doc.first||l>=doc.first+doc.size)return(possible=false);line=l;return lineObj=getLine(doc,l);}
|
609 |
-
function moveOnce(boundToLine){var next=(visually?moveVisually:moveLogically)(lineObj,ch,dir,true);if(next==null){if(!boundToLine&&findNextLine()){if(visually)ch=(dir<0?lineRight:lineLeft)(lineObj);else ch=dir<0?lineObj.text.length:0;}else return(possible=false);}else ch=next;return true;}
|
610 |
-
if(unit=="char")moveOnce();else if(unit=="column")moveOnce(true);else if(unit=="word"||unit=="group"){var sawType=null,group=unit=="group";var helper=doc.cm&&doc.cm.getHelper(pos,"wordChars");for(var first=true;;first=false){if(dir<0&&!moveOnce(!first))break;var cur=lineObj.text.charAt(ch)||"\n";var type=isWordChar(cur,helper)?"w":group&&cur=="\n"?"n":!group||/\s/.test(cur)?null:"p";if(group&&!first&&!type)type="s";if(sawType&&sawType!=type){if(dir<0){dir=1;moveOnce();}
|
611 |
-
break;}
|
612 |
-
if(type)sawType=type;if(dir>0&&!moveOnce(!first))break;}}
|
613 |
-
var result=skipAtomic(doc,Pos(line,ch),origDir,true);if(!possible)result.hitSide=true;return result;}
|
614 |
-
function findPosV(cm,pos,dir,unit){var doc=cm.doc,x=pos.left,y;if(unit=="page"){var pageSize=Math.min(cm.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);y=pos.top+dir*(pageSize-(dir<0?1.5:.5)*textHeight(cm.display));}else if(unit=="line"){y=dir>0?pos.bottom+3:pos.top-3;}
|
615 |
-
for(;;){var target=coordsChar(cm,x,y);if(!target.outside)break;if(dir<0?y<=0:y>=doc.height){target.hitSide=true;break;}
|
616 |
-
y+=dir*5;}
|
617 |
-
return target;}
|
618 |
-
CodeMirror.prototype={constructor:CodeMirror,focus:function(){window.focus();this.display.input.focus();},setOption:function(option,value){var options=this.options,old=options[option];if(options[option]==value&&option!="mode")return;options[option]=value;if(optionHandlers.hasOwnProperty(option))
|
619 |
-
operation(this,optionHandlers[option])(this,value,old);},getOption:function(option){return this.options[option];},getDoc:function(){return this.doc;},addKeyMap:function(map,bottom){this.state.keyMaps[bottom?"push":"unshift"](getKeyMap(map));},removeKeyMap:function(map){var maps=this.state.keyMaps;for(var i=0;i<maps.length;++i)
|
620 |
-
if(maps[i]==map||maps[i].name==map){maps.splice(i,1);return true;}},addOverlay:methodOp(function(spec,options){var mode=spec.token?spec:CodeMirror.getMode(this.options,spec);if(mode.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:mode,modeSpec:spec,opaque:options&&options.opaque});this.state.modeGen++;regChange(this);}),removeOverlay:methodOp(function(spec){var overlays=this.state.overlays;for(var i=0;i<overlays.length;++i){var cur=overlays[i].modeSpec;if(cur==spec||typeof spec=="string"&&cur.name==spec){overlays.splice(i,1);this.state.modeGen++;regChange(this);return;}}}),indentLine:methodOp(function(n,dir,aggressive){if(typeof dir!="string"&&typeof dir!="number"){if(dir==null)dir=this.options.smartIndent?"smart":"prev";else dir=dir?"add":"subtract";}
|
621 |
-
if(isLine(this.doc,n))indentLine(this,n,dir,aggressive);}),indentSelection:methodOp(function(how){var ranges=this.doc.sel.ranges,end=-1;for(var i=0;i<ranges.length;i++){var range=ranges[i];if(!range.empty()){var from=range.from(),to=range.to();var start=Math.max(end,from.line);end=Math.min(this.lastLine(),to.line-(to.ch?0:1))+1;for(var j=start;j<end;++j)
|
622 |
-
indentLine(this,j,how);var newRanges=this.doc.sel.ranges;if(from.ch==0&&ranges.length==newRanges.length&&newRanges[i].from().ch>0)
|
623 |
-
replaceOneSelection(this.doc,i,new Range(from,newRanges[i].to()),sel_dontScroll);}else if(range.head.line>end){indentLine(this,range.head.line,how,true);end=range.head.line;if(i==this.doc.sel.primIndex)ensureCursorVisible(this);}}}),getTokenAt:function(pos,precise){return takeToken(this,pos,precise);},getLineTokens:function(line,precise){return takeToken(this,Pos(line),precise,true);},getTokenTypeAt:function(pos){pos=clipPos(this.doc,pos);var styles=getLineStyles(this,getLine(this.doc,pos.line));var before=0,after=(styles.length-1)/2,ch=pos.ch;var type;if(ch==0)type=styles[2];else for(;;){var mid=(before+after)>>1;if((mid?styles[mid*2-1]:0)>=ch)after=mid;else if(styles[mid*2+1]<ch)before=mid+1;else{type=styles[mid*2+2];break;}}
|
624 |
-
var cut=type?type.indexOf("cm-overlay "):-1;return cut<0?type:cut==0?null:type.slice(0,cut-1);},getModeAt:function(pos){var mode=this.doc.mode;if(!mode.innerMode)return mode;return CodeMirror.innerMode(mode,this.getTokenAt(pos).state).mode;},getHelper:function(pos,type){return this.getHelpers(pos,type)[0];},getHelpers:function(pos,type){var found=[];if(!helpers.hasOwnProperty(type))return found;var help=helpers[type],mode=this.getModeAt(pos);if(typeof mode[type]=="string"){if(help[mode[type]])found.push(help[mode[type]]);}else if(mode[type]){for(var i=0;i<mode[type].length;i++){var val=help[mode[type][i]];if(val)found.push(val);}}else if(mode.helperType&&help[mode.helperType]){found.push(help[mode.helperType]);}else if(help[mode.name]){found.push(help[mode.name]);}
|
625 |
-
for(var i=0;i<help._global.length;i++){var cur=help._global[i];if(cur.pred(mode,this)&&indexOf(found,cur.val)==-1)
|
626 |
-
found.push(cur.val);}
|
627 |
-
return found;},getStateAfter:function(line,precise){var doc=this.doc;line=clipLine(doc,line==null?doc.first+doc.size-1:line);return getStateBefore(this,line+1,precise);},cursorCoords:function(start,mode){var pos,range=this.doc.sel.primary();if(start==null)pos=range.head;else if(typeof start=="object")pos=clipPos(this.doc,start);else pos=start?range.from():range.to();return cursorCoords(this,pos,mode||"page");},charCoords:function(pos,mode){return charCoords(this,clipPos(this.doc,pos),mode||"page");},coordsChar:function(coords,mode){coords=fromCoordSystem(this,coords,mode||"page");return coordsChar(this,coords.left,coords.top);},lineAtHeight:function(height,mode){height=fromCoordSystem(this,{top:height,left:0},mode||"page").top;return lineAtHeight(this.doc,height+this.display.viewOffset);},heightAtLine:function(line,mode){var end=false,lineObj;if(typeof line=="number"){var last=this.doc.first+this.doc.size-1;if(line<this.doc.first)line=this.doc.first;else if(line>last){line=last;end=true;}
|
628 |
-
lineObj=getLine(this.doc,line);}else{lineObj=line;}
|
629 |
-
return intoCoordSystem(this,lineObj,{top:0,left:0},mode||"page").top+
|
630 |
-
(end?this.doc.height-heightAtLine(lineObj):0);},defaultTextHeight:function(){return textHeight(this.display);},defaultCharWidth:function(){return charWidth(this.display);},setGutterMarker:methodOp(function(line,gutterID,value){return changeLine(this.doc,line,"gutter",function(line){var markers=line.gutterMarkers||(line.gutterMarkers={});markers[gutterID]=value;if(!value&&isEmpty(markers))line.gutterMarkers=null;return true;});}),clearGutter:methodOp(function(gutterID){var cm=this,doc=cm.doc,i=doc.first;doc.iter(function(line){if(line.gutterMarkers&&line.gutterMarkers[gutterID]){line.gutterMarkers[gutterID]=null;regLineChange(cm,i,"gutter");if(isEmpty(line.gutterMarkers))line.gutterMarkers=null;}
|
631 |
-
++i;});}),lineInfo:function(line){if(typeof line=="number"){if(!isLine(this.doc,line))return null;var n=line;line=getLine(this.doc,line);if(!line)return null;}else{var n=lineNo(line);if(n==null)return null;}
|
632 |
-
return{line:n,handle:line,text:line.text,gutterMarkers:line.gutterMarkers,textClass:line.textClass,bgClass:line.bgClass,wrapClass:line.wrapClass,widgets:line.widgets};},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo};},addWidget:function(pos,node,scroll,vert,horiz){var display=this.display;pos=cursorCoords(this,clipPos(this.doc,pos));var top=pos.bottom,left=pos.left;node.style.position="absolute";node.setAttribute("cm-ignore-events","true");this.display.input.setUneditable(node);display.sizer.appendChild(node);if(vert=="over"){top=pos.top;}else if(vert=="above"||vert=="near"){var vspace=Math.max(display.wrapper.clientHeight,this.doc.height),hspace=Math.max(display.sizer.clientWidth,display.lineSpace.clientWidth);if((vert=='above'||pos.bottom+node.offsetHeight>vspace)&&pos.top>node.offsetHeight)
|
633 |
-
top=pos.top-node.offsetHeight;else if(pos.bottom+node.offsetHeight<=vspace)
|
634 |
-
top=pos.bottom;if(left+node.offsetWidth>hspace)
|
635 |
-
left=hspace-node.offsetWidth;}
|
636 |
-
node.style.top=top+"px";node.style.left=node.style.right="";if(horiz=="right"){left=display.sizer.clientWidth-node.offsetWidth;node.style.right="0px";}else{if(horiz=="left")left=0;else if(horiz=="middle")left=(display.sizer.clientWidth-node.offsetWidth)/2;node.style.left=left+"px";}
|
637 |
-
if(scroll)
|
638 |
-
scrollIntoView(this,left,top,left+node.offsetWidth,top+node.offsetHeight);},triggerOnKeyDown:methodOp(onKeyDown),triggerOnKeyPress:methodOp(onKeyPress),triggerOnKeyUp:onKeyUp,execCommand:function(cmd){if(commands.hasOwnProperty(cmd))
|
639 |
-
return commands[cmd](this);},findPosH:function(from,amount,unit,visually){var dir=1;if(amount<0){dir=-1;amount=-amount;}
|
640 |
-
for(var i=0,cur=clipPos(this.doc,from);i<amount;++i){cur=findPosH(this.doc,cur,dir,unit,visually);if(cur.hitSide)break;}
|
641 |
-
return cur;},moveH:methodOp(function(dir,unit){var cm=this;cm.extendSelectionsBy(function(range){if(cm.display.shift||cm.doc.extend||range.empty())
|
642 |
-
return findPosH(cm.doc,range.head,dir,unit,cm.options.rtlMoveVisually);else
|
643 |
-
return dir<0?range.from():range.to();},sel_move);}),deleteH:methodOp(function(dir,unit){var sel=this.doc.sel,doc=this.doc;if(sel.somethingSelected())
|
644 |
-
doc.replaceSelection("",null,"+delete");else
|
645 |
-
deleteNearSelection(this,function(range){var other=findPosH(doc,range.head,dir,unit,false);return dir<0?{from:other,to:range.head}:{from:range.head,to:other};});}),findPosV:function(from,amount,unit,goalColumn){var dir=1,x=goalColumn;if(amount<0){dir=-1;amount=-amount;}
|
646 |
-
for(var i=0,cur=clipPos(this.doc,from);i<amount;++i){var coords=cursorCoords(this,cur,"div");if(x==null)x=coords.left;else coords.left=x;cur=findPosV(this,coords,dir,unit);if(cur.hitSide)break;}
|
647 |
-
return cur;},moveV:methodOp(function(dir,unit){var cm=this,doc=this.doc,goals=[];var collapse=!cm.display.shift&&!doc.extend&&doc.sel.somethingSelected();doc.extendSelectionsBy(function(range){if(collapse)
|
648 |
-
return dir<0?range.from():range.to();var headPos=cursorCoords(cm,range.head,"div");if(range.goalColumn!=null)headPos.left=range.goalColumn;goals.push(headPos.left);var pos=findPosV(cm,headPos,dir,unit);if(unit=="page"&&range==doc.sel.primary())
|
649 |
-
addToScrollPos(cm,null,charCoords(cm,pos,"div").top-headPos.top);return pos;},sel_move);if(goals.length)for(var i=0;i<doc.sel.ranges.length;i++)
|
650 |
-
doc.sel.ranges[i].goalColumn=goals[i];}),findWordAt:function(pos){var doc=this.doc,line=getLine(doc,pos.line).text;var start=pos.ch,end=pos.ch;if(line){var helper=this.getHelper(pos,"wordChars");if((pos.xRel<0||end==line.length)&&start)--start;else++end;var startChar=line.charAt(start);var check=isWordChar(startChar,helper)?function(ch){return isWordChar(ch,helper);}:/\s/.test(startChar)?function(ch){return/\s/.test(ch);}:function(ch){return!/\s/.test(ch)&&!isWordChar(ch);};while(start>0&&check(line.charAt(start-1)))--start;while(end<line.length&&check(line.charAt(end)))++end;}
|
651 |
-
return new Range(Pos(pos.line,start),Pos(pos.line,end));},toggleOverwrite:function(value){if(value!=null&&value==this.state.overwrite)return;if(this.state.overwrite=!this.state.overwrite)
|
652 |
-
addClass(this.display.cursorDiv,"CodeMirror-overwrite");else
|
653 |
-
rmClass(this.display.cursorDiv,"CodeMirror-overwrite");signal(this,"overwriteToggle",this,this.state.overwrite);},hasFocus:function(){return this.display.input.getField()==activeElt();},scrollTo:methodOp(function(x,y){if(x!=null||y!=null)resolveScrollToPos(this);if(x!=null)this.curOp.scrollLeft=x;if(y!=null)this.curOp.scrollTop=y;}),getScrollInfo:function(){var scroller=this.display.scroller;return{left:scroller.scrollLeft,top:scroller.scrollTop,height:scroller.scrollHeight-scrollGap(this)-this.display.barHeight,width:scroller.scrollWidth-scrollGap(this)-this.display.barWidth,clientHeight:displayHeight(this),clientWidth:displayWidth(this)};},scrollIntoView:methodOp(function(range,margin){if(range==null){range={from:this.doc.sel.primary().head,to:null};if(margin==null)margin=this.options.cursorScrollMargin;}else if(typeof range=="number"){range={from:Pos(range,0),to:null};}else if(range.from==null){range={from:range,to:null};}
|
654 |
-
if(!range.to)range.to=range.from;range.margin=margin||0;if(range.from.line!=null){resolveScrollToPos(this);this.curOp.scrollToPos=range;}else{var sPos=calculateScrollPos(this,Math.min(range.from.left,range.to.left),Math.min(range.from.top,range.to.top)-range.margin,Math.max(range.from.right,range.to.right),Math.max(range.from.bottom,range.to.bottom)+range.margin);this.scrollTo(sPos.scrollLeft,sPos.scrollTop);}}),setSize:methodOp(function(width,height){var cm=this;function interpret(val){return typeof val=="number"||/^\d+$/.test(String(val))?val+"px":val;}
|
655 |
-
if(width!=null)cm.display.wrapper.style.width=interpret(width);if(height!=null)cm.display.wrapper.style.height=interpret(height);if(cm.options.lineWrapping)clearLineMeasurementCache(this);var lineNo=cm.display.viewFrom;cm.doc.iter(lineNo,cm.display.viewTo,function(line){if(line.widgets)for(var i=0;i<line.widgets.length;i++)
|
656 |
-
if(line.widgets[i].noHScroll){regLineChange(cm,lineNo,"widget");break;}
|
657 |
-
++lineNo;});cm.curOp.forceUpdate=true;signal(cm,"refresh",this);}),operation:function(f){return runInOp(this,f);},refresh:methodOp(function(){var oldHeight=this.display.cachedTextHeight;regChange(this);this.curOp.forceUpdate=true;clearCaches(this);this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop);updateGutterSpace(this);if(oldHeight==null||Math.abs(oldHeight-textHeight(this.display))>.5)
|
658 |
-
estimateLineHeights(this);signal(this,"refresh",this);}),swapDoc:methodOp(function(doc){var old=this.doc;old.cm=null;attachDoc(this,doc);clearCaches(this);this.display.input.reset();this.scrollTo(doc.scrollLeft,doc.scrollTop);this.curOp.forceScroll=true;signalLater(this,"swapDoc",this,old);return old;}),getInputField:function(){return this.display.input.getField();},getWrapperElement:function(){return this.display.wrapper;},getScrollerElement:function(){return this.display.scroller;},getGutterElement:function(){return this.display.gutters;}};eventMixin(CodeMirror);var defaults=CodeMirror.defaults={};var optionHandlers=CodeMirror.optionHandlers={};function option(name,deflt,handle,notOnInit){CodeMirror.defaults[name]=deflt;if(handle)optionHandlers[name]=notOnInit?function(cm,val,old){if(old!=Init)handle(cm,val,old);}:handle;}
|
659 |
-
var Init=CodeMirror.Init={toString:function(){return"CodeMirror.Init";}};option("value","",function(cm,val){cm.setValue(val);},true);option("mode",null,function(cm,val){cm.doc.modeOption=val;loadMode(cm);},true);option("indentUnit",2,loadMode,true);option("indentWithTabs",false);option("smartIndent",true);option("tabSize",4,function(cm){resetModeState(cm);clearCaches(cm);regChange(cm);},true);option("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(cm,val,old){cm.state.specialChars=new RegExp(val.source+(val.test("\t")?"":"|\t"),"g");if(old!=CodeMirror.Init)cm.refresh();});option("specialCharPlaceholder",defaultSpecialCharPlaceholder,function(cm){cm.refresh();},true);option("electricChars",true);option("inputStyle",mobile?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor");},true);option("rtlMoveVisually",!windows);option("wholeLineUpdateBefore",true);option("theme","default",function(cm){themeChanged(cm);guttersChanged(cm);},true);option("keyMap","default",function(cm,val,old){var next=getKeyMap(val);var prev=old!=CodeMirror.Init&&getKeyMap(old);if(prev&&prev.detach)prev.detach(cm,next);if(next.attach)next.attach(cm,prev||null);});option("extraKeys",null);option("lineWrapping",false,wrappingChanged,true);option("gutters",[],function(cm){setGuttersForLineNumbers(cm.options);guttersChanged(cm);},true);option("fixedGutter",true,function(cm,val){cm.display.gutters.style.left=val?compensateForHScroll(cm.display)+"px":"0";cm.refresh();},true);option("coverGutterNextToScrollbar",false,function(cm){updateScrollbars(cm);},true);option("scrollbarStyle","native",function(cm){initScrollbars(cm);updateScrollbars(cm);cm.display.scrollbars.setScrollTop(cm.doc.scrollTop);cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft);},true);option("lineNumbers",false,function(cm){setGuttersForLineNumbers(cm.options);guttersChanged(cm);},true);option("firstLineNumber",1,guttersChanged,true);option("lineNumberFormatter",function(integer){return integer;},guttersChanged,true);option("showCursorWhenSelecting",false,updateSelection,true);option("resetSelectionOnContextMenu",true);option("lineWiseCopyCut",true);option("readOnly",false,function(cm,val){if(val=="nocursor"){onBlur(cm);cm.display.input.blur();cm.display.disabled=true;}else{cm.display.disabled=false;if(!val)cm.display.input.reset();}});option("disableInput",false,function(cm,val){if(!val)cm.display.input.reset();},true);option("dragDrop",true,dragDropChanged);option("cursorBlinkRate",530);option("cursorScrollMargin",0);option("cursorHeight",1,updateSelection,true);option("singleCursorHeightPerLine",true,updateSelection,true);option("workTime",100);option("workDelay",100);option("flattenSpans",true,resetModeState,true);option("addModeClass",false,resetModeState,true);option("pollInterval",100);option("undoDepth",200,function(cm,val){cm.doc.history.undoDepth=val;});option("historyEventDelay",1250);option("viewportMargin",10,function(cm){cm.refresh();},true);option("maxHighlightLength",10000,resetModeState,true);option("moveInputWithCursor",true,function(cm,val){if(!val)cm.display.input.resetPosition();});option("tabindex",null,function(cm,val){cm.display.input.getField().tabIndex=val||"";});option("autofocus",null);var modes=CodeMirror.modes={},mimeModes=CodeMirror.mimeModes={};CodeMirror.defineMode=function(name,mode){if(!CodeMirror.defaults.mode&&name!="null")CodeMirror.defaults.mode=name;if(arguments.length>2)
|
660 |
-
mode.dependencies=Array.prototype.slice.call(arguments,2);modes[name]=mode;};CodeMirror.defineMIME=function(mime,spec){mimeModes[mime]=spec;};CodeMirror.resolveMode=function(spec){if(typeof spec=="string"&&mimeModes.hasOwnProperty(spec)){spec=mimeModes[spec];}else if(spec&&typeof spec.name=="string"&&mimeModes.hasOwnProperty(spec.name)){var found=mimeModes[spec.name];if(typeof found=="string")found={name:found};spec=createObj(found,spec);spec.name=found.name;}else if(typeof spec=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(spec)){return CodeMirror.resolveMode("application/xml");}
|
661 |
-
if(typeof spec=="string")return{name:spec};else return spec||{name:"null"};};CodeMirror.getMode=function(options,spec){var spec=CodeMirror.resolveMode(spec);var mfactory=modes[spec.name];if(!mfactory)return CodeMirror.getMode(options,"text/plain");var modeObj=mfactory(options,spec);if(modeExtensions.hasOwnProperty(spec.name)){var exts=modeExtensions[spec.name];for(var prop in exts){if(!exts.hasOwnProperty(prop))continue;if(modeObj.hasOwnProperty(prop))modeObj["_"+prop]=modeObj[prop];modeObj[prop]=exts[prop];}}
|
662 |
-
modeObj.name=spec.name;if(spec.helperType)modeObj.helperType=spec.helperType;if(spec.modeProps)for(var prop in spec.modeProps)
|
663 |
-
modeObj[prop]=spec.modeProps[prop];return modeObj;};CodeMirror.defineMode("null",function(){return{token:function(stream){stream.skipToEnd();}};});CodeMirror.defineMIME("text/plain","null");var modeExtensions=CodeMirror.modeExtensions={};CodeMirror.extendMode=function(mode,properties){var exts=modeExtensions.hasOwnProperty(mode)?modeExtensions[mode]:(modeExtensions[mode]={});copyObj(properties,exts);};CodeMirror.defineExtension=function(name,func){CodeMirror.prototype[name]=func;};CodeMirror.defineDocExtension=function(name,func){Doc.prototype[name]=func;};CodeMirror.defineOption=option;var initHooks=[];CodeMirror.defineInitHook=function(f){initHooks.push(f);};var helpers=CodeMirror.helpers={};CodeMirror.registerHelper=function(type,name,value){if(!helpers.hasOwnProperty(type))helpers[type]=CodeMirror[type]={_global:[]};helpers[type][name]=value;};CodeMirror.registerGlobalHelper=function(type,name,predicate,value){CodeMirror.registerHelper(type,name,value);helpers[type]._global.push({pred:predicate,val:value});};var copyState=CodeMirror.copyState=function(mode,state){if(state===true)return state;if(mode.copyState)return mode.copyState(state);var nstate={};for(var n in state){var val=state[n];if(val instanceof Array)val=val.concat([]);nstate[n]=val;}
|
664 |
-
return nstate;};var startState=CodeMirror.startState=function(mode,a1,a2){return mode.startState?mode.startState(a1,a2):true;};CodeMirror.innerMode=function(mode,state){while(mode.innerMode){var info=mode.innerMode(state);if(!info||info.mode==mode)break;state=info.state;mode=info.mode;}
|
665 |
-
return info||{mode:mode,state:state};};var commands=CodeMirror.commands={selectAll:function(cm){cm.setSelection(Pos(cm.firstLine(),0),Pos(cm.lastLine()),sel_dontScroll);},singleSelection:function(cm){cm.setSelection(cm.getCursor("anchor"),cm.getCursor("head"),sel_dontScroll);},killLine:function(cm){deleteNearSelection(cm,function(range){if(range.empty()){var len=getLine(cm.doc,range.head.line).text.length;if(range.head.ch==len&&range.head.line<cm.lastLine())
|
666 |
-
return{from:range.head,to:Pos(range.head.line+1,0)};else
|
667 |
-
return{from:range.head,to:Pos(range.head.line,len)};}else{return{from:range.from(),to:range.to()};}});},deleteLine:function(cm){deleteNearSelection(cm,function(range){return{from:Pos(range.from().line,0),to:clipPos(cm.doc,Pos(range.to().line+1,0))};});},delLineLeft:function(cm){deleteNearSelection(cm,function(range){return{from:Pos(range.from().line,0),to:range.from()};});},delWrappedLineLeft:function(cm){deleteNearSelection(cm,function(range){var top=cm.charCoords(range.head,"div").top+5;var leftPos=cm.coordsChar({left:0,top:top},"div");return{from:leftPos,to:range.from()};});},delWrappedLineRight:function(cm){deleteNearSelection(cm,function(range){var top=cm.charCoords(range.head,"div").top+5;var rightPos=cm.coordsChar({left:cm.display.lineDiv.offsetWidth+100,top:top},"div");return{from:range.from(),to:rightPos};});},undo:function(cm){cm.undo();},redo:function(cm){cm.redo();},undoSelection:function(cm){cm.undoSelection();},redoSelection:function(cm){cm.redoSelection();},goDocStart:function(cm){cm.extendSelection(Pos(cm.firstLine(),0));},goDocEnd:function(cm){cm.extendSelection(Pos(cm.lastLine()));},goLineStart:function(cm){cm.extendSelectionsBy(function(range){return lineStart(cm,range.head.line);},{origin:"+move",bias:1});},goLineStartSmart:function(cm){cm.extendSelectionsBy(function(range){return lineStartSmart(cm,range.head);},{origin:"+move",bias:1});},goLineEnd:function(cm){cm.extendSelectionsBy(function(range){return lineEnd(cm,range.head.line);},{origin:"+move",bias:-1});},goLineRight:function(cm){cm.extendSelectionsBy(function(range){var top=cm.charCoords(range.head,"div").top+5;return cm.coordsChar({left:cm.display.lineDiv.offsetWidth+100,top:top},"div");},sel_move);},goLineLeft:function(cm){cm.extendSelectionsBy(function(range){var top=cm.charCoords(range.head,"div").top+5;return cm.coordsChar({left:0,top:top},"div");},sel_move);},goLineLeftSmart:function(cm){cm.extendSelectionsBy(function(range){var top=cm.charCoords(range.head,"div").top+5;var pos=cm.coordsChar({left:0,top:top},"div");if(pos.ch<cm.getLine(pos.line).search(/\S/))return lineStartSmart(cm,range.head);return pos;},sel_move);},goLineUp:function(cm){cm.moveV(-1,"line");},goLineDown:function(cm){cm.moveV(1,"line");},goPageUp:function(cm){cm.moveV(-1,"page");},goPageDown:function(cm){cm.moveV(1,"page");},goCharLeft:function(cm){cm.moveH(-1,"char");},goCharRight:function(cm){cm.moveH(1,"char");},goColumnLeft:function(cm){cm.moveH(-1,"column");},goColumnRight:function(cm){cm.moveH(1,"column");},goWordLeft:function(cm){cm.moveH(-1,"word");},goGroupRight:function(cm){cm.moveH(1,"group");},goGroupLeft:function(cm){cm.moveH(-1,"group");},goWordRight:function(cm){cm.moveH(1,"word");},delCharBefore:function(cm){cm.deleteH(-1,"char");},delCharAfter:function(cm){cm.deleteH(1,"char");},delWordBefore:function(cm){cm.deleteH(-1,"word");},delWordAfter:function(cm){cm.deleteH(1,"word");},delGroupBefore:function(cm){cm.deleteH(-1,"group");},delGroupAfter:function(cm){cm.deleteH(1,"group");},indentAuto:function(cm){cm.indentSelection("smart");},indentMore:function(cm){cm.indentSelection("add");},indentLess:function(cm){cm.indentSelection("subtract");},insertTab:function(cm){cm.replaceSelection("\t");},insertSoftTab:function(cm){var spaces=[],ranges=cm.listSelections(),tabSize=cm.options.tabSize;for(var i=0;i<ranges.length;i++){var pos=ranges[i].from();var col=countColumn(cm.getLine(pos.line),pos.ch,tabSize);spaces.push(new Array(tabSize-col%tabSize+1).join(" "));}
|
668 |
-
cm.replaceSelections(spaces);},defaultTab:function(cm){if(cm.somethingSelected())cm.indentSelection("add");else cm.execCommand("insertTab");},transposeChars:function(cm){runInOp(cm,function(){var ranges=cm.listSelections(),newSel=[];for(var i=0;i<ranges.length;i++){var cur=ranges[i].head,line=getLine(cm.doc,cur.line).text;if(line){if(cur.ch==line.length)cur=new Pos(cur.line,cur.ch-1);if(cur.ch>0){cur=new Pos(cur.line,cur.ch+1);cm.replaceRange(line.charAt(cur.ch-1)+line.charAt(cur.ch-2),Pos(cur.line,cur.ch-2),cur,"+transpose");}else if(cur.line>cm.doc.first){var prev=getLine(cm.doc,cur.line-1).text;if(prev)
|
669 |
-
cm.replaceRange(line.charAt(0)+"\n"+prev.charAt(prev.length-1),Pos(cur.line-1,prev.length-1),Pos(cur.line,1),"+transpose");}}
|
670 |
-
newSel.push(new Range(cur,cur));}
|
671 |
-
cm.setSelections(newSel);});},newlineAndIndent:function(cm){runInOp(cm,function(){var len=cm.listSelections().length;for(var i=0;i<len;i++){var range=cm.listSelections()[i];cm.replaceRange("\n",range.anchor,range.head,"+input");cm.indentLine(range.from().line+1,null,true);ensureCursorVisible(cm);}});},toggleOverwrite:function(cm){cm.toggleOverwrite();}};var keyMap=CodeMirror.keyMap={};keyMap.basic={"Left":"goCharLeft","Right":"goCharRight","Up":"goLineUp","Down":"goLineDown","End":"goLineEnd","Home":"goLineStartSmart","PageUp":"goPageUp","PageDown":"goPageDown","Delete":"delCharAfter","Backspace":"delCharBefore","Shift-Backspace":"delCharBefore","Tab":"defaultTab","Shift-Tab":"indentAuto","Enter":"newlineAndIndent","Insert":"toggleOverwrite","Esc":"singleSelection"};keyMap.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"};keyMap.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"};keyMap.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]};keyMap["default"]=mac?keyMap.macDefault:keyMap.pcDefault;function normalizeKeyName(name){var parts=name.split(/-(?!$)/),name=parts[parts.length-1];var alt,ctrl,shift,cmd;for(var i=0;i<parts.length-1;i++){var mod=parts[i];if(/^(cmd|meta|m)$/i.test(mod))cmd=true;else if(/^a(lt)?$/i.test(mod))alt=true;else if(/^(c|ctrl|control)$/i.test(mod))ctrl=true;else if(/^s(hift)$/i.test(mod))shift=true;else throw new Error("Unrecognized modifier name: "+mod);}
|
672 |
-
if(alt)name="Alt-"+name;if(ctrl)name="Ctrl-"+name;if(cmd)name="Cmd-"+name;if(shift)name="Shift-"+name;return name;}
|
673 |
-
CodeMirror.normalizeKeyMap=function(keymap){var copy={};for(var keyname in keymap)if(keymap.hasOwnProperty(keyname)){var value=keymap[keyname];if(/^(name|fallthrough|(de|at)tach)$/.test(keyname))continue;if(value=="..."){delete keymap[keyname];continue;}
|
674 |
-
var keys=map(keyname.split(" "),normalizeKeyName);for(var i=0;i<keys.length;i++){var val,name;if(i==keys.length-1){name=keyname;val=value;}else{name=keys.slice(0,i+1).join(" ");val="...";}
|
675 |
-
var prev=copy[name];if(!prev)copy[name]=val;else if(prev!=val)throw new Error("Inconsistent bindings for "+name);}
|
676 |
-
delete keymap[keyname];}
|
677 |
-
for(var prop in copy)keymap[prop]=copy[prop];return keymap;};var lookupKey=CodeMirror.lookupKey=function(key,map,handle,context){map=getKeyMap(map);var found=map.call?map.call(key,context):map[key];if(found===false)return"nothing";if(found==="...")return"multi";if(found!=null&&handle(found))return"handled";if(map.fallthrough){if(Object.prototype.toString.call(map.fallthrough)!="[object Array]")
|
678 |
-
return lookupKey(key,map.fallthrough,handle,context);for(var i=0;i<map.fallthrough.length;i++){var result=lookupKey(key,map.fallthrough[i],handle,context);if(result)return result;}}};var isModifierKey=CodeMirror.isModifierKey=function(value){var name=typeof value=="string"?value:keyNames[value.keyCode];return name=="Ctrl"||name=="Alt"||name=="Shift"||name=="Mod";};var keyName=CodeMirror.keyName=function(event,noShift){if(presto&&event.keyCode==34&&event["char"])return false;var base=keyNames[event.keyCode],name=base;if(name==null||event.altGraphKey)return false;if(event.altKey&&base!="Alt")name="Alt-"+name;if((flipCtrlCmd?event.metaKey:event.ctrlKey)&&base!="Ctrl")name="Ctrl-"+name;if((flipCtrlCmd?event.ctrlKey:event.metaKey)&&base!="Cmd")name="Cmd-"+name;if(!noShift&&event.shiftKey&&base!="Shift")name="Shift-"+name;return name;};function getKeyMap(val){return typeof val=="string"?keyMap[val]:val;}
|
679 |
-
CodeMirror.fromTextArea=function(textarea,options){options=options?copyObj(options):{};options.value=textarea.value;if(!options.tabindex&&textarea.tabIndex)
|
680 |
-
options.tabindex=textarea.tabIndex;if(!options.placeholder&&textarea.placeholder)
|
681 |
-
options.placeholder=textarea.placeholder;if(options.autofocus==null){var hasFocus=activeElt();options.autofocus=hasFocus==textarea||textarea.getAttribute("autofocus")!=null&&hasFocus==document.body;}
|
682 |
-
function save(){textarea.value=cm.getValue();}
|
683 |
-
if(textarea.form){on(textarea.form,"submit",save);if(!options.leaveSubmitMethodAlone){var form=textarea.form,realSubmit=form.submit;try{var wrappedSubmit=form.submit=function(){save();form.submit=realSubmit;form.submit();form.submit=wrappedSubmit;};}catch(e){}}}
|
684 |
-
options.finishInit=function(cm){cm.save=save;cm.getTextArea=function(){return textarea;};cm.toTextArea=function(){cm.toTextArea=isNaN;save();textarea.parentNode.removeChild(cm.getWrapperElement());textarea.style.display="";if(textarea.form){off(textarea.form,"submit",save);if(typeof textarea.form.submit=="function")
|
685 |
-
textarea.form.submit=realSubmit;}};};textarea.style.display="none";var cm=CodeMirror(function(node){textarea.parentNode.insertBefore(node,textarea.nextSibling);},options);return cm;};var StringStream=CodeMirror.StringStream=function(string,tabSize){this.pos=this.start=0;this.string=string;this.tabSize=tabSize||8;this.lastColumnPos=this.lastColumnValue=0;this.lineStart=0;};StringStream.prototype={eol:function(){return this.pos>=this.string.length;},sol:function(){return this.pos==this.lineStart;},peek:function(){return this.string.charAt(this.pos)||undefined;},next:function(){if(this.pos<this.string.length)
|
686 |
-
return this.string.charAt(this.pos++);},eat:function(match){var ch=this.string.charAt(this.pos);if(typeof match=="string")var ok=ch==match;else var ok=ch&&(match.test?match.test(ch):match(ch));if(ok){++this.pos;return ch;}},eatWhile:function(match){var start=this.pos;while(this.eat(match)){}
|
687 |
-
return this.pos>start;},eatSpace:function(){var start=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>start;},skipToEnd:function(){this.pos=this.string.length;},skipTo:function(ch){var found=this.string.indexOf(ch,this.pos);if(found>-1){this.pos=found;return true;}},backUp:function(n){this.pos-=n;},column:function(){if(this.lastColumnPos<this.start){this.lastColumnValue=countColumn(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue);this.lastColumnPos=this.start;}
|
688 |
-
return this.lastColumnValue-(this.lineStart?countColumn(this.string,this.lineStart,this.tabSize):0);},indentation:function(){return countColumn(this.string,null,this.tabSize)-
|
689 |
-
(this.lineStart?countColumn(this.string,this.lineStart,this.tabSize):0);},match:function(pattern,consume,caseInsensitive){if(typeof pattern=="string"){var cased=function(str){return caseInsensitive?str.toLowerCase():str;};var substr=this.string.substr(this.pos,pattern.length);if(cased(substr)==cased(pattern)){if(consume!==false)this.pos+=pattern.length;return true;}}else{var match=this.string.slice(this.pos).match(pattern);if(match&&match.index>0)return null;if(match&&consume!==false)this.pos+=match[0].length;return match;}},current:function(){return this.string.slice(this.start,this.pos);},hideFirstChars:function(n,inner){this.lineStart+=n;try{return inner();}
|
690 |
-
finally{this.lineStart-=n;}}};var nextMarkerId=0;var TextMarker=CodeMirror.TextMarker=function(doc,type){this.lines=[];this.type=type;this.doc=doc;this.id=++nextMarkerId;};eventMixin(TextMarker);TextMarker.prototype.clear=function(){if(this.explicitlyCleared)return;var cm=this.doc.cm,withOp=cm&&!cm.curOp;if(withOp)startOperation(cm);if(hasHandler(this,"clear")){var found=this.find();if(found)signalLater(this,"clear",found.from,found.to);}
|
691 |
-
var min=null,max=null;for(var i=0;i<this.lines.length;++i){var line=this.lines[i];var span=getMarkedSpanFor(line.markedSpans,this);if(cm&&!this.collapsed)regLineChange(cm,lineNo(line),"text");else if(cm){if(span.to!=null)max=lineNo(line);if(span.from!=null)min=lineNo(line);}
|
692 |
-
line.markedSpans=removeMarkedSpan(line.markedSpans,span);if(span.from==null&&this.collapsed&&!lineIsHidden(this.doc,line)&&cm)
|
693 |
-
updateLineHeight(line,textHeight(cm.display));}
|
694 |
-
if(cm&&this.collapsed&&!cm.options.lineWrapping)for(var i=0;i<this.lines.length;++i){var visual=visualLine(this.lines[i]),len=lineLength(visual);if(len>cm.display.maxLineLength){cm.display.maxLine=visual;cm.display.maxLineLength=len;cm.display.maxLineChanged=true;}}
|
695 |
-
if(min!=null&&cm&&this.collapsed)regChange(cm,min,max+1);this.lines.length=0;this.explicitlyCleared=true;if(this.atomic&&this.doc.cantEdit){this.doc.cantEdit=false;if(cm)reCheckSelection(cm.doc);}
|
696 |
-
if(cm)signalLater(cm,"markerCleared",cm,this);if(withOp)endOperation(cm);if(this.parent)this.parent.clear();};TextMarker.prototype.find=function(side,lineObj){if(side==null&&this.type=="bookmark")side=1;var from,to;for(var i=0;i<this.lines.length;++i){var line=this.lines[i];var span=getMarkedSpanFor(line.markedSpans,this);if(span.from!=null){from=Pos(lineObj?line:lineNo(line),span.from);if(side==-1)return from;}
|
697 |
-
if(span.to!=null){to=Pos(lineObj?line:lineNo(line),span.to);if(side==1)return to;}}
|
698 |
-
return from&&{from:from,to:to};};TextMarker.prototype.changed=function(){var pos=this.find(-1,true),widget=this,cm=this.doc.cm;if(!pos||!cm)return;runInOp(cm,function(){var line=pos.line,lineN=lineNo(pos.line);var view=findViewForLine(cm,lineN);if(view){clearLineMeasurementCacheFor(view);cm.curOp.selectionChanged=cm.curOp.forceUpdate=true;}
|
699 |
-
cm.curOp.updateMaxLine=true;if(!lineIsHidden(widget.doc,line)&&widget.height!=null){var oldHeight=widget.height;widget.height=null;var dHeight=widgetHeight(widget)-oldHeight;if(dHeight)
|
700 |
-
updateLineHeight(line,line.height+dHeight);}});};TextMarker.prototype.attachLine=function(line){if(!this.lines.length&&this.doc.cm){var op=this.doc.cm.curOp;if(!op.maybeHiddenMarkers||indexOf(op.maybeHiddenMarkers,this)==-1)
|
701 |
-
(op.maybeUnhiddenMarkers||(op.maybeUnhiddenMarkers=[])).push(this);}
|
702 |
-
this.lines.push(line);};TextMarker.prototype.detachLine=function(line){this.lines.splice(indexOf(this.lines,line),1);if(!this.lines.length&&this.doc.cm){var op=this.doc.cm.curOp;(op.maybeHiddenMarkers||(op.maybeHiddenMarkers=[])).push(this);}};var nextMarkerId=0;function markText(doc,from,to,options,type){if(options&&options.shared)return markTextShared(doc,from,to,options,type);if(doc.cm&&!doc.cm.curOp)return operation(doc.cm,markText)(doc,from,to,options,type);var marker=new TextMarker(doc,type),diff=cmp(from,to);if(options)copyObj(options,marker,false);if(diff>0||diff==0&&marker.clearWhenEmpty!==false)
|
703 |
-
return marker;if(marker.replacedWith){marker.collapsed=true;marker.widgetNode=elt("span",[marker.replacedWith],"CodeMirror-widget");if(!options.handleMouseEvents)marker.widgetNode.setAttribute("cm-ignore-events","true");if(options.insertLeft)marker.widgetNode.insertLeft=true;}
|
704 |
-
if(marker.collapsed){if(conflictingCollapsedRange(doc,from.line,from,to,marker)||from.line!=to.line&&conflictingCollapsedRange(doc,to.line,from,to,marker))
|
705 |
-
throw new Error("Inserting collapsed marker partially overlapping an existing one");sawCollapsedSpans=true;}
|
706 |
-
if(marker.addToHistory)
|
707 |
-
addChangeToHistory(doc,{from:from,to:to,origin:"markText"},doc.sel,NaN);var curLine=from.line,cm=doc.cm,updateMaxLine;doc.iter(curLine,to.line+1,function(line){if(cm&&marker.collapsed&&!cm.options.lineWrapping&&visualLine(line)==cm.display.maxLine)
|
708 |
-
updateMaxLine=true;if(marker.collapsed&&curLine!=from.line)updateLineHeight(line,0);addMarkedSpan(line,new MarkedSpan(marker,curLine==from.line?from.ch:null,curLine==to.line?to.ch:null));++curLine;});if(marker.collapsed)doc.iter(from.line,to.line+1,function(line){if(lineIsHidden(doc,line))updateLineHeight(line,0);});if(marker.clearOnEnter)on(marker,"beforeCursorEnter",function(){marker.clear();});if(marker.readOnly){sawReadOnlySpans=true;if(doc.history.done.length||doc.history.undone.length)
|
709 |
-
doc.clearHistory();}
|
710 |
-
if(marker.collapsed){marker.id=++nextMarkerId;marker.atomic=true;}
|
711 |
-
if(cm){if(updateMaxLine)cm.curOp.updateMaxLine=true;if(marker.collapsed)
|
712 |
-
regChange(cm,from.line,to.line+1);else if(marker.className||marker.title||marker.startStyle||marker.endStyle||marker.css)
|
713 |
-
for(var i=from.line;i<=to.line;i++)regLineChange(cm,i,"text");if(marker.atomic)reCheckSelection(cm.doc);signalLater(cm,"markerAdded",cm,marker);}
|
714 |
-
return marker;}
|
715 |
-
var SharedTextMarker=CodeMirror.SharedTextMarker=function(markers,primary){this.markers=markers;this.primary=primary;for(var i=0;i<markers.length;++i)
|
716 |
-
markers[i].parent=this;};eventMixin(SharedTextMarker);SharedTextMarker.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=true;for(var i=0;i<this.markers.length;++i)
|
717 |
-
this.markers[i].clear();signalLater(this,"clear");};SharedTextMarker.prototype.find=function(side,lineObj){return this.primary.find(side,lineObj);};function markTextShared(doc,from,to,options,type){options=copyObj(options);options.shared=false;var markers=[markText(doc,from,to,options,type)],primary=markers[0];var widget=options.widgetNode;linkedDocs(doc,function(doc){if(widget)options.widgetNode=widget.cloneNode(true);markers.push(markText(doc,clipPos(doc,from),clipPos(doc,to),options,type));for(var i=0;i<doc.linked.length;++i)
|
718 |
-
if(doc.linked[i].isParent)return;primary=lst(markers);});return new SharedTextMarker(markers,primary);}
|
719 |
-
function findSharedMarkers(doc){return doc.findMarks(Pos(doc.first,0),doc.clipPos(Pos(doc.lastLine())),function(m){return m.parent;});}
|
720 |
-
function copySharedMarkers(doc,markers){for(var i=0;i<markers.length;i++){var marker=markers[i],pos=marker.find();var mFrom=doc.clipPos(pos.from),mTo=doc.clipPos(pos.to);if(cmp(mFrom,mTo)){var subMark=markText(doc,mFrom,mTo,marker.primary,marker.primary.type);marker.markers.push(subMark);subMark.parent=marker;}}}
|
721 |
-
function detachSharedMarkers(markers){for(var i=0;i<markers.length;i++){var marker=markers[i],linked=[marker.primary.doc];;linkedDocs(marker.primary.doc,function(d){linked.push(d);});for(var j=0;j<marker.markers.length;j++){var subMarker=marker.markers[j];if(indexOf(linked,subMarker.doc)==-1){subMarker.parent=null;marker.markers.splice(j--,1);}}}}
|
722 |
-
function MarkedSpan(marker,from,to){this.marker=marker;this.from=from;this.to=to;}
|
723 |
-
function getMarkedSpanFor(spans,marker){if(spans)for(var i=0;i<spans.length;++i){var span=spans[i];if(span.marker==marker)return span;}}
|
724 |
-
function removeMarkedSpan(spans,span){for(var r,i=0;i<spans.length;++i)
|
725 |
-
if(spans[i]!=span)(r||(r=[])).push(spans[i]);return r;}
|
726 |
-
function addMarkedSpan(line,span){line.markedSpans=line.markedSpans?line.markedSpans.concat([span]):[span];span.marker.attachLine(line);}
|
727 |
-
function markedSpansBefore(old,startCh,isInsert){if(old)for(var i=0,nw;i<old.length;++i){var span=old[i],marker=span.marker;var startsBefore=span.from==null||(marker.inclusiveLeft?span.from<=startCh:span.from<startCh);if(startsBefore||span.from==startCh&&marker.type=="bookmark"&&(!isInsert||!span.marker.insertLeft)){var endsAfter=span.to==null||(marker.inclusiveRight?span.to>=startCh:span.to>startCh);(nw||(nw=[])).push(new MarkedSpan(marker,span.from,endsAfter?null:span.to));}}
|
728 |
-
return nw;}
|
729 |
-
function markedSpansAfter(old,endCh,isInsert){if(old)for(var i=0,nw;i<old.length;++i){var span=old[i],marker=span.marker;var endsAfter=span.to==null||(marker.inclusiveRight?span.to>=endCh:span.to>endCh);if(endsAfter||span.from==endCh&&marker.type=="bookmark"&&(!isInsert||span.marker.insertLeft)){var startsBefore=span.from==null||(marker.inclusiveLeft?span.from<=endCh:span.from<endCh);(nw||(nw=[])).push(new MarkedSpan(marker,startsBefore?null:span.from-endCh,span.to==null?null:span.to-endCh));}}
|
730 |
-
return nw;}
|
731 |
-
function stretchSpansOverChange(doc,change){if(change.full)return null;var oldFirst=isLine(doc,change.from.line)&&getLine(doc,change.from.line).markedSpans;var oldLast=isLine(doc,change.to.line)&&getLine(doc,change.to.line).markedSpans;if(!oldFirst&&!oldLast)return null;var startCh=change.from.ch,endCh=change.to.ch,isInsert=cmp(change.from,change.to)==0;var first=markedSpansBefore(oldFirst,startCh,isInsert);var last=markedSpansAfter(oldLast,endCh,isInsert);var sameLine=change.text.length==1,offset=lst(change.text).length+(sameLine?startCh:0);if(first){for(var i=0;i<first.length;++i){var span=first[i];if(span.to==null){var found=getMarkedSpanFor(last,span.marker);if(!found)span.to=startCh;else if(sameLine)span.to=found.to==null?null:found.to+offset;}}}
|
732 |
-
if(last){for(var i=0;i<last.length;++i){var span=last[i];if(span.to!=null)span.to+=offset;if(span.from==null){var found=getMarkedSpanFor(first,span.marker);if(!found){span.from=offset;if(sameLine)(first||(first=[])).push(span);}}else{span.from+=offset;if(sameLine)(first||(first=[])).push(span);}}}
|
733 |
-
if(first)first=clearEmptySpans(first);if(last&&last!=first)last=clearEmptySpans(last);var newMarkers=[first];if(!sameLine){var gap=change.text.length-2,gapMarkers;if(gap>0&&first)
|
734 |
-
for(var i=0;i<first.length;++i)
|
735 |
-
if(first[i].to==null)
|
736 |
-
(gapMarkers||(gapMarkers=[])).push(new MarkedSpan(first[i].marker,null,null));for(var i=0;i<gap;++i)
|
737 |
-
newMarkers.push(gapMarkers);newMarkers.push(last);}
|
738 |
-
return newMarkers;}
|
739 |
-
function clearEmptySpans(spans){for(var i=0;i<spans.length;++i){var span=spans[i];if(span.from!=null&&span.from==span.to&&span.marker.clearWhenEmpty!==false)
|
740 |
-
spans.splice(i--,1);}
|
741 |
-
if(!spans.length)return null;return spans;}
|
742 |
-
function mergeOldSpans(doc,change){var old=getOldSpans(doc,change);var stretched=stretchSpansOverChange(doc,change);if(!old)return stretched;if(!stretched)return old;for(var i=0;i<old.length;++i){var oldCur=old[i],stretchCur=stretched[i];if(oldCur&&stretchCur){spans:for(var j=0;j<stretchCur.length;++j){var span=stretchCur[j];for(var k=0;k<oldCur.length;++k)
|
743 |
-
if(oldCur[k].marker==span.marker)continue spans;oldCur.push(span);}}else if(stretchCur){old[i]=stretchCur;}}
|
744 |
-
return old;}
|
745 |
-
function removeReadOnlyRanges(doc,from,to){var markers=null;doc.iter(from.line,to.line+1,function(line){if(line.markedSpans)for(var i=0;i<line.markedSpans.length;++i){var mark=line.markedSpans[i].marker;if(mark.readOnly&&(!markers||indexOf(markers,mark)==-1))
|
746 |
-
(markers||(markers=[])).push(mark);}});if(!markers)return null;var parts=[{from:from,to:to}];for(var i=0;i<markers.length;++i){var mk=markers[i],m=mk.find(0);for(var j=0;j<parts.length;++j){var p=parts[j];if(cmp(p.to,m.from)<0||cmp(p.from,m.to)>0)continue;var newParts=[j,1],dfrom=cmp(p.from,m.from),dto=cmp(p.to,m.to);if(dfrom<0||!mk.inclusiveLeft&&!dfrom)
|
747 |
-
newParts.push({from:p.from,to:m.from});if(dto>0||!mk.inclusiveRight&&!dto)
|
748 |
-
newParts.push({from:m.to,to:p.to});parts.splice.apply(parts,newParts);j+=newParts.length-1;}}
|
749 |
-
return parts;}
|
750 |
-
function detachMarkedSpans(line){var spans=line.markedSpans;if(!spans)return;for(var i=0;i<spans.length;++i)
|
751 |
-
spans[i].marker.detachLine(line);line.markedSpans=null;}
|
752 |
-
function attachMarkedSpans(line,spans){if(!spans)return;for(var i=0;i<spans.length;++i)
|
753 |
-
spans[i].marker.attachLine(line);line.markedSpans=spans;}
|
754 |
-
function extraLeft(marker){return marker.inclusiveLeft?-1:0;}
|
755 |
-
function extraRight(marker){return marker.inclusiveRight?1:0;}
|
756 |
-
function compareCollapsedMarkers(a,b){var lenDiff=a.lines.length-b.lines.length;if(lenDiff!=0)return lenDiff;var aPos=a.find(),bPos=b.find();var fromCmp=cmp(aPos.from,bPos.from)||extraLeft(a)-extraLeft(b);if(fromCmp)return-fromCmp;var toCmp=cmp(aPos.to,bPos.to)||extraRight(a)-extraRight(b);if(toCmp)return toCmp;return b.id-a.id;}
|
757 |
-
function collapsedSpanAtSide(line,start){var sps=sawCollapsedSpans&&line.markedSpans,found;if(sps)for(var sp,i=0;i<sps.length;++i){sp=sps[i];if(sp.marker.collapsed&&(start?sp.from:sp.to)==null&&(!found||compareCollapsedMarkers(found,sp.marker)<0))
|
758 |
-
found=sp.marker;}
|
759 |
-
return found;}
|
760 |
-
function collapsedSpanAtStart(line){return collapsedSpanAtSide(line,true);}
|
761 |
-
function collapsedSpanAtEnd(line){return collapsedSpanAtSide(line,false);}
|
762 |
-
function conflictingCollapsedRange(doc,lineNo,from,to,marker){var line=getLine(doc,lineNo);var sps=sawCollapsedSpans&&line.markedSpans;if(sps)for(var i=0;i<sps.length;++i){var sp=sps[i];if(!sp.marker.collapsed)continue;var found=sp.marker.find(0);var fromCmp=cmp(found.from,from)||extraLeft(sp.marker)-extraLeft(marker);var toCmp=cmp(found.to,to)||extraRight(sp.marker)-extraRight(marker);if(fromCmp>=0&&toCmp<=0||fromCmp<=0&&toCmp>=0)continue;if(fromCmp<=0&&(cmp(found.to,from)>0||(sp.marker.inclusiveRight&&marker.inclusiveLeft))||fromCmp>=0&&(cmp(found.from,to)<0||(sp.marker.inclusiveLeft&&marker.inclusiveRight)))
|
763 |
-
return true;}}
|
764 |
-
function visualLine(line){var merged;while(merged=collapsedSpanAtStart(line))
|
765 |
-
line=merged.find(-1,true).line;return line;}
|
766 |
-
function visualLineContinued(line){var merged,lines;while(merged=collapsedSpanAtEnd(line)){line=merged.find(1,true).line;(lines||(lines=[])).push(line);}
|
767 |
-
return lines;}
|
768 |
-
function visualLineNo(doc,lineN){var line=getLine(doc,lineN),vis=visualLine(line);if(line==vis)return lineN;return lineNo(vis);}
|
769 |
-
function visualLineEndNo(doc,lineN){if(lineN>doc.lastLine())return lineN;var line=getLine(doc,lineN),merged;if(!lineIsHidden(doc,line))return lineN;while(merged=collapsedSpanAtEnd(line))
|
770 |
-
line=merged.find(1,true).line;return lineNo(line)+1;}
|
771 |
-
function lineIsHidden(doc,line){var sps=sawCollapsedSpans&&line.markedSpans;if(sps)for(var sp,i=0;i<sps.length;++i){sp=sps[i];if(!sp.marker.collapsed)continue;if(sp.from==null)return true;if(sp.marker.widgetNode)continue;if(sp.from==0&&sp.marker.inclusiveLeft&&lineIsHiddenInner(doc,line,sp))
|
772 |
-
return true;}}
|
773 |
-
function lineIsHiddenInner(doc,line,span){if(span.to==null){var end=span.marker.find(1,true);return lineIsHiddenInner(doc,end.line,getMarkedSpanFor(end.line.markedSpans,span.marker));}
|
774 |
-
if(span.marker.inclusiveRight&&span.to==line.text.length)
|
775 |
-
return true;for(var sp,i=0;i<line.markedSpans.length;++i){sp=line.markedSpans[i];if(sp.marker.collapsed&&!sp.marker.widgetNode&&sp.from==span.to&&(sp.to==null||sp.to!=span.from)&&(sp.marker.inclusiveLeft||span.marker.inclusiveRight)&&lineIsHiddenInner(doc,line,sp))return true;}}
|
776 |
-
var LineWidget=CodeMirror.LineWidget=function(doc,node,options){if(options)for(var opt in options)if(options.hasOwnProperty(opt))
|
777 |
-
this[opt]=options[opt];this.doc=doc;this.node=node;};eventMixin(LineWidget);function adjustScrollWhenAboveVisible(cm,line,diff){if(heightAtLine(line)<((cm.curOp&&cm.curOp.scrollTop)||cm.doc.scrollTop))
|
778 |
-
addToScrollPos(cm,null,diff);}
|
779 |
-
LineWidget.prototype.clear=function(){var cm=this.doc.cm,ws=this.line.widgets,line=this.line,no=lineNo(line);if(no==null||!ws)return;for(var i=0;i<ws.length;++i)if(ws[i]==this)ws.splice(i--,1);if(!ws.length)line.widgets=null;var height=widgetHeight(this);updateLineHeight(line,Math.max(0,line.height-height));if(cm)runInOp(cm,function(){adjustScrollWhenAboveVisible(cm,line,-height);regLineChange(cm,no,"widget");});};LineWidget.prototype.changed=function(){var oldH=this.height,cm=this.doc.cm,line=this.line;this.height=null;var diff=widgetHeight(this)-oldH;if(!diff)return;updateLineHeight(line,line.height+diff);if(cm)runInOp(cm,function(){cm.curOp.forceUpdate=true;adjustScrollWhenAboveVisible(cm,line,diff);});};function widgetHeight(widget){if(widget.height!=null)return widget.height;var cm=widget.doc.cm;if(!cm)return 0;if(!contains(document.body,widget.node)){var parentStyle="position: relative;";if(widget.coverGutter)
|
780 |
-
parentStyle+="margin-left: -"+cm.display.gutters.offsetWidth+"px;";if(widget.noHScroll)
|
781 |
-
parentStyle+="width: "+cm.display.wrapper.clientWidth+"px;";removeChildrenAndAdd(cm.display.measure,elt("div",[widget.node],null,parentStyle));}
|
782 |
-
return widget.height=widget.node.offsetHeight;}
|
783 |
-
function addLineWidget(doc,handle,node,options){var widget=new LineWidget(doc,node,options);var cm=doc.cm;if(cm&&widget.noHScroll)cm.display.alignWidgets=true;changeLine(doc,handle,"widget",function(line){var widgets=line.widgets||(line.widgets=[]);if(widget.insertAt==null)widgets.push(widget);else widgets.splice(Math.min(widgets.length-1,Math.max(0,widget.insertAt)),0,widget);widget.line=line;if(cm&&!lineIsHidden(doc,line)){var aboveVisible=heightAtLine(line)<doc.scrollTop;updateLineHeight(line,line.height+widgetHeight(widget));if(aboveVisible)addToScrollPos(cm,null,widget.height);cm.curOp.forceUpdate=true;}
|
784 |
-
return true;});return widget;}
|
785 |
-
var Line=CodeMirror.Line=function(text,markedSpans,estimateHeight){this.text=text;attachMarkedSpans(this,markedSpans);this.height=estimateHeight?estimateHeight(this):1;};eventMixin(Line);Line.prototype.lineNo=function(){return lineNo(this);};function updateLine(line,text,markedSpans,estimateHeight){line.text=text;if(line.stateAfter)line.stateAfter=null;if(line.styles)line.styles=null;if(line.order!=null)line.order=null;detachMarkedSpans(line);attachMarkedSpans(line,markedSpans);var estHeight=estimateHeight?estimateHeight(line):1;if(estHeight!=line.height)updateLineHeight(line,estHeight);}
|
786 |
-
function cleanUpLine(line){line.parent=null;detachMarkedSpans(line);}
|
787 |
-
function extractLineClasses(type,output){if(type)for(;;){var lineClass=type.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!lineClass)break;type=type.slice(0,lineClass.index)+type.slice(lineClass.index+lineClass[0].length);var prop=lineClass[1]?"bgClass":"textClass";if(output[prop]==null)
|
788 |
-
output[prop]=lineClass[2];else if(!(new RegExp("(?:^|\s)"+lineClass[2]+"(?:$|\s)")).test(output[prop]))
|
789 |
-
output[prop]+=" "+lineClass[2];}
|
790 |
-
return type;}
|
791 |
-
function callBlankLine(mode,state){if(mode.blankLine)return mode.blankLine(state);if(!mode.innerMode)return;var inner=CodeMirror.innerMode(mode,state);if(inner.mode.blankLine)return inner.mode.blankLine(inner.state);}
|
792 |
-
function readToken(mode,stream,state,inner){for(var i=0;i<10;i++){if(inner)inner[0]=CodeMirror.innerMode(mode,state).mode;var style=mode.token(stream,state);if(stream.pos>stream.start)return style;}
|
793 |
-
throw new Error("Mode "+mode.name+" failed to advance stream.");}
|
794 |
-
function takeToken(cm,pos,precise,asArray){function getObj(copy){return{start:stream.start,end:stream.pos,string:stream.current(),type:style||null,state:copy?copyState(doc.mode,state):state};}
|
795 |
-
var doc=cm.doc,mode=doc.mode,style;pos=clipPos(doc,pos);var line=getLine(doc,pos.line),state=getStateBefore(cm,pos.line,precise);var stream=new StringStream(line.text,cm.options.tabSize),tokens;if(asArray)tokens=[];while((asArray||stream.pos<pos.ch)&&!stream.eol()){stream.start=stream.pos;style=readToken(mode,stream,state);if(asArray)tokens.push(getObj(true));}
|
796 |
-
return asArray?tokens:getObj();}
|
797 |
-
function runMode(cm,text,mode,state,f,lineClasses,forceToEnd){var flattenSpans=mode.flattenSpans;if(flattenSpans==null)flattenSpans=cm.options.flattenSpans;var curStart=0,curStyle=null;var stream=new StringStream(text,cm.options.tabSize),style;var inner=cm.options.addModeClass&&[null];if(text=="")extractLineClasses(callBlankLine(mode,state),lineClasses);while(!stream.eol()){if(stream.pos>cm.options.maxHighlightLength){flattenSpans=false;if(forceToEnd)processLine(cm,text,state,stream.pos);stream.pos=text.length;style=null;}else{style=extractLineClasses(readToken(mode,stream,state,inner),lineClasses);}
|
798 |
-
if(inner){var mName=inner[0].name;if(mName)style="m-"+(style?mName+" "+style:mName);}
|
799 |
-
if(!flattenSpans||curStyle!=style){while(curStart<stream.start){curStart=Math.min(stream.start,curStart+50000);f(curStart,curStyle);}
|
800 |
-
curStyle=style;}
|
801 |
-
stream.start=stream.pos;}
|
802 |
-
while(curStart<stream.pos){var pos=Math.min(stream.pos,curStart+50000);f(pos,curStyle);curStart=pos;}}
|
803 |
-
function highlightLine(cm,line,state,forceToEnd){var st=[cm.state.modeGen],lineClasses={};runMode(cm,line.text,cm.doc.mode,state,function(end,style){st.push(end,style);},lineClasses,forceToEnd);for(var o=0;o<cm.state.overlays.length;++o){var overlay=cm.state.overlays[o],i=1,at=0;runMode(cm,line.text,overlay.mode,true,function(end,style){var start=i;while(at<end){var i_end=st[i];if(i_end>end)
|
804 |
-
st.splice(i,1,end,st[i+1],i_end);i+=2;at=Math.min(end,i_end);}
|
805 |
-
if(!style)return;if(overlay.opaque){st.splice(start,i-start,end,"cm-overlay "+style);i=start+2;}else{for(;start<i;start+=2){var cur=st[start+1];st[start+1]=(cur?cur+" ":"")+"cm-overlay "+style;}}},lineClasses);}
|
806 |
-
return{styles:st,classes:lineClasses.bgClass||lineClasses.textClass?lineClasses:null};}
|
807 |
-
function getLineStyles(cm,line,updateFrontier){if(!line.styles||line.styles[0]!=cm.state.modeGen){var result=highlightLine(cm,line,line.stateAfter=getStateBefore(cm,lineNo(line)));line.styles=result.styles;if(result.classes)line.styleClasses=result.classes;else if(line.styleClasses)line.styleClasses=null;if(updateFrontier===cm.doc.frontier)cm.doc.frontier++;}
|
808 |
-
return line.styles;}
|
809 |
-
function processLine(cm,text,state,startAt){var mode=cm.doc.mode;var stream=new StringStream(text,cm.options.tabSize);stream.start=stream.pos=startAt||0;if(text=="")callBlankLine(mode,state);while(!stream.eol()&&stream.pos<=cm.options.maxHighlightLength){readToken(mode,stream,state);stream.start=stream.pos;}}
|
810 |
-
var styleToClassCache={},styleToClassCacheWithMode={};function interpretTokenStyle(style,options){if(!style||/^\s*$/.test(style))return null;var cache=options.addModeClass?styleToClassCacheWithMode:styleToClassCache;return cache[style]||(cache[style]=style.replace(/\S+/g,"cm-$&"));}
|
811 |
-
function buildLineContent(cm,lineView){var content=elt("span",null,null,webkit?"padding-right: .1px":null);var builder={pre:elt("pre",[content]),content:content,col:0,pos:0,cm:cm,splitSpaces:(ie||webkit)&&cm.getOption("lineWrapping")};lineView.measure={};for(var i=0;i<=(lineView.rest?lineView.rest.length:0);i++){var line=i?lineView.rest[i-1]:lineView.line,order;builder.pos=0;builder.addToken=buildToken;if(hasBadBidiRects(cm.display.measure)&&(order=getOrder(line)))
|
812 |
-
builder.addToken=buildTokenBadBidi(builder.addToken,order);builder.map=[];var allowFrontierUpdate=lineView!=cm.display.externalMeasured&&lineNo(line);insertLineContent(line,builder,getLineStyles(cm,line,allowFrontierUpdate));if(line.styleClasses){if(line.styleClasses.bgClass)
|
813 |
-
builder.bgClass=joinClasses(line.styleClasses.bgClass,builder.bgClass||"");if(line.styleClasses.textClass)
|
814 |
-
builder.textClass=joinClasses(line.styleClasses.textClass,builder.textClass||"");}
|
815 |
-
if(builder.map.length==0)
|
816 |
-
builder.map.push(0,0,builder.content.appendChild(zeroWidthElement(cm.display.measure)));if(i==0){lineView.measure.map=builder.map;lineView.measure.cache={};}else{(lineView.measure.maps||(lineView.measure.maps=[])).push(builder.map);(lineView.measure.caches||(lineView.measure.caches=[])).push({});}}
|
817 |
-
if(webkit&&/\bcm-tab\b/.test(builder.content.lastChild.className))
|
818 |
-
builder.content.className="cm-tab-wrap-hack";signal(cm,"renderLine",cm,lineView.line,builder.pre);if(builder.pre.className)
|
819 |
-
builder.textClass=joinClasses(builder.pre.className,builder.textClass||"");return builder;}
|
820 |
-
function defaultSpecialCharPlaceholder(ch){var token=elt("span","\u2022","cm-invalidchar");token.title="\\u"+ch.charCodeAt(0).toString(16);token.setAttribute("aria-label",token.title);return token;}
|
821 |
-
function buildToken(builder,text,style,startStyle,endStyle,title,css){if(!text)return;var displayText=builder.splitSpaces?text.replace(/ {3,}/g,splitSpaces):text;var special=builder.cm.state.specialChars,mustWrap=false;if(!special.test(text)){builder.col+=text.length;var content=document.createTextNode(displayText);builder.map.push(builder.pos,builder.pos+text.length,content);if(ie&&ie_version<9)mustWrap=true;builder.pos+=text.length;}else{var content=document.createDocumentFragment(),pos=0;while(true){special.lastIndex=pos;var m=special.exec(text);var skipped=m?m.index-pos:text.length-pos;if(skipped){var txt=document.createTextNode(displayText.slice(pos,pos+skipped));if(ie&&ie_version<9)content.appendChild(elt("span",[txt]));else content.appendChild(txt);builder.map.push(builder.pos,builder.pos+skipped,txt);builder.col+=skipped;builder.pos+=skipped;}
|
822 |
-
if(!m)break;pos+=skipped+1;if(m[0]=="\t"){var tabSize=builder.cm.options.tabSize,tabWidth=tabSize-builder.col%tabSize;var txt=content.appendChild(elt("span",spaceStr(tabWidth),"cm-tab"));txt.setAttribute("role","presentation");txt.setAttribute("cm-text","\t");builder.col+=tabWidth;}else{var txt=builder.cm.options.specialCharPlaceholder(m[0]);txt.setAttribute("cm-text",m[0]);if(ie&&ie_version<9)content.appendChild(elt("span",[txt]));else content.appendChild(txt);builder.col+=1;}
|
823 |
-
builder.map.push(builder.pos,builder.pos+1,txt);builder.pos++;}}
|
824 |
-
if(style||startStyle||endStyle||mustWrap||css){var fullStyle=style||"";if(startStyle)fullStyle+=startStyle;if(endStyle)fullStyle+=endStyle;var token=elt("span",[content],fullStyle,css);if(title)token.title=title;return builder.content.appendChild(token);}
|
825 |
-
builder.content.appendChild(content);}
|
826 |
-
function splitSpaces(old){var out=" ";for(var i=0;i<old.length-2;++i)out+=i%2?" ":"\u00a0";out+=" ";return out;}
|
827 |
-
function buildTokenBadBidi(inner,order){return function(builder,text,style,startStyle,endStyle,title,css){style=style?style+" cm-force-border":"cm-force-border";var start=builder.pos,end=start+text.length;for(;;){for(var i=0;i<order.length;i++){var part=order[i];if(part.to>start&&part.from<=start)break;}
|
828 |
-
if(part.to>=end)return inner(builder,text,style,startStyle,endStyle,title,css);inner(builder,text.slice(0,part.to-start),style,startStyle,null,title,css);startStyle=null;text=text.slice(part.to-start);start=part.to;}};}
|
829 |
-
function buildCollapsedSpan(builder,size,marker,ignoreWidget){var widget=!ignoreWidget&&marker.widgetNode;if(widget)builder.map.push(builder.pos,builder.pos+size,widget);if(!ignoreWidget&&builder.cm.display.input.needsContentAttribute){if(!widget)
|
830 |
-
widget=builder.content.appendChild(document.createElement("span"));widget.setAttribute("cm-marker",marker.id);}
|
831 |
-
if(widget){builder.cm.display.input.setUneditable(widget);builder.content.appendChild(widget);}
|
832 |
-
builder.pos+=size;}
|
833 |
-
function insertLineContent(line,builder,styles){var spans=line.markedSpans,allText=line.text,at=0;if(!spans){for(var i=1;i<styles.length;i+=2)
|
834 |
-
builder.addToken(builder,allText.slice(at,at=styles[i]),interpretTokenStyle(styles[i+1],builder.cm.options));return;}
|
835 |
-
var len=allText.length,pos=0,i=1,text="",style,css;var nextChange=0,spanStyle,spanEndStyle,spanStartStyle,title,collapsed;for(;;){if(nextChange==pos){spanStyle=spanEndStyle=spanStartStyle=title=css="";collapsed=null;nextChange=Infinity;var foundBookmarks=[];for(var j=0;j<spans.length;++j){var sp=spans[j],m=sp.marker;if(m.type=="bookmark"&&sp.from==pos&&m.widgetNode){foundBookmarks.push(m);}else if(sp.from<=pos&&(sp.to==null||sp.to>pos||m.collapsed&&sp.to==pos&&sp.from==pos)){if(sp.to!=null&&sp.to!=pos&&nextChange>sp.to){nextChange=sp.to;spanEndStyle="";}
|
836 |
-
if(m.className)spanStyle+=" "+m.className;if(m.css)css=m.css;if(m.startStyle&&sp.from==pos)spanStartStyle+=" "+m.startStyle;if(m.endStyle&&sp.to==nextChange)spanEndStyle+=" "+m.endStyle;if(m.title&&!title)title=m.title;if(m.collapsed&&(!collapsed||compareCollapsedMarkers(collapsed.marker,m)<0))
|
837 |
-
collapsed=sp;}else if(sp.from>pos&&nextChange>sp.from){nextChange=sp.from;}}
|
838 |
-
if(collapsed&&(collapsed.from||0)==pos){buildCollapsedSpan(builder,(collapsed.to==null?len+1:collapsed.to)-pos,collapsed.marker,collapsed.from==null);if(collapsed.to==null)return;if(collapsed.to==pos)collapsed=false;}
|
839 |
-
if(!collapsed&&foundBookmarks.length)for(var j=0;j<foundBookmarks.length;++j)
|
840 |
-
buildCollapsedSpan(builder,0,foundBookmarks[j]);}
|
841 |
-
if(pos>=len)break;var upto=Math.min(len,nextChange);while(true){if(text){var end=pos+text.length;if(!collapsed){var tokenText=end>upto?text.slice(0,upto-pos):text;builder.addToken(builder,tokenText,style?style+spanStyle:spanStyle,spanStartStyle,pos+tokenText.length==nextChange?spanEndStyle:"",title,css);}
|
842 |
-
if(end>=upto){text=text.slice(upto-pos);pos=upto;break;}
|
843 |
-
pos=end;spanStartStyle="";}
|
844 |
-
text=allText.slice(at,at=styles[i++]);style=interpretTokenStyle(styles[i++],builder.cm.options);}}}
|
845 |
-
function isWholeLineUpdate(doc,change){return change.from.ch==0&&change.to.ch==0&&lst(change.text)==""&&(!doc.cm||doc.cm.options.wholeLineUpdateBefore);}
|
846 |
-
function updateDoc(doc,change,markedSpans,estimateHeight){function spansFor(n){return markedSpans?markedSpans[n]:null;}
|
847 |
-
function update(line,text,spans){updateLine(line,text,spans,estimateHeight);signalLater(line,"change",line,change);}
|
848 |
-
function linesFor(start,end){for(var i=start,result=[];i<end;++i)
|
849 |
-
result.push(new Line(text[i],spansFor(i),estimateHeight));return result;}
|
850 |
-
var from=change.from,to=change.to,text=change.text;var firstLine=getLine(doc,from.line),lastLine=getLine(doc,to.line);var lastText=lst(text),lastSpans=spansFor(text.length-1),nlines=to.line-from.line;if(change.full){doc.insert(0,linesFor(0,text.length));doc.remove(text.length,doc.size-text.length);}else if(isWholeLineUpdate(doc,change)){var added=linesFor(0,text.length-1);update(lastLine,lastLine.text,lastSpans);if(nlines)doc.remove(from.line,nlines);if(added.length)doc.insert(from.line,added);}else if(firstLine==lastLine){if(text.length==1){update(firstLine,firstLine.text.slice(0,from.ch)+lastText+firstLine.text.slice(to.ch),lastSpans);}else{var added=linesFor(1,text.length-1);added.push(new Line(lastText+firstLine.text.slice(to.ch),lastSpans,estimateHeight));update(firstLine,firstLine.text.slice(0,from.ch)+text[0],spansFor(0));doc.insert(from.line+1,added);}}else if(text.length==1){update(firstLine,firstLine.text.slice(0,from.ch)+text[0]+lastLine.text.slice(to.ch),spansFor(0));doc.remove(from.line+1,nlines);}else{update(firstLine,firstLine.text.slice(0,from.ch)+text[0],spansFor(0));update(lastLine,lastText+lastLine.text.slice(to.ch),lastSpans);var added=linesFor(1,text.length-1);if(nlines>1)doc.remove(from.line+1,nlines-1);doc.insert(from.line+1,added);}
|
851 |
-
signalLater(doc,"change",doc,change);}
|
852 |
-
function LeafChunk(lines){this.lines=lines;this.parent=null;for(var i=0,height=0;i<lines.length;++i){lines[i].parent=this;height+=lines[i].height;}
|
853 |
-
this.height=height;}
|
854 |
-
LeafChunk.prototype={chunkSize:function(){return this.lines.length;},removeInner:function(at,n){for(var i=at,e=at+n;i<e;++i){var line=this.lines[i];this.height-=line.height;cleanUpLine(line);signalLater(line,"delete");}
|
855 |
-
this.lines.splice(at,n);},collapse:function(lines){lines.push.apply(lines,this.lines);},insertInner:function(at,lines,height){this.height+=height;this.lines=this.lines.slice(0,at).concat(lines).concat(this.lines.slice(at));for(var i=0;i<lines.length;++i)lines[i].parent=this;},iterN:function(at,n,op){for(var e=at+n;at<e;++at)
|
856 |
-
if(op(this.lines[at]))return true;}};function BranchChunk(children){this.children=children;var size=0,height=0;for(var i=0;i<children.length;++i){var ch=children[i];size+=ch.chunkSize();height+=ch.height;ch.parent=this;}
|
857 |
-
this.size=size;this.height=height;this.parent=null;}
|
858 |
-
BranchChunk.prototype={chunkSize:function(){return this.size;},removeInner:function(at,n){this.size-=n;for(var i=0;i<this.children.length;++i){var child=this.children[i],sz=child.chunkSize();if(at<sz){var rm=Math.min(n,sz-at),oldHeight=child.height;child.removeInner(at,rm);this.height-=oldHeight-child.height;if(sz==rm){this.children.splice(i--,1);child.parent=null;}
|
859 |
-
if((n-=rm)==0)break;at=0;}else at-=sz;}
|
860 |
-
if(this.size-n<25&&(this.children.length>1||!(this.children[0]instanceof LeafChunk))){var lines=[];this.collapse(lines);this.children=[new LeafChunk(lines)];this.children[0].parent=this;}},collapse:function(lines){for(var i=0;i<this.children.length;++i)this.children[i].collapse(lines);},insertInner:function(at,lines,height){this.size+=lines.length;this.height+=height;for(var i=0;i<this.children.length;++i){var child=this.children[i],sz=child.chunkSize();if(at<=sz){child.insertInner(at,lines,height);if(child.lines&&child.lines.length>50){while(child.lines.length>50){var spilled=child.lines.splice(child.lines.length-25,25);var newleaf=new LeafChunk(spilled);child.height-=newleaf.height;this.children.splice(i+1,0,newleaf);newleaf.parent=this;}
|
861 |
-
this.maybeSpill();}
|
862 |
-
break;}
|
863 |
-
at-=sz;}},maybeSpill:function(){if(this.children.length<=10)return;var me=this;do{var spilled=me.children.splice(me.children.length-5,5);var sibling=new BranchChunk(spilled);if(!me.parent){var copy=new BranchChunk(me.children);copy.parent=me;me.children=[copy,sibling];me=copy;}else{me.size-=sibling.size;me.height-=sibling.height;var myIndex=indexOf(me.parent.children,me);me.parent.children.splice(myIndex+1,0,sibling);}
|
864 |
-
sibling.parent=me.parent;}while(me.children.length>10);me.parent.maybeSpill();},iterN:function(at,n,op){for(var i=0;i<this.children.length;++i){var child=this.children[i],sz=child.chunkSize();if(at<sz){var used=Math.min(n,sz-at);if(child.iterN(at,used,op))return true;if((n-=used)==0)break;at=0;}else at-=sz;}}};var nextDocId=0;var Doc=CodeMirror.Doc=function(text,mode,firstLine){if(!(this instanceof Doc))return new Doc(text,mode,firstLine);if(firstLine==null)firstLine=0;BranchChunk.call(this,[new LeafChunk([new Line("",null)])]);this.first=firstLine;this.scrollTop=this.scrollLeft=0;this.cantEdit=false;this.cleanGeneration=1;this.frontier=firstLine;var start=Pos(firstLine,0);this.sel=simpleSelection(start);this.history=new History(null);this.id=++nextDocId;this.modeOption=mode;if(typeof text=="string")text=splitLines(text);updateDoc(this,{from:start,to:start,text:text});setSelection(this,simpleSelection(start),sel_dontScroll);};Doc.prototype=createObj(BranchChunk.prototype,{constructor:Doc,iter:function(from,to,op){if(op)this.iterN(from-this.first,to-from,op);else this.iterN(this.first,this.first+this.size,from);},insert:function(at,lines){var height=0;for(var i=0;i<lines.length;++i)height+=lines[i].height;this.insertInner(at-this.first,lines,height);},remove:function(at,n){this.removeInner(at-this.first,n);},getValue:function(lineSep){var lines=getLines(this,this.first,this.first+this.size);if(lineSep===false)return lines;return lines.join(lineSep||"\n");},setValue:docMethodOp(function(code){var top=Pos(this.first,0),last=this.first+this.size-1;makeChange(this,{from:top,to:Pos(last,getLine(this,last).text.length),text:splitLines(code),origin:"setValue",full:true},true);setSelection(this,simpleSelection(top));}),replaceRange:function(code,from,to,origin){from=clipPos(this,from);to=to?clipPos(this,to):from;replaceRange(this,code,from,to,origin);},getRange:function(from,to,lineSep){var lines=getBetween(this,clipPos(this,from),clipPos(this,to));if(lineSep===false)return lines;return lines.join(lineSep||"\n");},getLine:function(line){var l=this.getLineHandle(line);return l&&l.text;},getLineHandle:function(line){if(isLine(this,line))return getLine(this,line);},getLineNumber:function(line){return lineNo(line);},getLineHandleVisualStart:function(line){if(typeof line=="number")line=getLine(this,line);return visualLine(line);},lineCount:function(){return this.size;},firstLine:function(){return this.first;},lastLine:function(){return this.first+this.size-1;},clipPos:function(pos){return clipPos(this,pos);},getCursor:function(start){var range=this.sel.primary(),pos;if(start==null||start=="head")pos=range.head;else if(start=="anchor")pos=range.anchor;else if(start=="end"||start=="to"||start===false)pos=range.to();else pos=range.from();return pos;},listSelections:function(){return this.sel.ranges;},somethingSelected:function(){return this.sel.somethingSelected();},setCursor:docMethodOp(function(line,ch,options){setSimpleSelection(this,clipPos(this,typeof line=="number"?Pos(line,ch||0):line),null,options);}),setSelection:docMethodOp(function(anchor,head,options){setSimpleSelection(this,clipPos(this,anchor),clipPos(this,head||anchor),options);}),extendSelection:docMethodOp(function(head,other,options){extendSelection(this,clipPos(this,head),other&&clipPos(this,other),options);}),extendSelections:docMethodOp(function(heads,options){extendSelections(this,clipPosArray(this,heads,options));}),extendSelectionsBy:docMethodOp(function(f,options){extendSelections(this,map(this.sel.ranges,f),options);}),setSelections:docMethodOp(function(ranges,primary,options){if(!ranges.length)return;for(var i=0,out=[];i<ranges.length;i++)
|
865 |
-
out[i]=new Range(clipPos(this,ranges[i].anchor),clipPos(this,ranges[i].head));if(primary==null)primary=Math.min(ranges.length-1,this.sel.primIndex);setSelection(this,normalizeSelection(out,primary),options);}),addSelection:docMethodOp(function(anchor,head,options){var ranges=this.sel.ranges.slice(0);ranges.push(new Range(clipPos(this,anchor),clipPos(this,head||anchor)));setSelection(this,normalizeSelection(ranges,ranges.length-1),options);}),getSelection:function(lineSep){var ranges=this.sel.ranges,lines;for(var i=0;i<ranges.length;i++){var sel=getBetween(this,ranges[i].from(),ranges[i].to());lines=lines?lines.concat(sel):sel;}
|
866 |
-
if(lineSep===false)return lines;else return lines.join(lineSep||"\n");},getSelections:function(lineSep){var parts=[],ranges=this.sel.ranges;for(var i=0;i<ranges.length;i++){var sel=getBetween(this,ranges[i].from(),ranges[i].to());if(lineSep!==false)sel=sel.join(lineSep||"\n");parts[i]=sel;}
|
867 |
-
return parts;},replaceSelection:function(code,collapse,origin){var dup=[];for(var i=0;i<this.sel.ranges.length;i++)
|
868 |
-
dup[i]=code;this.replaceSelections(dup,collapse,origin||"+input");},replaceSelections:docMethodOp(function(code,collapse,origin){var changes=[],sel=this.sel;for(var i=0;i<sel.ranges.length;i++){var range=sel.ranges[i];changes[i]={from:range.from(),to:range.to(),text:splitLines(code[i]),origin:origin};}
|
869 |
-
var newSel=collapse&&collapse!="end"&&computeReplacedSel(this,changes,collapse);for(var i=changes.length-1;i>=0;i--)
|
870 |
-
makeChange(this,changes[i]);if(newSel)setSelectionReplaceHistory(this,newSel);else if(this.cm)ensureCursorVisible(this.cm);}),undo:docMethodOp(function(){makeChangeFromHistory(this,"undo");}),redo:docMethodOp(function(){makeChangeFromHistory(this,"redo");}),undoSelection:docMethodOp(function(){makeChangeFromHistory(this,"undo",true);}),redoSelection:docMethodOp(function(){makeChangeFromHistory(this,"redo",true);}),setExtending:function(val){this.extend=val;},getExtending:function(){return this.extend;},historySize:function(){var hist=this.history,done=0,undone=0;for(var i=0;i<hist.done.length;i++)if(!hist.done[i].ranges)++done;for(var i=0;i<hist.undone.length;i++)if(!hist.undone[i].ranges)++undone;return{undo:done,redo:undone};},clearHistory:function(){this.history=new History(this.history.maxGeneration);},markClean:function(){this.cleanGeneration=this.changeGeneration(true);},changeGeneration:function(forceSplit){if(forceSplit)
|
871 |
-
this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null;return this.history.generation;},isClean:function(gen){return this.history.generation==(gen||this.cleanGeneration);},getHistory:function(){return{done:copyHistoryArray(this.history.done),undone:copyHistoryArray(this.history.undone)};},setHistory:function(histData){var hist=this.history=new History(this.history.maxGeneration);hist.done=copyHistoryArray(histData.done.slice(0),null,true);hist.undone=copyHistoryArray(histData.undone.slice(0),null,true);},addLineClass:docMethodOp(function(handle,where,cls){return changeLine(this,handle,where=="gutter"?"gutter":"class",function(line){var prop=where=="text"?"textClass":where=="background"?"bgClass":where=="gutter"?"gutterClass":"wrapClass";if(!line[prop])line[prop]=cls;else if(classTest(cls).test(line[prop]))return false;else line[prop]+=" "+cls;return true;});}),removeLineClass:docMethodOp(function(handle,where,cls){return changeLine(this,handle,where=="gutter"?"gutter":"class",function(line){var prop=where=="text"?"textClass":where=="background"?"bgClass":where=="gutter"?"gutterClass":"wrapClass";var cur=line[prop];if(!cur)return false;else if(cls==null)line[prop]=null;else{var found=cur.match(classTest(cls));if(!found)return false;var end=found.index+found[0].length;line[prop]=cur.slice(0,found.index)+(!found.index||end==cur.length?"":" ")+cur.slice(end)||null;}
|
872 |
-
return true;});}),addLineWidget:docMethodOp(function(handle,node,options){return addLineWidget(this,handle,node,options);}),removeLineWidget:function(widget){widget.clear();},markText:function(from,to,options){return markText(this,clipPos(this,from),clipPos(this,to),options,"range");},setBookmark:function(pos,options){var realOpts={replacedWith:options&&(options.nodeType==null?options.widget:options),insertLeft:options&&options.insertLeft,clearWhenEmpty:false,shared:options&&options.shared,handleMouseEvents:options&&options.handleMouseEvents};pos=clipPos(this,pos);return markText(this,pos,pos,realOpts,"bookmark");},findMarksAt:function(pos){pos=clipPos(this,pos);var markers=[],spans=getLine(this,pos.line).markedSpans;if(spans)for(var i=0;i<spans.length;++i){var span=spans[i];if((span.from==null||span.from<=pos.ch)&&(span.to==null||span.to>=pos.ch))
|
873 |
-
markers.push(span.marker.parent||span.marker);}
|
874 |
-
return markers;},findMarks:function(from,to,filter){from=clipPos(this,from);to=clipPos(this,to);var found=[],lineNo=from.line;this.iter(from.line,to.line+1,function(line){var spans=line.markedSpans;if(spans)for(var i=0;i<spans.length;i++){var span=spans[i];if(!(lineNo==from.line&&from.ch>span.to||span.from==null&&lineNo!=from.line||lineNo==to.line&&span.from>to.ch)&&(!filter||filter(span.marker)))
|
875 |
-
found.push(span.marker.parent||span.marker);}
|
876 |
-
++lineNo;});return found;},getAllMarks:function(){var markers=[];this.iter(function(line){var sps=line.markedSpans;if(sps)for(var i=0;i<sps.length;++i)
|
877 |
-
if(sps[i].from!=null)markers.push(sps[i].marker);});return markers;},posFromIndex:function(off){var ch,lineNo=this.first;this.iter(function(line){var sz=line.text.length+1;if(sz>off){ch=off;return true;}
|
878 |
-
off-=sz;++lineNo;});return clipPos(this,Pos(lineNo,ch));},indexFromPos:function(coords){coords=clipPos(this,coords);var index=coords.ch;if(coords.line<this.first||coords.ch<0)return 0;this.iter(this.first,coords.line,function(line){index+=line.text.length+1;});return index;},copy:function(copyHistory){var doc=new Doc(getLines(this,this.first,this.first+this.size),this.modeOption,this.first);doc.scrollTop=this.scrollTop;doc.scrollLeft=this.scrollLeft;doc.sel=this.sel;doc.extend=false;if(copyHistory){doc.history.undoDepth=this.history.undoDepth;doc.setHistory(this.getHistory());}
|
879 |
-
return doc;},linkedDoc:function(options){if(!options)options={};var from=this.first,to=this.first+this.size;if(options.from!=null&&options.from>from)from=options.from;if(options.to!=null&&options.to<to)to=options.to;var copy=new Doc(getLines(this,from,to),options.mode||this.modeOption,from);if(options.sharedHist)copy.history=this.history;(this.linked||(this.linked=[])).push({doc:copy,sharedHist:options.sharedHist});copy.linked=[{doc:this,isParent:true,sharedHist:options.sharedHist}];copySharedMarkers(copy,findSharedMarkers(this));return copy;},unlinkDoc:function(other){if(other instanceof CodeMirror)other=other.doc;if(this.linked)for(var i=0;i<this.linked.length;++i){var link=this.linked[i];if(link.doc!=other)continue;this.linked.splice(i,1);other.unlinkDoc(this);detachSharedMarkers(findSharedMarkers(this));break;}
|
880 |
-
if(other.history==this.history){var splitIds=[other.id];linkedDocs(other,function(doc){splitIds.push(doc.id);},true);other.history=new History(null);other.history.done=copyHistoryArray(this.history.done,splitIds);other.history.undone=copyHistoryArray(this.history.undone,splitIds);}},iterLinkedDocs:function(f){linkedDocs(this,f);},getMode:function(){return this.mode;},getEditor:function(){return this.cm;}});Doc.prototype.eachLine=Doc.prototype.iter;var dontDelegate="iter insert remove copy getEditor".split(" ");for(var prop in Doc.prototype)if(Doc.prototype.hasOwnProperty(prop)&&indexOf(dontDelegate,prop)<0)
|
881 |
-
CodeMirror.prototype[prop]=(function(method){return function(){return method.apply(this.doc,arguments);};})(Doc.prototype[prop]);eventMixin(Doc);function linkedDocs(doc,f,sharedHistOnly){function propagate(doc,skip,sharedHist){if(doc.linked)for(var i=0;i<doc.linked.length;++i){var rel=doc.linked[i];if(rel.doc==skip)continue;var shared=sharedHist&&rel.sharedHist;if(sharedHistOnly&&!shared)continue;f(rel.doc,shared);propagate(rel.doc,doc,shared);}}
|
882 |
-
propagate(doc,null,true);}
|
883 |
-
function attachDoc(cm,doc){if(doc.cm)throw new Error("This document is already in use.");cm.doc=doc;doc.cm=cm;estimateLineHeights(cm);loadMode(cm);if(!cm.options.lineWrapping)findMaxLine(cm);cm.options.mode=doc.modeOption;regChange(cm);}
|
884 |
-
function getLine(doc,n){n-=doc.first;if(n<0||n>=doc.size)throw new Error("There is no line "+(n+doc.first)+" in the document.");for(var chunk=doc;!chunk.lines;){for(var i=0;;++i){var child=chunk.children[i],sz=child.chunkSize();if(n<sz){chunk=child;break;}
|
885 |
-
n-=sz;}}
|
886 |
-
return chunk.lines[n];}
|
887 |
-
function getBetween(doc,start,end){var out=[],n=start.line;doc.iter(start.line,end.line+1,function(line){var text=line.text;if(n==end.line)text=text.slice(0,end.ch);if(n==start.line)text=text.slice(start.ch);out.push(text);++n;});return out;}
|
888 |
-
function getLines(doc,from,to){var out=[];doc.iter(from,to,function(line){out.push(line.text);});return out;}
|
889 |
-
function updateLineHeight(line,height){var diff=height-line.height;if(diff)for(var n=line;n;n=n.parent)n.height+=diff;}
|
890 |
-
function lineNo(line){if(line.parent==null)return null;var cur=line.parent,no=indexOf(cur.lines,line);for(var chunk=cur.parent;chunk;cur=chunk,chunk=chunk.parent){for(var i=0;;++i){if(chunk.children[i]==cur)break;no+=chunk.children[i].chunkSize();}}
|
891 |
-
return no+cur.first;}
|
892 |
-
function lineAtHeight(chunk,h){var n=chunk.first;outer:do{for(var i=0;i<chunk.children.length;++i){var child=chunk.children[i],ch=child.height;if(h<ch){chunk=child;continue outer;}
|
893 |
-
h-=ch;n+=child.chunkSize();}
|
894 |
-
return n;}while(!chunk.lines);for(var i=0;i<chunk.lines.length;++i){var line=chunk.lines[i],lh=line.height;if(h<lh)break;h-=lh;}
|
895 |
-
return n+i;}
|
896 |
-
function heightAtLine(lineObj){lineObj=visualLine(lineObj);var h=0,chunk=lineObj.parent;for(var i=0;i<chunk.lines.length;++i){var line=chunk.lines[i];if(line==lineObj)break;else h+=line.height;}
|
897 |
-
for(var p=chunk.parent;p;chunk=p,p=chunk.parent){for(var i=0;i<p.children.length;++i){var cur=p.children[i];if(cur==chunk)break;else h+=cur.height;}}
|
898 |
-
return h;}
|
899 |
-
function getOrder(line){var order=line.order;if(order==null)order=line.order=bidiOrdering(line.text);return order;}
|
900 |
-
function History(startGen){this.done=[];this.undone=[];this.undoDepth=Infinity;this.lastModTime=this.lastSelTime=0;this.lastOp=this.lastSelOp=null;this.lastOrigin=this.lastSelOrigin=null;this.generation=this.maxGeneration=startGen||1;}
|
901 |
-
function historyChangeFromChange(doc,change){var histChange={from:copyPos(change.from),to:changeEnd(change),text:getBetween(doc,change.from,change.to)};attachLocalSpans(doc,histChange,change.from.line,change.to.line+1);linkedDocs(doc,function(doc){attachLocalSpans(doc,histChange,change.from.line,change.to.line+1);},true);return histChange;}
|
902 |
-
function clearSelectionEvents(array){while(array.length){var last=lst(array);if(last.ranges)array.pop();else break;}}
|
903 |
-
function lastChangeEvent(hist,force){if(force){clearSelectionEvents(hist.done);return lst(hist.done);}else if(hist.done.length&&!lst(hist.done).ranges){return lst(hist.done);}else if(hist.done.length>1&&!hist.done[hist.done.length-2].ranges){hist.done.pop();return lst(hist.done);}}
|
904 |
-
function addChangeToHistory(doc,change,selAfter,opId){var hist=doc.history;hist.undone.length=0;var time=+new Date,cur;if((hist.lastOp==opId||hist.lastOrigin==change.origin&&change.origin&&((change.origin.charAt(0)=="+"&&doc.cm&&hist.lastModTime>time-doc.cm.options.historyEventDelay)||change.origin.charAt(0)=="*"))&&(cur=lastChangeEvent(hist,hist.lastOp==opId))){var last=lst(cur.changes);if(cmp(change.from,change.to)==0&&cmp(change.from,last.to)==0){last.to=changeEnd(change);}else{cur.changes.push(historyChangeFromChange(doc,change));}}else{var before=lst(hist.done);if(!before||!before.ranges)
|
905 |
-
pushSelectionToHistory(doc.sel,hist.done);cur={changes:[historyChangeFromChange(doc,change)],generation:hist.generation};hist.done.push(cur);while(hist.done.length>hist.undoDepth){hist.done.shift();if(!hist.done[0].ranges)hist.done.shift();}}
|
906 |
-
hist.done.push(selAfter);hist.generation=++hist.maxGeneration;hist.lastModTime=hist.lastSelTime=time;hist.lastOp=hist.lastSelOp=opId;hist.lastOrigin=hist.lastSelOrigin=change.origin;if(!last)signal(doc,"historyAdded");}
|
907 |
-
function selectionEventCanBeMerged(doc,origin,prev,sel){var ch=origin.charAt(0);return ch=="*"||ch=="+"&&prev.ranges.length==sel.ranges.length&&prev.somethingSelected()==sel.somethingSelected()&&new Date-doc.history.lastSelTime<=(doc.cm?doc.cm.options.historyEventDelay:500);}
|
908 |
-
function addSelectionToHistory(doc,sel,opId,options){var hist=doc.history,origin=options&&options.origin;if(opId==hist.lastSelOp||(origin&&hist.lastSelOrigin==origin&&(hist.lastModTime==hist.lastSelTime&&hist.lastOrigin==origin||selectionEventCanBeMerged(doc,origin,lst(hist.done),sel))))
|
909 |
-
hist.done[hist.done.length-1]=sel;else
|
910 |
-
pushSelectionToHistory(sel,hist.done);hist.lastSelTime=+new Date;hist.lastSelOrigin=origin;hist.lastSelOp=opId;if(options&&options.clearRedo!==false)
|
911 |
-
clearSelectionEvents(hist.undone);}
|
912 |
-
function pushSelectionToHistory(sel,dest){var top=lst(dest);if(!(top&&top.ranges&&top.equals(sel)))
|
913 |
-
dest.push(sel);}
|
914 |
-
function attachLocalSpans(doc,change,from,to){var existing=change["spans_"+doc.id],n=0;doc.iter(Math.max(doc.first,from),Math.min(doc.first+doc.size,to),function(line){if(line.markedSpans)
|
915 |
-
(existing||(existing=change["spans_"+doc.id]={}))[n]=line.markedSpans;++n;});}
|
916 |
-
function removeClearedSpans(spans){if(!spans)return null;for(var i=0,out;i<spans.length;++i){if(spans[i].marker.explicitlyCleared){if(!out)out=spans.slice(0,i);}
|
917 |
-
else if(out)out.push(spans[i]);}
|
918 |
-
return!out?spans:out.length?out:null;}
|
919 |
-
function getOldSpans(doc,change){var found=change["spans_"+doc.id];if(!found)return null;for(var i=0,nw=[];i<change.text.length;++i)
|
920 |
-
nw.push(removeClearedSpans(found[i]));return nw;}
|
921 |
-
function copyHistoryArray(events,newGroup,instantiateSel){for(var i=0,copy=[];i<events.length;++i){var event=events[i];if(event.ranges){copy.push(instantiateSel?Selection.prototype.deepCopy.call(event):event);continue;}
|
922 |
-
var changes=event.changes,newChanges=[];copy.push({changes:newChanges});for(var j=0;j<changes.length;++j){var change=changes[j],m;newChanges.push({from:change.from,to:change.to,text:change.text});if(newGroup)for(var prop in change)if(m=prop.match(/^spans_(\d+)$/)){if(indexOf(newGroup,Number(m[1]))>-1){lst(newChanges)[prop]=change[prop];delete change[prop];}}}}
|
923 |
-
return copy;}
|
924 |
-
function rebaseHistSelSingle(pos,from,to,diff){if(to<pos.line){pos.line+=diff;}else if(from<pos.line){pos.line=from;pos.ch=0;}}
|
925 |
-
function rebaseHistArray(array,from,to,diff){for(var i=0;i<array.length;++i){var sub=array[i],ok=true;if(sub.ranges){if(!sub.copied){sub=array[i]=sub.deepCopy();sub.copied=true;}
|
926 |
-
for(var j=0;j<sub.ranges.length;j++){rebaseHistSelSingle(sub.ranges[j].anchor,from,to,diff);rebaseHistSelSingle(sub.ranges[j].head,from,to,diff);}
|
927 |
-
continue;}
|
928 |
-
for(var j=0;j<sub.changes.length;++j){var cur=sub.changes[j];if(to<cur.from.line){cur.from=Pos(cur.from.line+diff,cur.from.ch);cur.to=Pos(cur.to.line+diff,cur.to.ch);}else if(from<=cur.to.line){ok=false;break;}}
|
929 |
-
if(!ok){array.splice(0,i+1);i=0;}}}
|
930 |
-
function rebaseHist(hist,change){var from=change.from.line,to=change.to.line,diff=change.text.length-(to-from)-1;rebaseHistArray(hist.done,from,to,diff);rebaseHistArray(hist.undone,from,to,diff);}
|
931 |
-
var e_preventDefault=CodeMirror.e_preventDefault=function(e){if(e.preventDefault)e.preventDefault();else e.returnValue=false;};var e_stopPropagation=CodeMirror.e_stopPropagation=function(e){if(e.stopPropagation)e.stopPropagation();else e.cancelBubble=true;};function e_defaultPrevented(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==false;}
|
932 |
-
var e_stop=CodeMirror.e_stop=function(e){e_preventDefault(e);e_stopPropagation(e);};function e_target(e){return e.target||e.srcElement;}
|
933 |
-
function e_button(e){var b=e.which;if(b==null){if(e.button&1)b=1;else if(e.button&2)b=3;else if(e.button&4)b=2;}
|
934 |
-
if(mac&&e.ctrlKey&&b==1)b=3;return b;}
|
935 |
-
var on=CodeMirror.on=function(emitter,type,f){if(emitter.addEventListener)
|
936 |
-
emitter.addEventListener(type,f,false);else if(emitter.attachEvent)
|
937 |
-
emitter.attachEvent("on"+type,f);else{var map=emitter._handlers||(emitter._handlers={});var arr=map[type]||(map[type]=[]);arr.push(f);}};var off=CodeMirror.off=function(emitter,type,f){if(emitter.removeEventListener)
|
938 |
-
emitter.removeEventListener(type,f,false);else if(emitter.detachEvent)
|
939 |
-
emitter.detachEvent("on"+type,f);else{var arr=emitter._handlers&&emitter._handlers[type];if(!arr)return;for(var i=0;i<arr.length;++i)
|
940 |
-
if(arr[i]==f){arr.splice(i,1);break;}}};var signal=CodeMirror.signal=function(emitter,type){var arr=emitter._handlers&&emitter._handlers[type];if(!arr)return;var args=Array.prototype.slice.call(arguments,2);for(var i=0;i<arr.length;++i)arr[i].apply(null,args);};var orphanDelayedCallbacks=null;function signalLater(emitter,type){var arr=emitter._handlers&&emitter._handlers[type];if(!arr)return;var args=Array.prototype.slice.call(arguments,2),list;if(operationGroup){list=operationGroup.delayedCallbacks;}else if(orphanDelayedCallbacks){list=orphanDelayedCallbacks;}else{list=orphanDelayedCallbacks=[];setTimeout(fireOrphanDelayed,0);}
|
941 |
-
function bnd(f){return function(){f.apply(null,args);};};for(var i=0;i<arr.length;++i)
|
942 |
-
list.push(bnd(arr[i]));}
|
943 |
-
function fireOrphanDelayed(){var delayed=orphanDelayedCallbacks;orphanDelayedCallbacks=null;for(var i=0;i<delayed.length;++i)delayed[i]();}
|
944 |
-
function signalDOMEvent(cm,e,override){if(typeof e=="string")
|
945 |
-
e={type:e,preventDefault:function(){this.defaultPrevented=true;}};signal(cm,override||e.type,cm,e);return e_defaultPrevented(e)||e.codemirrorIgnore;}
|
946 |
-
function signalCursorActivity(cm){var arr=cm._handlers&&cm._handlers.cursorActivity;if(!arr)return;var set=cm.curOp.cursorActivityHandlers||(cm.curOp.cursorActivityHandlers=[]);for(var i=0;i<arr.length;++i)if(indexOf(set,arr[i])==-1)
|
947 |
-
set.push(arr[i]);}
|
948 |
-
function hasHandler(emitter,type){var arr=emitter._handlers&&emitter._handlers[type];return arr&&arr.length>0;}
|
949 |
-
function eventMixin(ctor){ctor.prototype.on=function(type,f){on(this,type,f);};ctor.prototype.off=function(type,f){off(this,type,f);};}
|
950 |
-
var scrollerGap=30;var Pass=CodeMirror.Pass={toString:function(){return"CodeMirror.Pass";}};var sel_dontScroll={scroll:false},sel_mouse={origin:"*mouse"},sel_move={origin:"+move"};function Delayed(){this.id=null;}
|
951 |
-
Delayed.prototype.set=function(ms,f){clearTimeout(this.id);this.id=setTimeout(f,ms);};var countColumn=CodeMirror.countColumn=function(string,end,tabSize,startIndex,startValue){if(end==null){end=string.search(/[^\s\u00a0]/);if(end==-1)end=string.length;}
|
952 |
-
for(var i=startIndex||0,n=startValue||0;;){var nextTab=string.indexOf("\t",i);if(nextTab<0||nextTab>=end)
|
953 |
-
return n+(end-i);n+=nextTab-i;n+=tabSize-(n%tabSize);i=nextTab+1;}};function findColumn(string,goal,tabSize){for(var pos=0,col=0;;){var nextTab=string.indexOf("\t",pos);if(nextTab==-1)nextTab=string.length;var skipped=nextTab-pos;if(nextTab==string.length||col+skipped>=goal)
|
954 |
-
return pos+Math.min(skipped,goal-col);col+=nextTab-pos;col+=tabSize-(col%tabSize);pos=nextTab+1;if(col>=goal)return pos;}}
|
955 |
-
var spaceStrs=[""];function spaceStr(n){while(spaceStrs.length<=n)
|
956 |
-
spaceStrs.push(lst(spaceStrs)+" ");return spaceStrs[n];}
|
957 |
-
function lst(arr){return arr[arr.length-1];}
|
958 |
-
var selectInput=function(node){node.select();};if(ios)
|
959 |
-
selectInput=function(node){node.selectionStart=0;node.selectionEnd=node.value.length;};else if(ie)
|
960 |
-
selectInput=function(node){try{node.select();}catch(_e){}};function indexOf(array,elt){for(var i=0;i<array.length;++i)
|
961 |
-
if(array[i]==elt)return i;return-1;}
|
962 |
-
function map(array,f){var out=[];for(var i=0;i<array.length;i++)out[i]=f(array[i],i);return out;}
|
963 |
-
function nothing(){}
|
964 |
-
function createObj(base,props){var inst;if(Object.create){inst=Object.create(base);}else{nothing.prototype=base;inst=new nothing();}
|
965 |
-
if(props)copyObj(props,inst);return inst;};function copyObj(obj,target,overwrite){if(!target)target={};for(var prop in obj)
|
966 |
-
if(obj.hasOwnProperty(prop)&&(overwrite!==false||!target.hasOwnProperty(prop)))
|
967 |
-
target[prop]=obj[prop];return target;}
|
968 |
-
function bind(f){var args=Array.prototype.slice.call(arguments,1);return function(){return f.apply(null,args);};}
|
969 |
-
var nonASCIISingleCaseWordChar=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;var isWordCharBasic=CodeMirror.isWordChar=function(ch){return/\w/.test(ch)||ch>"\x80"&&(ch.toUpperCase()!=ch.toLowerCase()||nonASCIISingleCaseWordChar.test(ch));};function isWordChar(ch,helper){if(!helper)return isWordCharBasic(ch);if(helper.source.indexOf("\\w")>-1&&isWordCharBasic(ch))return true;return helper.test(ch);}
|
970 |
-
function isEmpty(obj){for(var n in obj)if(obj.hasOwnProperty(n)&&obj[n])return false;return true;}
|
971 |
-
var extendingChars=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function isExtendingChar(ch){return ch.charCodeAt(0)>=768&&extendingChars.test(ch);}
|
972 |
-
function elt(tag,content,className,style){var e=document.createElement(tag);if(className)e.className=className;if(style)e.style.cssText=style;if(typeof content=="string")e.appendChild(document.createTextNode(content));else if(content)for(var i=0;i<content.length;++i)e.appendChild(content[i]);return e;}
|
973 |
-
var range;if(document.createRange)range=function(node,start,end,endNode){var r=document.createRange();r.setEnd(endNode||node,end);r.setStart(node,start);return r;};else range=function(node,start,end){var r=document.body.createTextRange();try{r.moveToElementText(node.parentNode);}
|
974 |
-
catch(e){return r;}
|
975 |
-
r.collapse(true);r.moveEnd("character",end);r.moveStart("character",start);return r;};function removeChildren(e){for(var count=e.childNodes.length;count>0;--count)
|
976 |
-
e.removeChild(e.firstChild);return e;}
|
977 |
-
function removeChildrenAndAdd(parent,e){return removeChildren(parent).appendChild(e);}
|
978 |
-
var contains=CodeMirror.contains=function(parent,child){if(child.nodeType==3)
|
979 |
-
child=child.parentNode;if(parent.contains)
|
980 |
-
return parent.contains(child);do{if(child.nodeType==11)child=child.host;if(child==parent)return true;}while(child=child.parentNode);};function activeElt(){return document.activeElement;}
|
981 |
-
if(ie&&ie_version<11)activeElt=function(){try{return document.activeElement;}
|
982 |
-
catch(e){return document.body;}};function classTest(cls){return new RegExp("(^|\\s)"+cls+"(?:$|\\s)\\s*");}
|
983 |
-
var rmClass=CodeMirror.rmClass=function(node,cls){var current=node.className;var match=classTest(cls).exec(current);if(match){var after=current.slice(match.index+match[0].length);node.className=current.slice(0,match.index)+(after?match[1]+after:"");}};var addClass=CodeMirror.addClass=function(node,cls){var current=node.className;if(!classTest(cls).test(current))node.className+=(current?" ":"")+cls;};function joinClasses(a,b){var as=a.split(" ");for(var i=0;i<as.length;i++)
|
984 |
-
if(as[i]&&!classTest(as[i]).test(b))b+=" "+as[i];return b;}
|
985 |
-
function forEachCodeMirror(f){if(!document.body.getElementsByClassName)return;var byClass=document.body.getElementsByClassName("CodeMirror");for(var i=0;i<byClass.length;i++){var cm=byClass[i].CodeMirror;if(cm)f(cm);}}
|
986 |
-
var globalsRegistered=false;function ensureGlobalHandlers(){if(globalsRegistered)return;registerGlobalHandlers();globalsRegistered=true;}
|
987 |
-
function registerGlobalHandlers(){var resizeTimer;on(window,"resize",function(){if(resizeTimer==null)resizeTimer=setTimeout(function(){resizeTimer=null;forEachCodeMirror(onResize);},100);});on(window,"blur",function(){forEachCodeMirror(onBlur);});}
|
988 |
-
var dragAndDrop=function(){if(ie&&ie_version<9)return false;var div=elt('div');return"draggable"in div||"dragDrop"in div;}();var zwspSupported;function zeroWidthElement(measure){if(zwspSupported==null){var test=elt("span","\u200b");removeChildrenAndAdd(measure,elt("span",[test,document.createTextNode("x")]));if(measure.firstChild.offsetHeight!=0)
|
989 |
-
zwspSupported=test.offsetWidth<=1&&test.offsetHeight>2&&!(ie&&ie_version<8);}
|
990 |
-
var node=zwspSupported?elt("span","\u200b"):elt("span","\u00a0",null,"display: inline-block; width: 1px; margin-right: -1px");node.setAttribute("cm-text","");return node;}
|
991 |
-
var badBidiRects;function hasBadBidiRects(measure){if(badBidiRects!=null)return badBidiRects;var txt=removeChildrenAndAdd(measure,document.createTextNode("A\u062eA"));var r0=range(txt,0,1).getBoundingClientRect();if(!r0||r0.left==r0.right)return false;var r1=range(txt,1,2).getBoundingClientRect();return badBidiRects=(r1.right-r0.right<3);}
|
992 |
-
var splitLines=CodeMirror.splitLines="\n\nb".split(/\n/).length!=3?function(string){var pos=0,result=[],l=string.length;while(pos<=l){var nl=string.indexOf("\n",pos);if(nl==-1)nl=string.length;var line=string.slice(pos,string.charAt(nl-1)=="\r"?nl-1:nl);var rt=line.indexOf("\r");if(rt!=-1){result.push(line.slice(0,rt));pos+=rt+1;}else{result.push(line);pos=nl+1;}}
|
993 |
-
return result;}:function(string){return string.split(/\r\n?|\n/);};var hasSelection=window.getSelection?function(te){try{return te.selectionStart!=te.selectionEnd;}
|
994 |
-
catch(e){return false;}}:function(te){try{var range=te.ownerDocument.selection.createRange();}
|
995 |
-
catch(e){}
|
996 |
-
if(!range||range.parentElement()!=te)return false;return range.compareEndPoints("StartToEnd",range)!=0;};var hasCopyEvent=(function(){var e=elt("div");if("oncopy"in e)return true;e.setAttribute("oncopy","return;");return typeof e.oncopy=="function";})();var badZoomedRects=null;function hasBadZoomedRects(measure){if(badZoomedRects!=null)return badZoomedRects;var node=removeChildrenAndAdd(measure,elt("span","x"));var normal=node.getBoundingClientRect();var fromRange=range(node,0,1).getBoundingClientRect();return badZoomedRects=Math.abs(normal.left-fromRange.left)>1;}
|
997 |
-
var keyNames={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};CodeMirror.keyNames=keyNames;(function(){for(var i=0;i<10;i++)keyNames[i+48]=keyNames[i+96]=String(i);for(var i=65;i<=90;i++)keyNames[i]=String.fromCharCode(i);for(var i=1;i<=12;i++)keyNames[i+111]=keyNames[i+63235]="F"+i;})();function iterateBidiSections(order,from,to,f){if(!order)return f(from,to,"ltr");var found=false;for(var i=0;i<order.length;++i){var part=order[i];if(part.from<to&&part.to>from||from==to&&part.to==from){f(Math.max(part.from,from),Math.min(part.to,to),part.level==1?"rtl":"ltr");found=true;}}
|
998 |
-
if(!found)f(from,to,"ltr");}
|
999 |
-
function bidiLeft(part){return part.level%2?part.to:part.from;}
|
1000 |
-
function bidiRight(part){return part.level%2?part.from:part.to;}
|
1001 |
-
function lineLeft(line){var order=getOrder(line);return order?bidiLeft(order[0]):0;}
|
1002 |
-
function lineRight(line){var order=getOrder(line);if(!order)return line.text.length;return bidiRight(lst(order));}
|
1003 |
-
function lineStart(cm,lineN){var line=getLine(cm.doc,lineN);var visual=visualLine(line);if(visual!=line)lineN=lineNo(visual);var order=getOrder(visual);var ch=!order?0:order[0].level%2?lineRight(visual):lineLeft(visual);return Pos(lineN,ch);}
|
1004 |
-
function lineEnd(cm,lineN){var merged,line=getLine(cm.doc,lineN);while(merged=collapsedSpanAtEnd(line)){line=merged.find(1,true).line;lineN=null;}
|
1005 |
-
var order=getOrder(line);var ch=!order?line.text.length:order[0].level%2?lineLeft(line):lineRight(line);return Pos(lineN==null?lineNo(line):lineN,ch);}
|
1006 |
-
function lineStartSmart(cm,pos){var start=lineStart(cm,pos.line);var line=getLine(cm.doc,start.line);var order=getOrder(line);if(!order||order[0].level==0){var firstNonWS=Math.max(0,line.text.search(/\S/));var inWS=pos.line==start.line&&pos.ch<=firstNonWS&&pos.ch;return Pos(start.line,inWS?0:firstNonWS);}
|
1007 |
-
return start;}
|
1008 |
-
function compareBidiLevel(order,a,b){var linedir=order[0].level;if(a==linedir)return true;if(b==linedir)return false;return a<b;}
|
1009 |
-
var bidiOther;function getBidiPartAt(order,pos){bidiOther=null;for(var i=0,found;i<order.length;++i){var cur=order[i];if(cur.from<pos&&cur.to>pos)return i;if((cur.from==pos||cur.to==pos)){if(found==null){found=i;}else if(compareBidiLevel(order,cur.level,order[found].level)){if(cur.from!=cur.to)bidiOther=found;return i;}else{if(cur.from!=cur.to)bidiOther=i;return found;}}}
|
1010 |
-
return found;}
|
1011 |
-
function moveInLine(line,pos,dir,byUnit){if(!byUnit)return pos+dir;do pos+=dir;while(pos>0&&isExtendingChar(line.text.charAt(pos)));return pos;}
|
1012 |
-
function moveVisually(line,start,dir,byUnit){var bidi=getOrder(line);if(!bidi)return moveLogically(line,start,dir,byUnit);var pos=getBidiPartAt(bidi,start),part=bidi[pos];var target=moveInLine(line,start,part.level%2?-dir:dir,byUnit);for(;;){if(target>part.from&&target<part.to)return target;if(target==part.from||target==part.to){if(getBidiPartAt(bidi,target)==pos)return target;part=bidi[pos+=dir];return(dir>0)==part.level%2?part.to:part.from;}else{part=bidi[pos+=dir];if(!part)return null;if((dir>0)==part.level%2)
|
1013 |
-
target=moveInLine(line,part.to,-1,byUnit);else
|
1014 |
-
target=moveInLine(line,part.from,1,byUnit);}}}
|
1015 |
-
function moveLogically(line,start,dir,byUnit){var target=start+dir;if(byUnit)while(target>0&&isExtendingChar(line.text.charAt(target)))target+=dir;return target<0||target>line.text.length?null:target;}
|
1016 |
-
var bidiOrdering=(function(){var lowTypes="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";var arabicTypes="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm";function charType(code){if(code<=0xf7)return lowTypes.charAt(code);else if(0x590<=code&&code<=0x5f4)return"R";else if(0x600<=code&&code<=0x6ed)return arabicTypes.charAt(code-0x600);else if(0x6ee<=code&&code<=0x8ac)return"r";else if(0x2000<=code&&code<=0x200b)return"w";else if(code==0x200c)return"b";else return"L";}
|
1017 |
-
var bidiRE=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;var isNeutral=/[stwN]/,isStrong=/[LRr]/,countsAsLeft=/[Lb1n]/,countsAsNum=/[1n]/;var outerType="L";function BidiSpan(level,from,to){this.level=level;this.from=from;this.to=to;}
|
1018 |
-
return function(str){if(!bidiRE.test(str))return false;var len=str.length,types=[];for(var i=0,type;i<len;++i)
|
1019 |
-
types.push(type=charType(str.charCodeAt(i)));for(var i=0,prev=outerType;i<len;++i){var type=types[i];if(type=="m")types[i]=prev;else prev=type;}
|
1020 |
-
for(var i=0,cur=outerType;i<len;++i){var type=types[i];if(type=="1"&&cur=="r")types[i]="n";else if(isStrong.test(type)){cur=type;if(type=="r")types[i]="R";}}
|
1021 |
-
for(var i=1,prev=types[0];i<len-1;++i){var type=types[i];if(type=="+"&&prev=="1"&&types[i+1]=="1")types[i]="1";else if(type==","&&prev==types[i+1]&&(prev=="1"||prev=="n"))types[i]=prev;prev=type;}
|
1022 |
-
for(var i=0;i<len;++i){var type=types[i];if(type==",")types[i]="N";else if(type=="%"){for(var end=i+1;end<len&&types[end]=="%";++end){}
|
1023 |
-
var replace=(i&&types[i-1]=="!")||(end<len&&types[end]=="1")?"1":"N";for(var j=i;j<end;++j)types[j]=replace;i=end-1;}}
|
1024 |
-
for(var i=0,cur=outerType;i<len;++i){var type=types[i];if(cur=="L"&&type=="1")types[i]="L";else if(isStrong.test(type))cur=type;}
|
1025 |
-
for(var i=0;i<len;++i){if(isNeutral.test(types[i])){for(var end=i+1;end<len&&isNeutral.test(types[end]);++end){}
|
1026 |
-
var before=(i?types[i-1]:outerType)=="L";var after=(end<len?types[end]:outerType)=="L";var replace=before||after?"L":"R";for(var j=i;j<end;++j)types[j]=replace;i=end-1;}}
|
1027 |
-
var order=[],m;for(var i=0;i<len;){if(countsAsLeft.test(types[i])){var start=i;for(++i;i<len&&countsAsLeft.test(types[i]);++i){}
|
1028 |
-
order.push(new BidiSpan(0,start,i));}else{var pos=i,at=order.length;for(++i;i<len&&types[i]!="L";++i){}
|
1029 |
-
for(var j=pos;j<i;){if(countsAsNum.test(types[j])){if(pos<j)order.splice(at,0,new BidiSpan(1,pos,j));var nstart=j;for(++j;j<i&&countsAsNum.test(types[j]);++j){}
|
1030 |
-
order.splice(at,0,new BidiSpan(2,nstart,j));pos=j;}else++j;}
|
1031 |
-
if(pos<i)order.splice(at,0,new BidiSpan(1,pos,i));}}
|
1032 |
-
if(order[0].level==1&&(m=str.match(/^\s+/))){order[0].from=m[0].length;order.unshift(new BidiSpan(0,0,m[0].length));}
|
1033 |
-
if(lst(order).level==1&&(m=str.match(/\s+$/))){lst(order).to-=m[0].length;order.push(new BidiSpan(0,len-m[0].length,len));}
|
1034 |
-
if(order[0].level==2)
|
1035 |
-
order.unshift(new BidiSpan(1,order[0].to,order[0].to));if(order[0].level!=lst(order).level)
|
1036 |
-
order.push(new BidiSpan(order[0].level,len,len));return order;};})();CodeMirror.version="5.2.0";return CodeMirror;});
|
1 |
+
!function(e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else{if("function"==typeof define&&define.amd)return define([],e);this.CodeMirror=e()}}(function(){"use strict";function e(r,n){if(!(this instanceof e))return new e(r,n);this.options=n=n?Di(n):{},Di(Xo,n,!1),d(n);var i=n.value;"string"==typeof i&&(i=new vl(i,n.mode)),this.doc=i;var o=new e.inputStyles[n.inputStyle](this),l=this.display=new t(r,i,o);l.wrapper.CodeMirror=this,u(this),s(this),n.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),n.autofocus&&!Co&&l.input.focus(),m(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new Li,keySeq:null,specialChars:null};var a=this;fo&&11>ho&&setTimeout(function(){a.display.input.reset(!0)},20),Rt(this),Ki(),mt(this),this.curOp.forceUpdate=!0,jn(this,i),n.autofocus&&!Co||a.hasFocus()?setTimeout(Hi(fr,this),20):hr(this);for(var c in _o)_o.hasOwnProperty(c)&&_o[c](this,n[c],Yo);C(this),n.finishInit&&n.finishInit(this);for(var f=0;f<Qo.length;++f)Qo[f](this);bt(this),po&&n.lineWrapping&&"optimizelegibility"==getComputedStyle(l.lineDiv).textRendering&&(l.lineDiv.style.textRendering="auto")}function t(e,t,r){var n=this;this.input=r,n.scrollbarFiller=zi("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=zi("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=zi("div",null,"CodeMirror-code"),n.selectionDiv=zi("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=zi("div",null,"CodeMirror-cursors"),n.measure=zi("div",null,"CodeMirror-measure"),n.lineMeasure=zi("div",null,"CodeMirror-measure"),n.lineSpace=zi("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none"),n.mover=zi("div",[zi("div",[n.lineSpace],"CodeMirror-lines")],null,"position: relative"),n.sizer=zi("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=zi("div",null,null,"position: absolute; height: "+Tl+"px; width: 1px;"),n.gutters=zi("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=zi("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=zi("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),fo&&8>ho&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),po||ao&&Co||(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,r.init(n)}function r(t){t.doc.mode=e.getMode(t.options,t.doc.modeOption),n(t)}function n(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,Ee(e,100),e.state.modeGen++,e.curOp&&Dt(e)}function i(e){e.options.lineWrapping?(Ul(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Gl(e.display.wrapper,"CodeMirror-wrap"),h(e)),l(e),Dt(e),it(e),setTimeout(function(){y(e)},100)}function o(e){var t=gt(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/vt(e.display)-3);return function(i){if(mn(e.doc,i))return 0;var o=0;if(i.widgets)for(var l=0;l<i.widgets.length;l++)i.widgets[l].height&&(o+=i.widgets[l].height);return r?o+(Math.ceil(i.text.length/n)||1)*t:o+t}}function l(e){var t=e.doc,r=o(e);t.iter(function(e){var t=r(e);t!=e.height&&$n(e,t)})}function s(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),it(e)}function a(e){u(e),Dt(e),setTimeout(function(){x(e)},20)}function u(e){var t=e.display.gutters,r=e.options.gutters;Fi(t);for(var n=0;n<r.length;++n){var i=r[n],o=t.appendChild(zi("div",null,"CodeMirror-gutter "+i));"CodeMirror-linenumbers"==i&&(e.display.lineGutter=o,o.style.width=(e.display.lineNumWidth||1)+"px")}t.style.display=n?"":"none",c(e)}function c(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function f(e){if(0==e.height)return 0;for(var t,r=e.text.length,n=e;t=cn(n);){var i=t.find(0,!0);n=i.from.line,r+=i.from.ch-i.to.ch}for(n=e;t=fn(n);){var i=t.find(0,!0);r-=n.text.length-i.from.ch,n=i.to.line,r+=n.text.length-i.to.ch}return r}function h(e){var t=e.display,r=e.doc;t.maxLine=Xn(r,r.first),t.maxLineLength=f(t.maxLine),t.maxLineChanged=!0,r.iter(function(e){var r=f(e);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function d(e){var t=Ni(e.gutters,"CodeMirror-linenumbers");-1==t&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function p(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+Ge(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?r:0,docHeight:n,scrollHeight:n+Ve(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}function g(e,t,r){this.cm=r;var n=this.vert=zi("div",[zi("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=zi("div",[zi("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(n),e(i),Cl(n,"scroll",function(){n.clientHeight&&t(n.scrollTop,"vertical")}),Cl(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedOverlay=!1,fo&&8>ho&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function v(){}function m(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&Gl(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new e.scrollbarModel[t.options.scrollbarStyle](function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),Cl(e,"mousedown",function(){t.state.focused&&setTimeout(function(){t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,r){"horizontal"==r?Jt(t,e):Qt(t,e)},t),t.display.scrollbars.addClass&&Ul(t.display.wrapper,t.display.scrollbars.addClass)}function y(e,t){t||(t=p(e));var r=e.display.barWidth,n=e.display.barHeight;b(e,t);for(var i=0;4>i&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&O(e),b(e,p(e)),r=e.display.barWidth,n=e.display.barHeight}function b(e,t){var r=e.display,n=r.scrollbars.update(t);r.sizer.style.paddingRight=(r.barWidth=n.right)+"px",r.sizer.style.paddingBottom=(r.barHeight=n.bottom)+"px",n.right&&n.bottom?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=n.bottom+"px",r.scrollbarFiller.style.width=n.right+"px"):r.scrollbarFiller.style.display="",n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=n.bottom+"px",r.gutterFiller.style.width=t.gutterWidth+"px"):r.gutterFiller.style.display=""}function w(e,t,r){var n=r&&null!=r.top?Math.max(0,r.top):e.scroller.scrollTop;n=Math.floor(n-Be(e));var i=r&&null!=r.bottom?r.bottom:n+e.wrapper.clientHeight,o=Zn(t,n),l=Zn(t,i);if(r&&r.ensure){var s=r.ensure.from.line,a=r.ensure.to.line;o>s?(o=s,l=Zn(t,Qn(Xn(t,s))+e.wrapper.clientHeight)):Math.min(a,t.lastLine())>=l&&(o=Zn(t,Qn(Xn(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function x(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=L(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",l=0;l<r.length;l++)if(!r[l].hidden){e.options.fixedGutter&&r[l].gutter&&(r[l].gutter.style.left=o);var s=r[l].alignable;if(s)for(var a=0;a<s.length;a++)s[a].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=n+i+"px")}}function C(e){if(!e.options.lineNumbers)return!1;var t=e.doc,r=S(e.options,t.first+t.size-1),n=e.display;if(r.length!=n.lineNumChars){var i=n.measure.appendChild(zi("div",[zi("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),o=i.firstChild.offsetWidth,l=i.offsetWidth-o;return n.lineGutter.style.width="",n.lineNumInnerWidth=Math.max(o,n.lineGutter.offsetWidth-l)+1,n.lineNumWidth=n.lineNumInnerWidth+l,n.lineNumChars=n.lineNumInnerWidth?r.length:-1,n.lineGutter.style.width=n.lineNumWidth+"px",c(e),!0}return!1}function S(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function L(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function k(e,t,r){var n=e.display;this.viewport=t,this.visible=w(n,e.doc,t),this.editorIsHidden=!n.wrapper.offsetWidth,this.wrapperHeight=n.wrapper.clientHeight,this.wrapperWidth=n.wrapper.clientWidth,this.oldDisplayWidth=Ke(e),this.force=r,this.dims=H(e),this.events=[]}function T(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Ve(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Ve(e)+"px",t.scrollbarsClipped=!0)}function M(e,t){var r=e.display,n=e.doc;if(t.editorIsHidden)return It(e),!1;if(!t.force&&t.visible.from>=r.viewFrom&&t.visible.to<=r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo)&&r.renderedView==r.view&&0==Ft(e))return!1;C(e)&&(It(e),t.dims=H(e));var i=n.first+n.size,o=Math.max(t.visible.from-e.options.viewportMargin,n.first),l=Math.min(i,t.visible.to+e.options.viewportMargin);r.viewFrom<o&&o-r.viewFrom<20&&(o=Math.max(n.first,r.viewFrom)),r.viewTo>l&&r.viewTo-l<20&&(l=Math.min(i,r.viewTo)),Ao&&(o=gn(e.doc,o),l=vn(e.doc,l));var s=o!=r.viewFrom||l!=r.viewTo||r.lastWrapHeight!=t.wrapperHeight||r.lastWrapWidth!=t.wrapperWidth;zt(e,o,l),r.viewOffset=Qn(Xn(e.doc,r.viewFrom)),e.display.mover.style.top=r.viewOffset+"px";var a=Ft(e);if(!s&&0==a&&!t.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var u=Bi();return a>4&&(r.lineDiv.style.display="none"),I(e,r.updateLineNumbers,t.dims),a>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,u&&Bi()!=u&&u.offsetHeight&&u.focus(),Fi(r.cursorDiv),Fi(r.selectionDiv),r.gutters.style.height=0,s&&(r.lastWrapHeight=t.wrapperHeight,r.lastWrapWidth=t.wrapperWidth,Ee(e,400)),r.updateLineNumbers=null,!0}function N(e,t){for(var r=t.force,n=t.viewport,i=!0;;i=!1){if(i&&e.options.lineWrapping&&t.oldDisplayWidth!=Ke(e))r=!0;else if(r=!1,n&&null!=n.top&&(n={top:Math.min(e.doc.height+Ge(e.display)-je(e),n.top)}),t.visible=w(e.display,e.doc,n),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!M(e,t))break;O(e);var o=p(e);Oe(e),W(e,o),y(e,o)}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function A(e,t){var r=new k(e,t);if(M(e,r)){O(e),N(e,r);var n=p(e);Oe(e),W(e,n),y(e,n),r.finish()}}function W(e,t){e.display.sizer.style.minHeight=t.docHeight+"px";var r=t.docHeight+e.display.barHeight;e.display.heightForcer.style.top=r+"px",e.display.gutters.style.height=Math.max(r+Ve(e),t.clientHeight)+"px"}function O(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n<t.view.length;n++){var i,o=t.view[n];if(!o.hidden){if(fo&&8>ho){var l=o.node.offsetTop+o.node.offsetHeight;i=l-r,r=l}else{var s=o.node.getBoundingClientRect();i=s.bottom-s.top}var a=o.line.height-i;if(2>i&&(i=gt(t)),(a>.001||-.001>a)&&($n(o.line,i),D(o.line),o.rest))for(var u=0;u<o.rest.length;u++)D(o.rest[u])}}}function D(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.offsetHeight}function H(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l)r[e.options.gutters[l]]=o.offsetLeft+o.clientLeft+i,n[e.options.gutters[l]]=o.clientWidth;return{fixedPos:L(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function I(e,t,r){function n(t){var r=t.nextSibling;return po&&So&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var i=e.display,o=e.options.lineNumbers,l=i.lineDiv,s=l.firstChild,a=i.view,u=i.viewFrom,c=0;c<a.length;c++){var f=a[c];if(f.hidden);else if(f.node&&f.node.parentNode==l){for(;s!=f.node;)s=n(s);var h=o&&null!=t&&u>=t&&f.lineNumber;f.changes&&(Ni(f.changes,"gutter")>-1&&(h=!1),P(e,f,u,r)),h&&(Fi(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(S(e.options,u)))),s=f.node.nextSibling}else{var d=V(e,f,u,r);l.insertBefore(d,s)}u+=f.size}for(;s;)s=n(s)}function P(e,t,r,n){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?R(e,t):"gutter"==o?G(e,t,r,n):"class"==o?B(t):"widget"==o&&U(e,t,n)}t.changes=null}function E(e){return e.node==e.text&&(e.node=zi("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),fo&&8>ho&&(e.node.style.zIndex=2)),e.node}function z(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var r=E(e);e.background=r.insertBefore(zi("div",null,t),r.firstChild)}}function F(e,t){var r=e.display.externalMeasured;return r&&r.line==t.line?(e.display.externalMeasured=null,t.measure=r.measure,r.built):Hn(e,t)}function R(e,t){var r=t.text.className,n=F(e,t);t.text==t.node&&(t.node=n.pre),t.text.parentNode.replaceChild(n.pre,t.text),t.text=n.pre,n.bgClass!=t.bgClass||n.textClass!=t.textClass?(t.bgClass=n.bgClass,t.textClass=n.textClass,B(t)):r&&(t.text.className=r)}function B(e){z(e),e.line.wrapClass?E(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function G(e,t,r,n){t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null);var i=t.line.gutterMarkers;if(e.options.lineNumbers||i){var o=E(t),l=t.gutter=zi("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px; width: "+n.gutterTotalWidth+"px");if(e.display.input.setUneditable(l),o.insertBefore(l,t.text),t.line.gutterClass&&(l.className+=" "+t.line.gutterClass),!e.options.lineNumbers||i&&i["CodeMirror-linenumbers"]||(t.lineNumber=l.appendChild(zi("div",S(e.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+n.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),i)for(var s=0;s<e.options.gutters.length;++s){var a=e.options.gutters[s],u=i.hasOwnProperty(a)&&i[a];u&&l.appendChild(zi("div",[u],"CodeMirror-gutter-elt","left: "+n.gutterLeft[a]+"px; width: "+n.gutterWidth[a]+"px"))}}}function U(e,t,r){t.alignable&&(t.alignable=null);for(var n,i=t.node.firstChild;i;i=n){var n=i.nextSibling;"CodeMirror-linewidget"==i.className&&t.node.removeChild(i)}K(e,t,r)}function V(e,t,r,n){var i=F(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),B(t),G(e,t,r,n),K(e,t,n),t.node}function K(e,t,r){if(j(e,t.line,t,r,!0),t.rest)for(var n=0;n<t.rest.length;n++)j(e,t.rest[n],t,r,!1)}function j(e,t,r,n,i){if(t.widgets)for(var o=E(r),l=0,s=t.widgets;l<s.length;++l){var a=s[l],u=zi("div",[a.node],"CodeMirror-linewidget");a.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),X(a,u,r,n),e.display.input.setUneditable(u),i&&a.above?o.insertBefore(u,r.gutter||r.text):o.appendChild(u),yi(a,"redraw")}}function X(e,t,r,n){if(e.noHScroll){(r.alignable||(r.alignable=[])).push(t);var i=n.wrapperWidth;t.style.left=n.fixedPos+"px",e.coverGutter||(i-=n.gutterTotalWidth,t.style.paddingLeft=n.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-n.gutterTotalWidth+"px"))}function _(e){return Wo(e.line,e.ch)}function Y(e,t){return Oo(e,t)<0?t:e}function $(e,t){return Oo(e,t)<0?e:t}function q(e){e.state.focused||(e.display.input.focus(),fr(e))}function Z(e){return e.options.readOnly||e.doc.cantEdit}function Q(e,t,r,n,i){var o=e.doc;e.display.shift=!1,n||(n=o.sel);var l=jl(t),s=null;e.state.pasteIncoming&&n.ranges.length>1&&(Do&&Do.join("\n")==t?s=n.ranges.length%Do.length==0&&Ai(Do,jl):l.length==n.ranges.length&&(s=Ai(l,function(e){return[e]})));for(var a=n.ranges.length-1;a>=0;a--){var u=n.ranges[a],c=u.from(),f=u.to();u.empty()&&(r&&r>0?c=Wo(c.line,c.ch-r):e.state.overwrite&&!e.state.pasteIncoming&&(f=Wo(f.line,Math.min(Xn(o,f.line).text.length,f.ch+Mi(l).length))));var h=e.curOp.updateInput,d={from:c,to:f,text:s?s[a%s.length]:l,origin:i||(e.state.pasteIncoming?"paste":e.state.cutIncoming?"cut":"+input")};if(wr(e.doc,d),yi(e,"inputRead",e,d),t&&!e.state.pasteIncoming&&e.options.electricChars&&e.options.smartIndent&&u.head.ch<100&&(!a||n.ranges[a-1].head.line!=u.head.line)){var p=e.getModeAt(u.head),g=jo(d),v=!1;if(p.electricChars){for(var m=0;m<p.electricChars.length;m++)if(t.indexOf(p.electricChars.charAt(m))>-1){v=Ir(e,g.line,"smart");break}}else p.electricInput&&p.electricInput.test(Xn(o,g.line).text.slice(0,g.ch))&&(v=Ir(e,g.line,"smart"));v&&yi(e,"electricInput",e,g.line)}}Dr(e),e.curOp.updateInput=h,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function J(e){for(var t=[],r=[],n=0;n<e.doc.sel.ranges.length;n++){var i=e.doc.sel.ranges[n].head.line,o={anchor:Wo(i,0),head:Wo(i+1,0)};r.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:r}}function ee(e){e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","off"),e.setAttribute("spellcheck","false")}function te(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new Li,this.inaccurateSelection=!1,this.hasSelection=!1,this.composing=null}function re(){var e=zi("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none"),t=zi("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return po?e.style.width="1000px":e.setAttribute("wrap","off"),xo&&(e.style.border="1px solid black"),ee(e),t}function ne(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Li,this.gracePeriod=!1}function ie(e,t){var r=qe(e,t.line);if(!r||r.hidden)return null;var n=Xn(e.doc,t.line),i=_e(r,n,t.line),o=Jn(n),l="left";if(o){var s=io(o,t.ch);l=s%2?"right":"left"}var a=Je(i.map,t.ch,"left");return a.offset="right"==a.collapse?a.end:a.start,a}function oe(e,t){return t&&(e.bad=!0),e}function le(e,t,r){var n;if(t==e.display.lineDiv){if(n=e.display.lineDiv.childNodes[r],!n)return oe(e.clipPos(Wo(e.display.viewTo-1)),!0);t=null,r=0}else for(n=t;;n=n.parentNode){if(!n||n==e.display.lineDiv)return null;if(n.parentNode&&n.parentNode==e.display.lineDiv)break}for(var i=0;i<e.display.view.length;i++){var o=e.display.view[i];if(o.node==n)return se(o,t,r)}}function se(e,t,r){function n(t,r,n){for(var i=-1;i<(c?c.length:0);i++)for(var o=0>i?u.map:c[i],l=0;l<o.length;l+=3){var s=o[l+2];if(s==t||s==r){var a=qn(0>i?e.line:e.rest[i]),f=o[l]+n;return(0>n||s!=t)&&(f=o[l+(n?1:0)]),Wo(a,f)}}}var i=e.text.firstChild,o=!1;if(!t||!Fl(i,t))return oe(Wo(qn(e.line),0),!0);if(t==i&&(o=!0,t=i.childNodes[r],r=0,!t)){var l=e.rest?Mi(e.rest):e.line;return oe(Wo(qn(l),l.text.length),o)}var s=3==t.nodeType?t:null,a=t;for(s||1!=t.childNodes.length||3!=t.firstChild.nodeType||(s=t.firstChild,r&&(r=s.nodeValue.length));a.parentNode!=i;)a=a.parentNode;var u=e.measure,c=u.maps,f=n(s,a,r);if(f)return oe(f,o);for(var h=a.nextSibling,d=s?s.nodeValue.length-r:0;h;h=h.nextSibling){if(f=n(h,h.firstChild,0))return oe(Wo(f.line,f.ch-d),o);d+=h.textContent.length}for(var p=a.previousSibling,d=r;p;p=p.previousSibling){if(f=n(p,p.firstChild,-1))return oe(Wo(f.line,f.ch+d),o);d+=h.textContent.length}}function ae(e,t,r,n,i){function o(e){return function(t){return t.id==e}}function l(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(null!=r)return""==r&&(r=t.textContent.replace(/\u200b/g,"")),void(s+=r);var u,c=t.getAttribute("cm-marker");if(c){var f=e.findMarks(Wo(n,0),Wo(i+1,0),o(+c));return void(f.length&&(u=f[0].find())&&(s+=_n(e.doc,u.from,u.to).join("\n")))}if("false"==t.getAttribute("contenteditable"))return;for(var h=0;h<t.childNodes.length;h++)l(t.childNodes[h]);/^(pre|div|p)$/i.test(t.nodeName)&&(a=!0)}else if(3==t.nodeType){var d=t.nodeValue;if(!d)return;a&&(s+="\n",a=!1),s+=d}}for(var s="",a=!1;l(t),t!=r;)t=t.nextSibling;return s}function ue(e,t){this.ranges=e,this.primIndex=t}function ce(e,t){this.anchor=e,this.head=t}function fe(e,t){var r=e[t];e.sort(function(e,t){return Oo(e.from(),t.from())}),t=Ni(e,r);for(var n=1;n<e.length;n++){var i=e[n],o=e[n-1];if(Oo(o.to(),i.from())>=0){var l=$(o.from(),i.from()),s=Y(o.to(),i.to()),a=o.empty()?i.from()==i.head:o.from()==o.head;t>=n&&--t,e.splice(--n,2,new ce(a?s:l,a?l:s))}}return new ue(e,t)}function he(e,t){return new ue([new ce(e,t||e)],0)}function de(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function pe(e,t){if(t.line<e.first)return Wo(e.first,0);var r=e.first+e.size-1;return t.line>r?Wo(r,Xn(e,r).text.length):ge(t,Xn(e,t.line).text.length)}function ge(e,t){var r=e.ch;return null==r||r>t?Wo(e.line,t):0>r?Wo(e.line,0):e}function ve(e,t){return t>=e.first&&t<e.first+e.size}function me(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=pe(e,t[n]);return r}function ye(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=Oo(r,i)<0;o!=Oo(n,i)<0?(i=r,r=n):o!=Oo(r,n)<0&&(r=n)}return new ce(i,r)}return new ce(n||r,r)}function be(e,t,r,n){ke(e,new ue([ye(e,e.sel.primary(),t,r)],0),n)}function we(e,t,r){for(var n=[],i=0;i<e.sel.ranges.length;i++)n[i]=ye(e,e.sel.ranges[i],t[i],null);var o=fe(n,e.sel.primIndex);ke(e,o,r)}function xe(e,t,r,n){var i=e.sel.ranges.slice(0);i[t]=r,ke(e,fe(i,e.sel.primIndex),n)}function Ce(e,t,r,n){ke(e,he(t,r),n)}function Se(e,t){var r={ranges:t.ranges,update:function(t){this.ranges=[];for(var r=0;r<t.length;r++)this.ranges[r]=new ce(pe(e,t[r].anchor),pe(e,t[r].head))}};return Ll(e,"beforeSelectionChange",e,r),e.cm&&Ll(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?fe(r.ranges,r.ranges.length-1):t}function Le(e,t,r){var n=e.history.done,i=Mi(n);i&&i.ranges?(n[n.length-1]=t,Te(e,t,r)):ke(e,t,r)}function ke(e,t,r){Te(e,t,r),li(e,e.sel,e.cm?e.cm.curOp.id:NaN,r)}function Te(e,t,r){(Ci(e,"beforeSelectionChange")||e.cm&&Ci(e.cm,"beforeSelectionChange"))&&(t=Se(e,t));var n=r&&r.bias||(Oo(t.primary().head,e.sel.primary().head)<0?-1:1);Me(e,Ae(e,t,n,!0)),r&&r.scroll===!1||!e.cm||Dr(e.cm)}function Me(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,xi(e.cm)),yi(e,"cursorActivity",e))}function Ne(e){Me(e,Ae(e,e.sel,null,!1),Nl)}function Ae(e,t,r,n){for(var i,o=0;o<t.ranges.length;o++){var l=t.ranges[o],s=We(e,l.anchor,r,n),a=We(e,l.head,r,n);(i||s!=l.anchor||a!=l.head)&&(i||(i=t.ranges.slice(0,o)),i[o]=new ce(s,a))}return i?fe(i,t.primIndex):t}function We(e,t,r,n){var i=!1,o=t,l=r||1;e.cantEdit=!1;e:for(;;){var s=Xn(e,o.line);if(s.markedSpans)for(var a=0;a<s.markedSpans.length;++a){var u=s.markedSpans[a],c=u.marker;if((null==u.from||(c.inclusiveLeft?u.from<=o.ch:u.from<o.ch))&&(null==u.to||(c.inclusiveRight?u.to>=o.ch:u.to>o.ch))){if(n&&(Ll(c,"beforeCursorEnter"),c.explicitlyCleared)){if(s.markedSpans){--a;continue}break}if(!c.atomic)continue;var f=c.find(0>l?-1:1);if(0==Oo(f,o)&&(f.ch+=l,f.ch<0?f=f.line>e.first?pe(e,Wo(f.line-1)):null:f.ch>s.text.length&&(f=f.line<e.first+e.size-1?Wo(f.line+1,0):null),!f)){if(i)return n?(e.cantEdit=!0,Wo(e.first,0)):We(e,t,r,!0);i=!0,f=t,l=-l}o=f;continue e}}return o}}function Oe(e){e.display.input.showSelection(e.display.input.prepareSelection())}function De(e,t){for(var r=e.doc,n={},i=n.cursors=document.createDocumentFragment(),o=n.selection=document.createDocumentFragment(),l=0;l<r.sel.ranges.length;l++)if(t!==!1||l!=r.sel.primIndex){var s=r.sel.ranges[l],a=s.empty();(a||e.options.showCursorWhenSelecting)&&He(e,s,i),a||Ie(e,s,o)}return n}function He(e,t,r){var n=ct(e,t.head,"div",null,null,!e.options.singleCursorHeightPerLine),i=r.appendChild(zi("div"," ","CodeMirror-cursor"));if(i.style.left=n.left+"px",i.style.top=n.top+"px",i.style.height=Math.max(0,n.bottom-n.top)*e.options.cursorHeight+"px",n.other){var o=r.appendChild(zi("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=n.other.left+"px",o.style.top=n.other.top+"px",o.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function Ie(e,t,r){function n(e,t,r,n){0>t&&(t=0),t=Math.round(t),n=Math.round(n),s.appendChild(zi("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==r?c-e:r)+"px; height: "+(n-t)+"px"))}function i(t,r,i){function o(r,n){return ut(e,Wo(t,r),"div",f,n)}var s,a,f=Xn(l,t),h=f.text.length;return $i(Jn(f),r||0,null==i?h:i,function(e,t,l){var f,d,p,g=o(e,"left");if(e==t)f=g,d=p=g.left;else{if(f=o(t-1,"right"),"rtl"==l){var v=g;g=f,f=v}d=g.left,p=f.right}null==r&&0==e&&(d=u),f.top-g.top>3&&(n(d,g.top,null,g.bottom),d=u,g.bottom<f.top&&n(d,g.bottom,null,f.top)),null==i&&t==h&&(p=c),(!s||g.top<s.top||g.top==s.top&&g.left<s.left)&&(s=g),(!a||f.bottom>a.bottom||f.bottom==a.bottom&&f.right>a.right)&&(a=f),u+1>d&&(d=u),n(d,f.top,p-d,f.bottom)}),{start:s,end:a}}var o=e.display,l=e.doc,s=document.createDocumentFragment(),a=Ue(e.display),u=a.left,c=Math.max(o.sizerWidth,Ke(e)-o.sizer.offsetLeft)-a.right,f=t.from(),h=t.to();if(f.line==h.line)i(f.line,f.ch,h.ch);else{var d=Xn(l,f.line),p=Xn(l,h.line),g=dn(d)==dn(p),v=i(f.line,f.ch,g?d.text.length+1:null).end,m=i(h.line,g?0:null,h.ch).start;g&&(v.top<m.top-2?(n(v.right,v.top,null,v.bottom),n(u,m.top,m.left,m.bottom)):n(v.right,v.top,m.left-v.right,v.bottom)),v.bottom<m.top&&n(u,v.bottom,null,m.top)}r.appendChild(s)}function Pe(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var r=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Ee(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,Hi(ze,e))}function ze(e){var t=e.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=e.display.viewTo)){var r=+new Date+e.options.workTime,n=el(t.mode,Re(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var l=o.styles,s=An(e,o,n,!0);o.styles=s.styles;var a=o.styleClasses,u=s.classes;u?o.styleClasses=u:a&&(o.styleClasses=null);for(var c=!l||l.length!=o.styles.length||a!=u&&(!a||!u||a.bgClass!=u.bgClass||a.textClass!=u.textClass),f=0;!c&&f<l.length;++f)c=l[f]!=o.styles[f];c&&i.push(t.frontier),o.stateAfter=el(t.mode,n)}else On(e,o.text,n),o.stateAfter=t.frontier%5==0?el(t.mode,n):null;return++t.frontier,+new Date>r?(Ee(e,e.options.workDelay),!0):void 0}),i.length&&Tt(e,function(){for(var t=0;t<i.length;t++)Ht(e,i[t],"text")})}}function Fe(e,t,r){for(var n,i,o=e.doc,l=r?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;s>l;--s){if(s<=o.first)return o.first;var a=Xn(o,s-1);if(a.stateAfter&&(!r||s<=o.frontier))return s;var u=Ol(a.text,null,e.options.tabSize);(null==i||n>u)&&(i=s-1,n=u)}return i}function Re(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=Fe(e,t,r),l=o>n.first&&Xn(n,o-1).stateAfter;return l=l?el(n.mode,l):tl(n.mode),n.iter(o,t,function(r){On(e,r.text,l);var s=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;r.stateAfter=s?el(n.mode,l):null,++o}),r&&(n.frontier=o),l}function Be(e){return e.lineSpace.offsetTop}function Ge(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Ue(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=Ri(e.measure,zi("pre","x")),r=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,n={left:parseInt(r.paddingLeft),right:parseInt(r.paddingRight)};return isNaN(n.left)||isNaN(n.right)||(e.cachedPaddingH=n),n}function Ve(e){return Tl-e.display.nativeBarWidth}function Ke(e){return e.display.scroller.clientWidth-Ve(e)-e.display.barWidth}function je(e){return e.display.scroller.clientHeight-Ve(e)-e.display.barHeight}function Xe(e,t,r){var n=e.options.lineWrapping,i=n&&Ke(e);if(!t.measure.heights||n&&t.measure.width!=i){var o=t.measure.heights=[];if(n){t.measure.width=i;for(var l=t.text.firstChild.getClientRects(),s=0;s<l.length-1;s++){var a=l[s],u=l[s+1];Math.abs(a.bottom-u.bottom)>2&&o.push((a.bottom+u.top)/2-r.top)}}o.push(r.bottom-r.top)}}function _e(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var n=0;n<e.rest.length;n++)if(e.rest[n]==t)return{map:e.measure.maps[n],cache:e.measure.caches[n]};for(var n=0;n<e.rest.length;n++)if(qn(e.rest[n])>r)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Ye(e,t){t=dn(t);var r=qn(t),n=e.display.externalMeasured=new Wt(e.doc,t,r);n.lineN=r;var i=n.built=Hn(e,n);return n.text=i.pre,Ri(e.display.lineMeasure,i.pre),n}function $e(e,t,r,n){return Qe(e,Ze(e,t),r,n)}function qe(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Pt(e,t)];var r=e.display.externalMeasured;return r&&t>=r.lineN&&t<r.lineN+r.size?r:void 0}function Ze(e,t){var r=qn(t),n=qe(e,r);n&&!n.text?n=null:n&&n.changes&&P(e,n,r,H(e)),n||(n=Ye(e,t));var i=_e(n,t,r);return{line:t,view:n,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function Qe(e,t,r,n,i){t.before&&(r=-1);var o,l=r+(n||"");return t.cache.hasOwnProperty(l)?o=t.cache[l]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Xe(e,t.view,t.rect),t.hasHeights=!0),o=et(e,t,r,n),o.bogus||(t.cache[l]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}function Je(e,t,r){for(var n,i,o,l,s=0;s<e.length;s+=3){var a=e[s],u=e[s+1];if(a>t?(i=0,o=1,l="left"):u>t?(i=t-a,o=i+1):(s==e.length-3||t==u&&e[s+3]>t)&&(o=u-a,i=o-1,t>=u&&(l="right")),null!=i){if(n=e[s+2],a==u&&r==(n.insertLeft?"left":"right")&&(l=r),"left"==r&&0==i)for(;s&&e[s-2]==e[s-3]&&e[s-1].insertLeft;)n=e[(s-=3)+2],l="left";if("right"==r&&i==u-a)for(;s<e.length-3&&e[s+3]==e[s+4]&&!e[s+5].insertLeft;)n=e[(s+=3)+2],l="right";break}}return{node:n,start:i,end:o,collapse:l,coverStart:a,coverEnd:u}}function et(e,t,r,n){var i,o=Je(t.map,r,n),l=o.node,s=o.start,a=o.end,u=o.collapse;if(3==l.nodeType){for(var c=0;4>c;c++){for(;s&&Ei(t.line.text.charAt(o.coverStart+s));)--s;for(;o.coverStart+a<o.coverEnd&&Ei(t.line.text.charAt(o.coverStart+a));)++a;if(fo&&9>ho&&0==s&&a==o.coverEnd-o.coverStart)i=l.parentNode.getBoundingClientRect();else if(fo&&e.options.lineWrapping){var f=Il(l,s,a).getClientRects();i=f.length?f["right"==n?f.length-1:0]:Eo}else i=Il(l,s,a).getBoundingClientRect()||Eo;if(i.left||i.right||0==s)break;a=s,s-=1,u="right"}fo&&11>ho&&(i=tt(e.display.measure,i))}else{s>0&&(u=n="right");var f;i=e.options.lineWrapping&&(f=l.getClientRects()).length>1?f["right"==n?f.length-1:0]:l.getBoundingClientRect()}if(fo&&9>ho&&!s&&(!i||!i.left&&!i.right)){var h=l.parentNode.getClientRects()[0];i=h?{left:h.left,right:h.left+vt(e.display),top:h.top,bottom:h.bottom}:Eo}for(var d=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(d+p)/2,v=t.view.measure.heights,c=0;c<v.length-1&&!(g<v[c]);c++);var m=c?v[c-1]:0,y=v[c],b={left:("right"==u?i.right:i.left)-t.rect.left,
|
2 |
+
right:("left"==u?i.left:i.right)-t.rect.left,top:m,bottom:y};return i.left||i.right||(b.bogus=!0),e.options.singleCursorHeightPerLine||(b.rtop=d,b.rbottom=p),b}function tt(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Yi(e))return t;var r=screen.logicalXDPI/screen.deviceXDPI,n=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*r,right:t.right*r,top:t.top*n,bottom:t.bottom*n}}function rt(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function nt(e){e.display.externalMeasure=null,Fi(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)rt(e.display.view[t])}function it(e){nt(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function ot(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function lt(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function st(e,t,r,n){if(t.widgets)for(var i=0;i<t.widgets.length;++i)if(t.widgets[i].above){var o=wn(t.widgets[i]);r.top+=o,r.bottom+=o}if("line"==n)return r;n||(n="local");var l=Qn(t);if("local"==n?l+=Be(e.display):l-=e.display.viewOffset,"page"==n||"window"==n){var s=e.display.lineSpace.getBoundingClientRect();l+=s.top+("window"==n?0:lt());var a=s.left+("window"==n?0:ot());r.left+=a,r.right+=a}return r.top+=l,r.bottom+=l,r}function at(e,t,r){if("div"==r)return t;var n=t.left,i=t.top;if("page"==r)n-=ot(),i-=lt();else if("local"==r||!r){var o=e.display.sizer.getBoundingClientRect();n+=o.left,i+=o.top}var l=e.display.lineSpace.getBoundingClientRect();return{left:n-l.left,top:i-l.top}}function ut(e,t,r,n,i){return n||(n=Xn(e.doc,t.line)),st(e,n,$e(e,n,t.ch,i),r)}function ct(e,t,r,n,i,o){function l(t,l){var s=Qe(e,i,t,l?"right":"left",o);return l?s.left=s.right:s.right=s.left,st(e,n,s,r)}function s(e,t){var r=a[t],n=r.level%2;return e==qi(r)&&t&&r.level<a[t-1].level?(r=a[--t],e=Zi(r)-(r.level%2?0:1),n=!0):e==Zi(r)&&t<a.length-1&&r.level<a[t+1].level&&(r=a[++t],e=qi(r)-r.level%2,n=!1),n&&e==r.to&&e>r.from?l(e-1):l(e,n)}n=n||Xn(e.doc,t.line),i||(i=Ze(e,n));var a=Jn(n),u=t.ch;if(!a)return l(u);var c=io(a,u),f=s(u,c);return null!=ql&&(f.other=s(u,ql)),f}function ft(e,t){var r=0,t=pe(e.doc,t);e.options.lineWrapping||(r=vt(e.display)*t.ch);var n=Xn(e.doc,t.line),i=Qn(n)+Be(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function ht(e,t,r,n){var i=Wo(e,t);return i.xRel=n,r&&(i.outside=!0),i}function dt(e,t,r){var n=e.doc;if(r+=e.display.viewOffset,0>r)return ht(n.first,0,!0,-1);var i=Zn(n,r),o=n.first+n.size-1;if(i>o)return ht(n.first+n.size-1,Xn(n,o).text.length,!0,1);0>t&&(t=0);for(var l=Xn(n,i);;){var s=pt(e,l,i,t,r),a=fn(l),u=a&&a.find(0,!0);if(!a||!(s.ch>u.from.ch||s.ch==u.from.ch&&s.xRel>0))return s;i=qn(l=u.to.line)}}function pt(e,t,r,n,i){function o(n){var i=ct(e,Wo(r,n),"line",t,u);return s=!0,l>i.bottom?i.left-a:l<i.top?i.left+a:(s=!1,i.left)}var l=i-Qn(t),s=!1,a=2*e.display.wrapper.clientWidth,u=Ze(e,t),c=Jn(t),f=t.text.length,h=Qi(t),d=Ji(t),p=o(h),g=s,v=o(d),m=s;if(n>v)return ht(r,d,m,1);for(;;){if(c?d==h||d==lo(t,h,1):1>=d-h){for(var y=p>n||v-n>=n-p?h:d,b=n-(y==h?p:v);Ei(t.text.charAt(y));)++y;var w=ht(r,y,y==h?g:m,-1>b?-1:b>1?1:0);return w}var x=Math.ceil(f/2),C=h+x;if(c){C=h;for(var S=0;x>S;++S)C=lo(t,C,1)}var L=o(C);L>n?(d=C,v=L,(m=s)&&(v+=1e3),f=x):(h=C,p=L,g=s,f-=x)}}function gt(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Ho){Ho=zi("pre");for(var t=0;49>t;++t)Ho.appendChild(document.createTextNode("x")),Ho.appendChild(zi("br"));Ho.appendChild(document.createTextNode("x"))}Ri(e.measure,Ho);var r=Ho.offsetHeight/50;return r>3&&(e.cachedTextHeight=r),Fi(e.measure),r||1}function vt(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=zi("span","xxxxxxxxxx"),r=zi("pre",[t]);Ri(e.measure,r);var n=t.getBoundingClientRect(),i=(n.right-n.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function mt(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Fo},zo?zo.ops.push(e.curOp):e.curOp.ownsGroup=zo={ops:[e.curOp],delayedCallbacks:[]}}function yt(e){var t=e.delayedCallbacks,r=0;do{for(;r<t.length;r++)t[r]();for(var n=0;n<e.ops.length;n++){var i=e.ops[n];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++](i.cm)}}while(r<t.length)}function bt(e){var t=e.curOp,r=t.ownsGroup;if(r)try{yt(r)}finally{zo=null;for(var n=0;n<r.ops.length;n++)r.ops[n].cm.curOp=null;wt(r)}}function wt(e){for(var t=e.ops,r=0;r<t.length;r++)xt(t[r]);for(var r=0;r<t.length;r++)Ct(t[r]);for(var r=0;r<t.length;r++)St(t[r]);for(var r=0;r<t.length;r++)Lt(t[r]);for(var r=0;r<t.length;r++)kt(t[r])}function xt(e){var t=e.cm,r=t.display;T(t),e.updateMaxLine&&h(t),e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<r.viewFrom||e.scrollToPos.to.line>=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new k(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Ct(e){e.updatedDisplay=e.mustUpdate&&M(e.cm,e.update)}function St(e){var t=e.cm,r=t.display;e.updatedDisplay&&O(t),e.barMeasure=p(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=$e(t,r.maxLine,r.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(r.scroller.clientWidth,r.sizer.offsetLeft+e.adjustWidthTo+Ve(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-Ke(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection())}function Lt(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Jt(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1),e.preparedSelection&&t.display.input.showSelection(e.preparedSelection),e.updatedDisplay&&W(t,e.barMeasure),(e.updatedDisplay||e.startHeight!=t.doc.height)&&y(t,e.barMeasure),e.selectionChanged&&Pe(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),e.focus&&e.focus==Bi()&&q(e.cm)}function kt(e){var t=e.cm,r=t.display,n=t.doc;if(e.updatedDisplay&&N(t,e.update),null==r.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(r.wheelStartX=r.wheelStartY=null),null==e.scrollTop||r.scroller.scrollTop==e.scrollTop&&!e.forceScroll||(n.scrollTop=Math.max(0,Math.min(r.scroller.scrollHeight-r.scroller.clientHeight,e.scrollTop)),r.scrollbars.setScrollTop(n.scrollTop),r.scroller.scrollTop=n.scrollTop),null==e.scrollLeft||r.scroller.scrollLeft==e.scrollLeft&&!e.forceScroll||(n.scrollLeft=Math.max(0,Math.min(r.scroller.scrollWidth-Ke(t),e.scrollLeft)),r.scrollbars.setScrollLeft(n.scrollLeft),r.scroller.scrollLeft=n.scrollLeft,x(t)),e.scrollToPos){var i=Nr(t,pe(n,e.scrollToPos.from),pe(n,e.scrollToPos.to),e.scrollToPos.margin);e.scrollToPos.isCursor&&t.state.focused&&Mr(t,i)}var o=e.maybeHiddenMarkers,l=e.maybeUnhiddenMarkers;if(o)for(var s=0;s<o.length;++s)o[s].lines.length||Ll(o[s],"hide");if(l)for(var s=0;s<l.length;++s)l[s].lines.length&&Ll(l[s],"unhide");r.wrapper.offsetHeight&&(n.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Ll(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Tt(e,t){if(e.curOp)return t();mt(e);try{return t()}finally{bt(e)}}function Mt(e,t){return function(){if(e.curOp)return t.apply(e,arguments);mt(e);try{return t.apply(e,arguments)}finally{bt(e)}}}function Nt(e){return function(){if(this.curOp)return e.apply(this,arguments);mt(this);try{return e.apply(this,arguments)}finally{bt(this)}}}function At(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);mt(t);try{return e.apply(this,arguments)}finally{bt(t)}}}function Wt(e,t,r){this.line=t,this.rest=pn(t),this.size=this.rest?qn(Mi(this.rest))-r+1:1,this.node=this.text=null,this.hidden=mn(e,t)}function Ot(e,t,r){for(var n,i=[],o=t;r>o;o=n){var l=new Wt(e.doc,Xn(e.doc,o),o);n=o+l.size,i.push(l)}return i}function Dt(e,t,r,n){null==t&&(t=e.doc.first),null==r&&(r=e.doc.first+e.doc.size),n||(n=0);var i=e.display;if(n&&r<i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Ao&&gn(e.doc,t)<i.viewTo&&It(e);else if(r<=i.viewFrom)Ao&&vn(e.doc,r+n)>i.viewFrom?It(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)It(e);else if(t<=i.viewFrom){var o=Et(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):It(e)}else if(r>=i.viewTo){var o=Et(e,t,t,-1);o?(i.view=i.view.slice(0,o.index),i.viewTo=o.lineN):It(e)}else{var l=Et(e,t,t,-1),s=Et(e,r,r+n,1);l&&s?(i.view=i.view.slice(0,l.index).concat(Ot(e,l.lineN,s.lineN)).concat(i.view.slice(s.index)),i.viewTo+=n):It(e)}var a=i.externalMeasured;a&&(r<a.lineN?a.lineN+=n:t<a.lineN+a.size&&(i.externalMeasured=null))}function Ht(e,t,r){e.curOp.viewChanged=!0;var n=e.display,i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size&&(n.externalMeasured=null),!(t<n.viewFrom||t>=n.viewTo)){var o=n.view[Pt(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);-1==Ni(l,r)&&l.push(r)}}}function It(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Pt(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var r=e.display.view,n=0;n<r.length;n++)if(t-=r[n].size,0>t)return n}function Et(e,t,r,n){var i,o=Pt(e,t),l=e.display.view;if(!Ao||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=0,a=e.display.viewFrom;o>s;s++)a+=l[s].size;if(a!=t){if(n>0){if(o==l.length-1)return null;i=a+l[o].size-t,o++}else i=a-t;t+=i,r+=i}for(;gn(e.doc,r)!=r;){if(o==(0>n?0:l.length-1))return null;r+=n*l[o-(0>n?1:0)].size,o+=n}return{index:o,lineN:r}}function zt(e,t,r){var n=e.display,i=n.view;0==i.length||t>=n.viewTo||r<=n.viewFrom?(n.view=Ot(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=Ot(e,t,n.viewFrom).concat(n.view):n.viewFrom<t&&(n.view=n.view.slice(Pt(e,t))),n.viewFrom=t,n.viewTo<r?n.view=n.view.concat(Ot(e,n.viewTo,r)):n.viewTo>r&&(n.view=n.view.slice(0,Pt(e,r)))),n.viewTo=r}function Ft(e){for(var t=e.display.view,r=0,n=0;n<t.length;n++){var i=t[n];i.hidden||i.node&&!i.changes||++r}return r}function Rt(e){function t(){i.activeTouch&&(o=setTimeout(function(){i.activeTouch=null},1e3),l=i.activeTouch,l.end=+new Date)}function r(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}function n(e,t){if(null==t.left)return!0;var r=t.left-e.left,n=t.top-e.top;return r*r+n*n>400}var i=e.display;Cl(i.scroller,"mousedown",Mt(e,Kt)),fo&&11>ho?Cl(i.scroller,"dblclick",Mt(e,function(t){if(!wi(e,t)){var r=Vt(e,t);if(r&&!$t(e,t)&&!Ut(e.display,t)){bl(t);var n=e.findWordAt(r);be(e.doc,n.anchor,n.head)}}})):Cl(i.scroller,"dblclick",function(t){wi(e,t)||bl(t)}),Mo||Cl(i.scroller,"contextmenu",function(t){dr(e,t)});var o,l={end:0};Cl(i.scroller,"touchstart",function(e){if(!r(e)){clearTimeout(o);var t=+new Date;i.activeTouch={start:t,moved:!1,prev:t-l.end<=300?l:null},1==e.touches.length&&(i.activeTouch.left=e.touches[0].pageX,i.activeTouch.top=e.touches[0].pageY)}}),Cl(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),Cl(i.scroller,"touchend",function(r){var o=i.activeTouch;if(o&&!Ut(i,r)&&null!=o.left&&!o.moved&&new Date-o.start<300){var l,s=e.coordsChar(i.activeTouch,"page");l=!o.prev||n(o,o.prev)?new ce(s,s):!o.prev.prev||n(o,o.prev.prev)?e.findWordAt(s):new ce(Wo(s.line,0),pe(e.doc,Wo(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),bl(r)}t()}),Cl(i.scroller,"touchcancel",t),Cl(i.scroller,"scroll",function(){i.scroller.clientHeight&&(Qt(e,i.scroller.scrollTop),Jt(e,i.scroller.scrollLeft,!0),Ll(e,"scroll",e))}),Cl(i.scroller,"mousewheel",function(t){er(e,t)}),Cl(i.scroller,"DOMMouseScroll",function(t){er(e,t)}),Cl(i.wrapper,"scroll",function(){i.wrapper.scrollTop=i.wrapper.scrollLeft=0}),i.dragFunctions={simple:function(t){wi(e,t)||xl(t)},start:function(t){Zt(e,t)},drop:Mt(e,qt)};var s=i.input.getField();Cl(s,"keyup",function(t){ar.call(e,t)}),Cl(s,"keydown",Mt(e,lr)),Cl(s,"keypress",Mt(e,ur)),Cl(s,"focus",Hi(fr,e)),Cl(s,"blur",Hi(hr,e))}function Bt(t,r,n){var i=n&&n!=e.Init;if(!r!=!i){var o=t.display.dragFunctions,l=r?Cl:Sl;l(t.display.scroller,"dragstart",o.start),l(t.display.scroller,"dragenter",o.simple),l(t.display.scroller,"dragover",o.simple),l(t.display.scroller,"drop",o.drop)}}function Gt(e){var t=e.display;(t.lastWrapHeight!=t.wrapper.clientHeight||t.lastWrapWidth!=t.wrapper.clientWidth)&&(t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize())}function Ut(e,t){for(var r=vi(t);r!=e.wrapper;r=r.parentNode)if(!r||1==r.nodeType&&"true"==r.getAttribute("cm-ignore-events")||r.parentNode==e.sizer&&r!=e.mover)return!0}function Vt(e,t,r,n){var i=e.display;if(!r&&"true"==vi(t).getAttribute("cm-not-content"))return null;var o,l,s=i.lineSpace.getBoundingClientRect();try{o=t.clientX-s.left,l=t.clientY-s.top}catch(t){return null}var a,u=dt(e,o,l);if(n&&1==u.xRel&&(a=Xn(e.doc,u.line).text).length==u.ch){var c=Ol(a,a.length,e.options.tabSize)-a.length;u=Wo(u.line,Math.max(0,Math.round((o-Ue(e.display).left)/vt(e.display))-c))}return u}function Kt(e){var t=this,r=t.display;if(!(r.activeTouch&&r.input.supportsTouch()||wi(t,e))){if(r.shift=e.shiftKey,Ut(r,e))return void(po||(r.scroller.draggable=!1,setTimeout(function(){r.scroller.draggable=!0},100)));if(!$t(t,e)){var n=Vt(t,e);switch(window.focus(),mi(e)){case 1:n?jt(t,e,n):vi(e)==r.scroller&&bl(e);break;case 2:po&&(t.state.lastMiddleDown=+new Date),n&&be(t.doc,n),setTimeout(function(){r.input.focus()},20),bl(e);break;case 3:Mo?dr(t,e):cr(t)}}}}function jt(e,t,r){fo?setTimeout(Hi(q,e),0):e.curOp.focus=Bi();var n,i=+new Date;Po&&Po.time>i-400&&0==Oo(Po.pos,r)?n="triple":Io&&Io.time>i-400&&0==Oo(Io.pos,r)?(n="double",Po={time:i,pos:r}):(n="single",Io={time:i,pos:r});var o,l=e.doc.sel,s=So?t.metaKey:t.ctrlKey;e.options.dragDrop&&Kl&&!Z(e)&&"single"==n&&(o=l.contains(r))>-1&&!l.ranges[o].empty()?Xt(e,t,r,s):_t(e,t,r,n,s)}function Xt(e,t,r,n){var i=e.display,o=+new Date,l=Mt(e,function(s){po&&(i.scroller.draggable=!1),e.state.draggingText=!1,Sl(document,"mouseup",l),Sl(i.scroller,"drop",l),Math.abs(t.clientX-s.clientX)+Math.abs(t.clientY-s.clientY)<10&&(bl(s),!n&&+new Date-200<o&&be(e.doc,r),po||fo&&9==ho?setTimeout(function(){document.body.focus(),i.input.focus()},20):i.input.focus())});po&&(i.scroller.draggable=!0),e.state.draggingText=l,i.scroller.dragDrop&&i.scroller.dragDrop(),Cl(document,"mouseup",l),Cl(i.scroller,"drop",l)}function _t(e,t,r,n,i){function o(t){if(0!=Oo(v,t))if(v=t,"rect"==n){for(var i=[],o=e.options.tabSize,l=Ol(Xn(u,r.line).text,r.ch,o),s=Ol(Xn(u,t.line).text,t.ch,o),a=Math.min(l,s),d=Math.max(l,s),p=Math.min(r.line,t.line),g=Math.min(e.lastLine(),Math.max(r.line,t.line));g>=p;p++){var m=Xn(u,p).text,y=ki(m,a,o);a==d?i.push(new ce(Wo(p,y),Wo(p,y))):m.length>y&&i.push(new ce(Wo(p,y),Wo(p,ki(m,d,o))))}i.length||i.push(new ce(r,r)),ke(u,fe(h.ranges.slice(0,f).concat(i),f),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b=c,w=b.anchor,x=t;if("single"!=n){if("double"==n)var C=e.findWordAt(t);else var C=new ce(Wo(t.line,0),pe(u,Wo(t.line+1,0)));Oo(C.anchor,w)>0?(x=C.head,w=$(b.from(),C.anchor)):(x=C.anchor,w=Y(b.to(),C.head))}var i=h.ranges.slice(0);i[f]=new ce(pe(u,w),x),ke(u,fe(i,f),Al)}}function l(t){var r=++y,i=Vt(e,t,!0,"rect"==n);if(i)if(0!=Oo(i,v)){e.curOp.focus=Bi(),o(i);var s=w(a,u);(i.line>=s.to||i.line<s.from)&&setTimeout(Mt(e,function(){y==r&&l(t)}),150)}else{var c=t.clientY<m.top?-20:t.clientY>m.bottom?20:0;c&&setTimeout(Mt(e,function(){y==r&&(a.scroller.scrollTop+=c,l(t))}),50)}}function s(e){y=1/0,bl(e),a.input.focus(),Sl(document,"mousemove",b),Sl(document,"mouseup",x),u.history.lastSelOrigin=null}var a=e.display,u=e.doc;bl(t);var c,f,h=u.sel,d=h.ranges;if(i&&!t.shiftKey?(f=u.sel.contains(r),c=f>-1?d[f]:new ce(r,r)):(c=u.sel.primary(),f=u.sel.primIndex),t.altKey)n="rect",i||(c=new ce(r,r)),r=Vt(e,t,!0,!0),f=-1;else if("double"==n){var p=e.findWordAt(r);c=e.display.shift||u.extend?ye(u,c,p.anchor,p.head):p}else if("triple"==n){var g=new ce(Wo(r.line,0),pe(u,Wo(r.line+1,0)));c=e.display.shift||u.extend?ye(u,c,g.anchor,g.head):g}else c=ye(u,c,r);i?-1==f?(f=d.length,ke(u,fe(d.concat([c]),f),{scroll:!1,origin:"*mouse"})):d.length>1&&d[f].empty()&&"single"==n&&!t.shiftKey?(ke(u,fe(d.slice(0,f).concat(d.slice(f+1)),0)),h=u.sel):xe(u,f,c,Al):(f=0,ke(u,new ue([c],0),Al),h=u.sel);var v=r,m=a.wrapper.getBoundingClientRect(),y=0,b=Mt(e,function(e){mi(e)?l(e):s(e)}),x=Mt(e,s);Cl(document,"mousemove",b),Cl(document,"mouseup",x)}function Yt(e,t,r,n,i){try{var o=t.clientX,l=t.clientY}catch(t){return!1}if(o>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&bl(t);var s=e.display,a=s.lineDiv.getBoundingClientRect();if(l>a.bottom||!Ci(e,r))return gi(t);l-=a.top-s.viewOffset;for(var u=0;u<e.options.gutters.length;++u){var c=s.gutters.childNodes[u];if(c&&c.getBoundingClientRect().right>=o){var f=Zn(e.doc,l),h=e.options.gutters[u];return i(e,r,e,f,h,t),gi(t)}}}function $t(e,t){return Yt(e,t,"gutterClick",!0,yi)}function qt(e){var t=this;if(!wi(t,e)&&!Ut(t.display,e)){bl(e),fo&&(Ro=+new Date);var r=Vt(t,e,!0),n=e.dataTransfer.files;if(r&&!Z(t))if(n&&n.length&&window.FileReader&&window.File)for(var i=n.length,o=Array(i),l=0,s=function(e,n){var s=new FileReader;s.onload=Mt(t,function(){if(o[n]=s.result,++l==i){r=pe(t.doc,r);var e={from:r,to:r,text:jl(o.join("\n")),origin:"paste"};wr(t.doc,e),Le(t.doc,he(r,jo(e)))}}),s.readAsText(e)},a=0;i>a;++a)s(n[a],a);else{if(t.state.draggingText&&t.doc.sel.contains(r)>-1)return t.state.draggingText(e),void setTimeout(function(){t.display.input.focus()},20);try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&!(So?e.altKey:e.ctrlKey))var u=t.listSelections();if(Te(t.doc,he(r,r)),u)for(var a=0;a<u.length;++a)Tr(t.doc,"",u[a].anchor,u[a].head,"drag");t.replaceSelection(o,"around","paste"),t.display.input.focus()}}catch(e){}}}}function Zt(e,t){if(fo&&(!e.state.draggingText||+new Date-Ro<100))return void xl(t);if(!wi(e,t)&&!Ut(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.setDragImage&&!yo)){var r=zi("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",mo&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),mo&&r.parentNode.removeChild(r)}}function Qt(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,ao||A(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbars.setScrollTop(t),ao&&A(e),Ee(e,100))}function Jt(e,t,r){(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||(t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,x(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function er(e,t){var r=Uo(t),n=r.x,i=r.y,o=e.display,l=o.scroller;if(n&&l.scrollWidth>l.clientWidth||i&&l.scrollHeight>l.clientHeight){if(i&&So&&po)e:for(var s=t.target,a=o.view;s!=l;s=s.parentNode)for(var u=0;u<a.length;u++)if(a[u].node==s){e.display.currentWheelTarget=s;break e}if(n&&!ao&&!mo&&null!=Go)return i&&Qt(e,Math.max(0,Math.min(l.scrollTop+i*Go,l.scrollHeight-l.clientHeight))),Jt(e,Math.max(0,Math.min(l.scrollLeft+n*Go,l.scrollWidth-l.clientWidth))),bl(t),void(o.wheelStartX=null);if(i&&null!=Go){var c=i*Go,f=e.doc.scrollTop,h=f+o.wrapper.clientHeight;0>c?f=Math.max(0,f+c-50):h=Math.min(e.doc.height,h+c+50),A(e,{top:f,bottom:h})}20>Bo&&(null==o.wheelStartX?(o.wheelStartX=l.scrollLeft,o.wheelStartY=l.scrollTop,o.wheelDX=n,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=l.scrollLeft-o.wheelStartX,t=l.scrollTop-o.wheelStartY,r=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,r&&(Go=(Go*Bo+r)/(Bo+1),++Bo)}},200)):(o.wheelDX+=n,o.wheelDY+=i))}}function tr(e,t,r){if("string"==typeof t&&(t=rl[t],!t))return!1;e.display.input.ensurePolled();var n=e.display.shift,i=!1;try{Z(e)&&(e.state.suppressEdits=!0),r&&(e.display.shift=!1),i=t(e)!=Ml}finally{e.display.shift=n,e.state.suppressEdits=!1}return i}function rr(e,t,r){for(var n=0;n<e.state.keyMaps.length;n++){var i=il(t,e.state.keyMaps[n],r,e);if(i)return i}return e.options.extraKeys&&il(t,e.options.extraKeys,r,e)||il(t,e.options.keyMap,r,e)}function nr(e,t,r,n){var i=e.state.keySeq;if(i){if(ol(t))return"handled";Vo.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),t=i+" "+t}var o=rr(e,t,n);return"multi"==o&&(e.state.keySeq=t),"handled"==o&&yi(e,"keyHandled",e,t,r),("handled"==o||"multi"==o)&&(bl(r),Pe(e)),i&&!o&&/\'$/.test(t)?(bl(r),!0):!!o}function ir(e,t){var r=ll(t,!0);return r?t.shiftKey&&!e.state.keySeq?nr(e,"Shift-"+r,t,function(t){return tr(e,t,!0)})||nr(e,r,t,function(t){return("string"==typeof t?/^go[A-Z]/.test(t):t.motion)?tr(e,t):void 0}):nr(e,r,t,function(t){return tr(e,t)}):!1}function or(e,t,r){return nr(e,"'"+r+"'",t,function(t){return tr(e,t,!0)})}function lr(e){var t=this;if(t.curOp.focus=Bi(),!wi(t,e)){fo&&11>ho&&27==e.keyCode&&(e.returnValue=!1);var r=e.keyCode;t.display.shift=16==r||e.shiftKey;var n=ir(t,e);mo&&(Ko=n?r:null,!n&&88==r&&!_l&&(So?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=r||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||sr(t)}}function sr(e){function t(e){18!=e.keyCode&&e.altKey||(Gl(r,"CodeMirror-crosshair"),Sl(document,"keyup",t),Sl(document,"mouseover",t))}var r=e.display.lineDiv;Ul(r,"CodeMirror-crosshair"),Cl(document,"keyup",t),Cl(document,"mouseover",t)}function ar(e){16==e.keyCode&&(this.doc.sel.shift=!1),wi(this,e)}function ur(e){var t=this;if(!(Ut(t.display,e)||wi(t,e)||e.ctrlKey&&!e.altKey||So&&e.metaKey)){var r=e.keyCode,n=e.charCode;if(mo&&r==Ko)return Ko=null,void bl(e);if(!mo||e.which&&!(e.which<10)||!ir(t,e)){var i=String.fromCharCode(null==n?r:n);or(t,e,i)||t.display.input.onKeyPress(e)}}}function cr(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,hr(e))},100)}function fr(e){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Ll(e,"focus",e),e.state.focused=!0,Ul(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),po&&setTimeout(function(){e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Pe(e))}function hr(e){e.state.delayingBlurEvent||(e.state.focused&&(Ll(e,"blur",e),e.state.focused=!1,Gl(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function dr(e,t){Ut(e.display,t)||pr(e,t)||e.display.input.onContextMenu(t)}function pr(e,t){return Ci(e,"gutterContextMenu")?Yt(e,t,"gutterContextMenu",!1,Ll):!1}function gr(e,t){if(Oo(e,t.from)<0)return e;if(Oo(e,t.to)<=0)return jo(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=jo(t).ch-t.to.ch),Wo(r,n)}function vr(e,t){for(var r=[],n=0;n<e.sel.ranges.length;n++){var i=e.sel.ranges[n];r.push(new ce(gr(i.anchor,t),gr(i.head,t)))}return fe(r,e.sel.primIndex)}function mr(e,t,r){return e.line==t.line?Wo(r.line,e.ch-t.ch+r.ch):Wo(r.line+(e.line-t.line),e.ch)}function yr(e,t,r){for(var n=[],i=Wo(e.first,0),o=i,l=0;l<t.length;l++){var s=t[l],a=mr(s.from,i,o),u=mr(jo(s),i,o);if(i=s.to,o=u,"around"==r){var c=e.sel.ranges[l],f=Oo(c.head,c.anchor)<0;n[l]=new ce(f?u:a,f?a:u)}else n[l]=new ce(a,a)}return new ue(n,e.sel.primIndex)}function br(e,t,r){var n={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return r&&(n.update=function(t,r,n,i){t&&(this.from=pe(e,t)),r&&(this.to=pe(e,r)),n&&(this.text=n),void 0!==i&&(this.origin=i)}),Ll(e,"beforeChange",e,n),e.cm&&Ll(e.cm,"beforeChange",e.cm,n),n.canceled?null:{from:n.from,to:n.to,text:n.text,origin:n.origin}}function wr(e,t,r){if(e.cm){if(!e.cm.curOp)return Mt(e.cm,wr)(e,t,r);if(e.cm.state.suppressEdits)return}if(!(Ci(e,"beforeChange")||e.cm&&Ci(e.cm,"beforeChange"))||(t=br(e,t,!0))){var n=No&&!r&&rn(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)xr(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else xr(e,t)}}function xr(e,t){if(1!=t.text.length||""!=t.text[0]||0!=Oo(t.from,t.to)){var r=vr(e,t);ii(e,t,r,e.cm?e.cm.curOp.id:NaN),Lr(e,t,r,Jr(e,t));var n=[];Kn(e,function(e,r){r||-1!=Ni(n,e.history)||(pi(e.history,t),n.push(e.history)),Lr(e,t,null,Jr(e,t))})}}function Cr(e,t,r){if(!e.cm||!e.cm.state.suppressEdits){for(var n,i=e.history,o=e.sel,l="undo"==t?i.done:i.undone,s="undo"==t?i.undone:i.done,a=0;a<l.length&&(n=l[a],r?!n.ranges||n.equals(e.sel):n.ranges);a++);if(a!=l.length){for(i.lastOrigin=i.lastSelOrigin=null;n=l.pop(),n.ranges;){if(si(n,s),r&&!n.equals(e.sel))return void ke(e,n,{clearRedo:!1});o=n}var u=[];si(o,s),s.push({changes:u,generation:i.generation}),i.generation=n.generation||++i.maxGeneration;for(var c=Ci(e,"beforeChange")||e.cm&&Ci(e.cm,"beforeChange"),a=n.changes.length-1;a>=0;--a){var f=n.changes[a];if(f.origin=t,c&&!br(e,f,!1))return void(l.length=0);u.push(ti(e,f));var h=a?vr(e,f):Mi(l);Lr(e,f,h,tn(e,f)),!a&&e.cm&&e.cm.scrollIntoView({from:f.from,to:jo(f)});var d=[];Kn(e,function(e,t){t||-1!=Ni(d,e.history)||(pi(e.history,f),d.push(e.history)),Lr(e,f,null,tn(e,f))})}}}}function Sr(e,t){if(0!=t&&(e.first+=t,e.sel=new ue(Ai(e.sel.ranges,function(e){return new ce(Wo(e.anchor.line+t,e.anchor.ch),Wo(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Dt(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;n<r.viewTo;n++)Ht(e.cm,n,"gutter")}}function Lr(e,t,r,n){if(e.cm&&!e.cm.curOp)return Mt(e.cm,Lr)(e,t,r,n);if(t.to.line<e.first)return void Sr(e,t.text.length-1-(t.to.line-t.from.line));if(!(t.from.line>e.lastLine())){if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);Sr(e,i),t={from:Wo(e.first,0),to:Wo(t.to.line+i,t.to.ch),text:[Mi(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:Wo(o,Xn(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=_n(e,t.from,t.to),r||(r=vr(e,t)),e.cm?kr(e.cm,t,n):Gn(e,t,n),Te(e,r,Nl)}}function kr(e,t,r){var n=e.doc,i=e.display,l=t.from,s=t.to,a=!1,u=l.line;e.options.lineWrapping||(u=qn(dn(Xn(n,l.line))),n.iter(u,s.line+1,function(e){return e==i.maxLine?(a=!0,!0):void 0})),n.sel.contains(t.from,t.to)>-1&&xi(e),Gn(n,t,r,o(e)),e.options.lineWrapping||(n.iter(u,l.line+t.text.length,function(e){var t=f(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,a=!1)}),a&&(e.curOp.updateMaxLine=!0)),n.frontier=Math.min(n.frontier,l.line),Ee(e,400);var c=t.text.length-(s.line-l.line)-1;t.full?Dt(e):l.line!=s.line||1!=t.text.length||Bn(e.doc,t)?Dt(e,l.line,s.line+1,c):Ht(e,l.line,"text");var h=Ci(e,"changes"),d=Ci(e,"change");if(d||h){var p={from:l,to:s,text:t.text,removed:t.removed,origin:t.origin};d&&yi(e,"change",e,p),h&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}e.display.selForContextMenu=null}function Tr(e,t,r,n,i){if(n||(n=r),Oo(n,r)<0){var o=n;n=r,r=o}"string"==typeof t&&(t=jl(t)),wr(e,{from:r,to:n,text:t,origin:i})}function Mr(e,t){if(!wi(e,"scrollCursorIntoView")){var r=e.display,n=r.sizer.getBoundingClientRect(),i=null;if(t.top+n.top<0?i=!0:t.bottom+n.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!wo){var o=zi("div","",null,"position: absolute; top: "+(t.top-r.viewOffset-Be(e.display))+"px; height: "+(t.bottom-t.top+Ve(e)+r.barHeight)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}function Nr(e,t,r,n){null==n&&(n=0);for(var i=0;5>i;i++){var o=!1,l=ct(e,t),s=r&&r!=t?ct(e,r):l,a=Wr(e,Math.min(l.left,s.left),Math.min(l.top,s.top)-n,Math.max(l.left,s.left),Math.max(l.bottom,s.bottom)+n),u=e.doc.scrollTop,c=e.doc.scrollLeft;if(null!=a.scrollTop&&(Qt(e,a.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(o=!0)),null!=a.scrollLeft&&(Jt(e,a.scrollLeft),Math.abs(e.doc.scrollLeft-c)>1&&(o=!0)),!o)break}return l}function Ar(e,t,r,n,i){var o=Wr(e,t,r,n,i);null!=o.scrollTop&&Qt(e,o.scrollTop),null!=o.scrollLeft&&Jt(e,o.scrollLeft)}function Wr(e,t,r,n,i){var o=e.display,l=gt(e.display);0>r&&(r=0);var s=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,a=je(e),u={};i-r>a&&(i=r+a);var c=e.doc.height+Ge(o),f=l>r,h=i>c-l;if(s>r)u.scrollTop=f?0:r;else if(i>s+a){var d=Math.min(r,(h?c:i)-a);d!=s&&(u.scrollTop=d)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,g=Ke(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),v=n-t>g;return v&&(n=t+g),10>t?u.scrollLeft=0:p>t?u.scrollLeft=Math.max(0,t-(v?0:10)):n>g+p-3&&(u.scrollLeft=n+(v?0:10)-g),u}function Or(e,t,r){(null!=t||null!=r)&&Hr(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=r&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+r)}function Dr(e){Hr(e);var t=e.getCursor(),r=t,n=t;e.options.lineWrapping||(r=t.ch?Wo(t.line,t.ch-1):t,n=Wo(t.line,t.ch+1)),e.curOp.scrollToPos={from:r,to:n,margin:e.options.cursorScrollMargin,isCursor:!0}}function Hr(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var r=ft(e,t.from),n=ft(e,t.to),i=Wr(e,Math.min(r.left,n.left),Math.min(r.top,n.top)-t.margin,Math.max(r.right,n.right),Math.max(r.bottom,n.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function Ir(e,t,r,n){var i,o=e.doc;null==r&&(r="add"),"smart"==r&&(o.mode.indent?i=Re(e,t):r="prev");var l=e.options.tabSize,s=Xn(o,t),a=Ol(s.text,null,l);s.stateAfter&&(s.stateAfter=null);var u,c=s.text.match(/^\s*/)[0];if(n||/\S/.test(s.text)){if("smart"==r&&(u=o.mode.indent(i,s.text.slice(c.length),s.text),u==Ml||u>150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?Ol(Xn(o,t-1).text,null,l):0:"add"==r?u=a+e.options.indentUnit:"subtract"==r?u=a-e.options.indentUnit:"number"==typeof r&&(u=a+r),u=Math.max(0,u);var f="",h=0;if(e.options.indentWithTabs)for(var d=Math.floor(u/l);d;--d)h+=l,f+=" ";if(u>h&&(f+=Ti(u-h)),f!=c)return Tr(o,f,Wo(t,0),Wo(t,c.length),"+input"),s.stateAfter=null,!0;for(var d=0;d<o.sel.ranges.length;d++){var p=o.sel.ranges[d];if(p.head.line==t&&p.head.ch<c.length){var h=Wo(t,c.length);xe(o,d,new ce(h,h));break}}}function Pr(e,t,r,n){var i=t,o=t;return"number"==typeof t?o=Xn(e,de(e,t)):i=qn(t),null==i?null:(n(o,i)&&e.cm&&Ht(e.cm,i,r),o)}function Er(e,t){for(var r=e.doc.sel.ranges,n=[],i=0;i<r.length;i++){for(var o=t(r[i]);n.length&&Oo(o.from,Mi(n).to)<=0;){var l=n.pop();if(Oo(l.from,o.from)<0){o.from=l.from;break}}n.push(o)}Tt(e,function(){for(var t=n.length-1;t>=0;t--)Tr(e.doc,"",n[t].from,n[t].to,"+delete");Dr(e)})}function zr(e,t,r,n,i){function o(){var t=s+r;return t<e.first||t>=e.first+e.size?f=!1:(s=t,c=Xn(e,t))}function l(e){var t=(i?lo:so)(c,a,r,!0);if(null==t){if(e||!o())return f=!1;a=i?(0>r?Ji:Qi)(c):0>r?c.text.length:0}else a=t;return!0}var s=t.line,a=t.ch,u=r,c=Xn(e,s),f=!0;if("char"==n)l();else if("column"==n)l(!0);else if("word"==n||"group"==n)for(var h=null,d="group"==n,p=e.cm&&e.cm.getHelper(t,"wordChars"),g=!0;!(0>r)||l(!g);g=!1){var v=c.text.charAt(a)||"\n",m=Ii(v,p)?"w":d&&"\n"==v?"n":!d||/\s/.test(v)?null:"p";if(!d||g||m||(m="s"),h&&h!=m){0>r&&(r=1,l());break}if(m&&(h=m),r>0&&!l(!g))break}var y=We(e,Wo(s,a),u,!0);return f||(y.hitSide=!0),y}function Fr(e,t,r,n){var i,o=e.doc,l=t.left;if("page"==n){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);
|
3 |
+
i=t.top+r*(s-(0>r?1.5:.5)*gt(e.display))}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(;;){var a=dt(e,l,i);if(!a.outside)break;if(0>r?0>=i:i>=o.height){a.hitSide=!0;break}i+=5*r}return a}function Rr(t,r,n,i){e.defaults[t]=r,n&&(_o[t]=i?function(e,t,r){r!=Yo&&n(e,t,r)}:n)}function Br(e){for(var t,r,n,i,o=e.split(/-(?!$)/),e=o[o.length-1],l=0;l<o.length-1;l++){var s=o[l];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))r=!0;else{if(!/^s(hift)$/i.test(s))throw new Error("Unrecognized modifier name: "+s);n=!0}}return t&&(e="Alt-"+e),r&&(e="Ctrl-"+e),i&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Gr(e){return"string"==typeof e?nl[e]:e}function Ur(e,t,r,n,i){if(n&&n.shared)return Vr(e,t,r,n,i);if(e.cm&&!e.cm.curOp)return Mt(e.cm,Ur)(e,t,r,n,i);var o=new ul(e,i),l=Oo(t,r);if(n&&Di(n,o,!1),l>0||0==l&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=zi("span",[o.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(hn(e,t.line,t,r,o)||t.line!=r.line&&hn(e,r.line,t,r,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Ao=!0}o.addToHistory&&ii(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var s,a=t.line,u=e.cm;if(e.iter(a,r.line+1,function(e){u&&o.collapsed&&!u.options.lineWrapping&&dn(e)==u.display.maxLine&&(s=!0),o.collapsed&&a!=t.line&&$n(e,0),qr(e,new _r(o,a==t.line?t.ch:null,a==r.line?r.ch:null)),++a}),o.collapsed&&e.iter(t.line,r.line+1,function(t){mn(e,t)&&$n(t,0)}),o.clearOnEnter&&Cl(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(No=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++al,o.atomic=!0),u){if(s&&(u.curOp.updateMaxLine=!0),o.collapsed)Dt(u,t.line,r.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var c=t.line;c<=r.line;c++)Ht(u,c,"text");o.atomic&&Ne(u.doc),yi(u,"markerAdded",u,o)}return o}function Vr(e,t,r,n,i){n=Di(n),n.shared=!1;var o=[Ur(e,t,r,n,i)],l=o[0],s=n.widgetNode;return Kn(e,function(e){s&&(n.widgetNode=s.cloneNode(!0)),o.push(Ur(e,pe(e,t),pe(e,r),n,i));for(var a=0;a<e.linked.length;++a)if(e.linked[a].isParent)return;l=Mi(o)}),new cl(o,l)}function Kr(e){return e.findMarks(Wo(e.first,0),e.clipPos(Wo(e.lastLine())),function(e){return e.parent})}function jr(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=n.find(),o=e.clipPos(i.from),l=e.clipPos(i.to);if(Oo(o,l)){var s=Ur(e,o,l,n.primary,n.primary.type);n.markers.push(s),s.parent=n}}}function Xr(e){for(var t=0;t<e.length;t++){var r=e[t],n=[r.primary.doc];Kn(r.primary.doc,function(e){n.push(e)});for(var i=0;i<r.markers.length;i++){var o=r.markers[i];-1==Ni(n,o.doc)&&(o.parent=null,r.markers.splice(i--,1))}}}function _r(e,t,r){this.marker=e,this.from=t,this.to=r}function Yr(e,t){if(e)for(var r=0;r<e.length;++r){var n=e[r];if(n.marker==t)return n}}function $r(e,t){for(var r,n=0;n<e.length;++n)e[n]!=t&&(r||(r=[])).push(e[n]);return r}function qr(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function Zr(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,s=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);if(s||o.from==t&&"bookmark"==l.type&&(!r||!o.marker.insertLeft)){var a=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);(n||(n=[])).push(new _r(l,o.from,a?null:o.to))}}return n}function Qr(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,s=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);if(s||o.from==t&&"bookmark"==l.type&&(!r||o.marker.insertLeft)){var a=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);(n||(n=[])).push(new _r(l,a?null:o.from-t,null==o.to?null:o.to-t))}}return n}function Jr(e,t){if(t.full)return null;var r=ve(e,t.from.line)&&Xn(e,t.from.line).markedSpans,n=ve(e,t.to.line)&&Xn(e,t.to.line).markedSpans;if(!r&&!n)return null;var i=t.from.ch,o=t.to.ch,l=0==Oo(t.from,t.to),s=Zr(r,i,l),a=Qr(n,o,l),u=1==t.text.length,c=Mi(t.text).length+(u?i:0);if(s)for(var f=0;f<s.length;++f){var h=s[f];if(null==h.to){var d=Yr(a,h.marker);d?u&&(h.to=null==d.to?null:d.to+c):h.to=i}}if(a)for(var f=0;f<a.length;++f){var h=a[f];if(null!=h.to&&(h.to+=c),null==h.from){var d=Yr(s,h.marker);d||(h.from=c,u&&(s||(s=[])).push(h))}else h.from+=c,u&&(s||(s=[])).push(h)}s&&(s=en(s)),a&&a!=s&&(a=en(a));var p=[s];if(!u){var g,v=t.text.length-2;if(v>0&&s)for(var f=0;f<s.length;++f)null==s[f].to&&(g||(g=[])).push(new _r(s[f].marker,null,null));for(var f=0;v>f;++f)p.push(g);p.push(a)}return p}function en(e){for(var t=0;t<e.length;++t){var r=e[t];null!=r.from&&r.from==r.to&&r.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function tn(e,t){var r=ci(e,t),n=Jr(e,t);if(!r)return n;if(!n)return r;for(var i=0;i<r.length;++i){var o=r[i],l=n[i];if(o&&l)e:for(var s=0;s<l.length;++s){for(var a=l[s],u=0;u<o.length;++u)if(o[u].marker==a.marker)continue e;o.push(a)}else l&&(r[i]=l)}return r}function rn(e,t,r){var n=null;if(e.iter(t.line,r.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var r=e.markedSpans[t].marker;!r.readOnly||n&&-1!=Ni(n,r)||(n||(n=[])).push(r)}}),!n)return null;for(var i=[{from:t,to:r}],o=0;o<n.length;++o)for(var l=n[o],s=l.find(0),a=0;a<i.length;++a){var u=i[a];if(!(Oo(u.to,s.from)<0||Oo(u.from,s.to)>0)){var c=[a,1],f=Oo(u.from,s.from),h=Oo(u.to,s.to);(0>f||!l.inclusiveLeft&&!f)&&c.push({from:u.from,to:s.from}),(h>0||!l.inclusiveRight&&!h)&&c.push({from:s.to,to:u.to}),i.splice.apply(i,c),a+=c.length-1}}return i}function nn(e){var t=e.markedSpans;if(t){for(var r=0;r<t.length;++r)t[r].marker.detachLine(e);e.markedSpans=null}}function on(e,t){if(t){for(var r=0;r<t.length;++r)t[r].marker.attachLine(e);e.markedSpans=t}}function ln(e){return e.inclusiveLeft?-1:0}function sn(e){return e.inclusiveRight?1:0}function an(e,t){var r=e.lines.length-t.lines.length;if(0!=r)return r;var n=e.find(),i=t.find(),o=Oo(n.from,i.from)||ln(e)-ln(t);if(o)return-o;var l=Oo(n.to,i.to)||sn(e)-sn(t);return l?l:t.id-e.id}function un(e,t){var r,n=Ao&&e.markedSpans;if(n)for(var i,o=0;o<n.length;++o)i=n[o],i.marker.collapsed&&null==(t?i.from:i.to)&&(!r||an(r,i.marker)<0)&&(r=i.marker);return r}function cn(e){return un(e,!0)}function fn(e){return un(e,!1)}function hn(e,t,r,n,i){var o=Xn(e,t),l=Ao&&o.markedSpans;if(l)for(var s=0;s<l.length;++s){var a=l[s];if(a.marker.collapsed){var u=a.marker.find(0),c=Oo(u.from,r)||ln(a.marker)-ln(i),f=Oo(u.to,n)||sn(a.marker)-sn(i);if(!(c>=0&&0>=f||0>=c&&f>=0)&&(0>=c&&(Oo(u.to,r)>0||a.marker.inclusiveRight&&i.inclusiveLeft)||c>=0&&(Oo(u.from,n)<0||a.marker.inclusiveLeft&&i.inclusiveRight)))return!0}}}function dn(e){for(var t;t=cn(e);)e=t.find(-1,!0).line;return e}function pn(e){for(var t,r;t=fn(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function gn(e,t){var r=Xn(e,t),n=dn(r);return r==n?t:qn(n)}function vn(e,t){if(t>e.lastLine())return t;var r,n=Xn(e,t);if(!mn(e,n))return t;for(;r=fn(n);)n=r.find(1,!0).line;return qn(n)+1}function mn(e,t){var r=Ao&&t.markedSpans;if(r)for(var n,i=0;i<r.length;++i)if(n=r[i],n.marker.collapsed){if(null==n.from)return!0;if(!n.marker.widgetNode&&0==n.from&&n.marker.inclusiveLeft&&yn(e,t,n))return!0}}function yn(e,t,r){if(null==r.to){var n=r.marker.find(1,!0);return yn(e,n.line,Yr(n.line.markedSpans,r.marker))}if(r.marker.inclusiveRight&&r.to==t.text.length)return!0;for(var i,o=0;o<t.markedSpans.length;++o)if(i=t.markedSpans[o],i.marker.collapsed&&!i.marker.widgetNode&&i.from==r.to&&(null==i.to||i.to!=r.from)&&(i.marker.inclusiveLeft||r.marker.inclusiveRight)&&yn(e,t,i))return!0}function bn(e,t,r){Qn(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Or(e,null,r)}function wn(e){if(null!=e.height)return e.height;var t=e.doc.cm;if(!t)return 0;if(!Fl(document.body,e.node)){var r="position: relative;";e.coverGutter&&(r+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(r+="width: "+t.display.wrapper.clientWidth+"px;"),Ri(t.display.measure,zi("div",[e.node],null,r))}return e.height=e.node.offsetHeight}function xn(e,t,r,n){var i=new fl(e,r,n),o=e.cm;return o&&i.noHScroll&&(o.display.alignWidgets=!0),Pr(e,t,"widget",function(t){var r=t.widgets||(t.widgets=[]);if(null==i.insertAt?r.push(i):r.splice(Math.min(r.length-1,Math.max(0,i.insertAt)),0,i),i.line=t,o&&!mn(e,t)){var n=Qn(t)<e.scrollTop;$n(t,t.height+wn(i)),n&&Or(o,null,i.height),o.curOp.forceUpdate=!0}return!0}),i}function Cn(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),nn(e),on(e,r);var i=n?n(e):1;i!=e.height&&$n(e,i)}function Sn(e){e.parent=null,nn(e)}function Ln(e,t){if(e)for(;;){var r=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!r)break;e=e.slice(0,r.index)+e.slice(r.index+r[0].length);var n=r[1]?"bgClass":"textClass";null==t[n]?t[n]=r[2]:new RegExp("(?:^|s)"+r[2]+"(?:$|s)").test(t[n])||(t[n]+=" "+r[2])}return e}function kn(t,r){if(t.blankLine)return t.blankLine(r);if(t.innerMode){var n=e.innerMode(t,r);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function Tn(t,r,n,i){for(var o=0;10>o;o++){i&&(i[0]=e.innerMode(t,n).mode);var l=t.token(r,n);if(r.pos>r.start)return l}throw new Error("Mode "+t.name+" failed to advance stream.")}function Mn(e,t,r,n){function i(e){return{start:f.start,end:f.pos,string:f.current(),type:o||null,state:e?el(l.mode,c):c}}var o,l=e.doc,s=l.mode;t=pe(l,t);var a,u=Xn(l,t.line),c=Re(e,t.line,r),f=new sl(u.text,e.options.tabSize);for(n&&(a=[]);(n||f.pos<t.ch)&&!f.eol();)f.start=f.pos,o=Tn(s,f,c),n&&a.push(i(!0));return n?a:i()}function Nn(e,t,r,n,i,o,l){var s=r.flattenSpans;null==s&&(s=e.options.flattenSpans);var a,u=0,c=null,f=new sl(t,e.options.tabSize),h=e.options.addModeClass&&[null];for(""==t&&Ln(kn(r,n),o);!f.eol();){if(f.pos>e.options.maxHighlightLength?(s=!1,l&&On(e,t,n,f.pos),f.pos=t.length,a=null):a=Ln(Tn(r,f,n,h),o),h){var d=h[0].name;d&&(a="m-"+(a?d+" "+a:d))}if(!s||c!=a){for(;u<f.start;)u=Math.min(f.start,u+5e4),i(u,c);c=a}f.start=f.pos}for(;u<f.pos;){var p=Math.min(f.pos,u+5e4);i(p,c),u=p}}function An(e,t,r,n){var i=[e.state.modeGen],o={};Nn(e,t.text,e.doc.mode,r,function(e,t){i.push(e,t)},o,n);for(var l=0;l<e.state.overlays.length;++l){var s=e.state.overlays[l],a=1,u=0;Nn(e,t.text,s.mode,!0,function(e,t){for(var r=a;e>u;){var n=i[a];n>e&&i.splice(a,1,e,i[a+1],n),a+=2,u=Math.min(e,n)}if(t)if(s.opaque)i.splice(r,a-r,e,"cm-overlay "+t),a=r+2;else for(;a>r;r+=2){var o=i[r+1];i[r+1]=(o?o+" ":"")+"cm-overlay "+t}},o)}return{styles:i,classes:o.bgClass||o.textClass?o:null}}function Wn(e,t,r){if(!t.styles||t.styles[0]!=e.state.modeGen){var n=An(e,t,t.stateAfter=Re(e,qn(t)));t.styles=n.styles,n.classes?t.styleClasses=n.classes:t.styleClasses&&(t.styleClasses=null),r===e.doc.frontier&&e.doc.frontier++}return t.styles}function On(e,t,r,n){var i=e.doc.mode,o=new sl(t,e.options.tabSize);for(o.start=o.pos=n||0,""==t&&kn(i,r);!o.eol()&&o.pos<=e.options.maxHighlightLength;)Tn(i,o,r),o.start=o.pos}function Dn(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?pl:dl;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function Hn(e,t){var r=zi("span",null,null,po?"padding-right: .1px":null),n={pre:zi("pre",[r]),content:r,col:0,pos:0,cm:e,splitSpaces:(fo||po)&&e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o,l=i?t.rest[i-1]:t.line;n.pos=0,n.addToken=Pn,_i(e.display.measure)&&(o=Jn(l))&&(n.addToken=zn(n.addToken,o)),n.map=[];var s=t!=e.display.externalMeasured&&qn(l);Rn(l,n,Wn(e,l,s)),l.styleClasses&&(l.styleClasses.bgClass&&(n.bgClass=Ui(l.styleClasses.bgClass,n.bgClass||"")),l.styleClasses.textClass&&(n.textClass=Ui(l.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(Xi(e.display.measure))),0==i?(t.measure.map=n.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(n.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return po&&/\bcm-tab\b/.test(n.content.lastChild.className)&&(n.content.className="cm-tab-wrap-hack"),Ll(e,"renderLine",e,t.line,n.pre),n.pre.className&&(n.textClass=Ui(n.pre.className,n.textClass||"")),n}function In(e){var t=zi("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Pn(e,t,r,n,i,o,l){if(t){var s=e.splitSpaces?t.replace(/ {3,}/g,En):t,a=e.cm.state.specialChars,u=!1;if(a.test(t))for(var c=document.createDocumentFragment(),f=0;;){a.lastIndex=f;var h=a.exec(t),d=h?h.index-f:t.length-f;if(d){var p=document.createTextNode(s.slice(f,f+d));fo&&9>ho?c.appendChild(zi("span",[p])):c.appendChild(p),e.map.push(e.pos,e.pos+d,p),e.col+=d,e.pos+=d}if(!h)break;if(f+=d+1," "==h[0]){var g=e.cm.options.tabSize,v=g-e.col%g,p=c.appendChild(zi("span",Ti(v),"cm-tab"));p.setAttribute("role","presentation"),p.setAttribute("cm-text"," "),e.col+=v}else{var p=e.cm.options.specialCharPlaceholder(h[0]);p.setAttribute("cm-text",h[0]),fo&&9>ho?c.appendChild(zi("span",[p])):c.appendChild(p),e.col+=1}e.map.push(e.pos,e.pos+1,p),e.pos++}else{e.col+=t.length;var c=document.createTextNode(s);e.map.push(e.pos,e.pos+t.length,c),fo&&9>ho&&(u=!0),e.pos+=t.length}if(r||n||i||u||l){var m=r||"";n&&(m+=n),i&&(m+=i);var y=zi("span",[c],m,l);return o&&(y.title=o),e.content.appendChild(y)}e.content.appendChild(c)}}function En(e){for(var t=" ",r=0;r<e.length-2;++r)t+=r%2?" ":" ";return t+=" "}function zn(e,t){return function(r,n,i,o,l,s,a){i=i?i+" cm-force-border":"cm-force-border";for(var u=r.pos,c=u+n.length;;){for(var f=0;f<t.length;f++){var h=t[f];if(h.to>u&&h.from<=u)break}if(h.to>=c)return e(r,n,i,o,l,s,a);e(r,n.slice(0,h.to-u),i,o,null,s,a),o=null,n=n.slice(h.to-u),u=h.to}}}function Fn(e,t,r,n){var i=!n&&r.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!n&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",r.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t}function Rn(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var l,s,a,u,c,f,h,d=i.length,p=0,g=1,v="",m=0;;){if(m==p){a=u=c=f=s="",h=null,m=1/0;for(var y=[],b=0;b<n.length;++b){var w=n[b],x=w.marker;"bookmark"==x.type&&w.from==p&&x.widgetNode?y.push(x):w.from<=p&&(null==w.to||w.to>p||x.collapsed&&w.to==p&&w.from==p)?(null!=w.to&&w.to!=p&&m>w.to&&(m=w.to,u=""),x.className&&(a+=" "+x.className),x.css&&(s=x.css),x.startStyle&&w.from==p&&(c+=" "+x.startStyle),x.endStyle&&w.to==m&&(u+=" "+x.endStyle),x.title&&!f&&(f=x.title),x.collapsed&&(!h||an(h.marker,x)<0)&&(h=w)):w.from>p&&m>w.from&&(m=w.from)}if(h&&(h.from||0)==p){if(Fn(t,(null==h.to?d+1:h.to)-p,h.marker,null==h.from),null==h.to)return;h.to==p&&(h=!1)}if(!h&&y.length)for(var b=0;b<y.length;++b)Fn(t,0,y[b])}if(p>=d)break;for(var C=Math.min(d,m);;){if(v){var S=p+v.length;if(!h){var L=S>C?v.slice(0,C-p):v;t.addToken(t,L,l?l+a:a,c,p+L.length==m?u:"",f,s)}if(S>=C){v=v.slice(C-p),p=C;break}p=S,c=""}v=i.slice(o,o=r[g++]),l=Dn(r[g++],t.cm.options)}}else for(var g=1;g<r.length;g+=2)t.addToken(t,i.slice(o,o=r[g]),Dn(r[g+1],t.cm.options))}function Bn(e,t){return 0==t.from.ch&&0==t.to.ch&&""==Mi(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Gn(e,t,r,n){function i(e){return r?r[e]:null}function o(e,r,i){Cn(e,r,i,n),yi(e,"change",e,t)}function l(e,t){for(var r=e,o=[];t>r;++r)o.push(new hl(u[r],i(r),n));return o}var s=t.from,a=t.to,u=t.text,c=Xn(e,s.line),f=Xn(e,a.line),h=Mi(u),d=i(u.length-1),p=a.line-s.line;if(t.full)e.insert(0,l(0,u.length)),e.remove(u.length,e.size-u.length);else if(Bn(e,t)){var g=l(0,u.length-1);o(f,f.text,d),p&&e.remove(s.line,p),g.length&&e.insert(s.line,g)}else if(c==f)if(1==u.length)o(c,c.text.slice(0,s.ch)+h+c.text.slice(a.ch),d);else{var g=l(1,u.length-1);g.push(new hl(h+c.text.slice(a.ch),d,n)),o(c,c.text.slice(0,s.ch)+u[0],i(0)),e.insert(s.line+1,g)}else if(1==u.length)o(c,c.text.slice(0,s.ch)+u[0]+f.text.slice(a.ch),i(0)),e.remove(s.line+1,p);else{o(c,c.text.slice(0,s.ch)+u[0],i(0)),o(f,h+f.text.slice(a.ch),d);var g=l(1,u.length-1);p>1&&e.remove(s.line+1,p-1),e.insert(s.line+1,g)}yi(e,"change",e,t)}function Un(e){this.lines=e,this.parent=null;for(var t=0,r=0;t<e.length;++t)e[t].parent=this,r+=e[t].height;this.height=r}function Vn(e){this.children=e;for(var t=0,r=0,n=0;n<e.length;++n){var i=e[n];t+=i.chunkSize(),r+=i.height,i.parent=this}this.size=t,this.height=r,this.parent=null}function Kn(e,t,r){function n(e,i,o){if(e.linked)for(var l=0;l<e.linked.length;++l){var s=e.linked[l];if(s.doc!=i){var a=o&&s.sharedHist;(!r||a)&&(t(s.doc,a),n(s.doc,e,a))}}}n(e,null,!0)}function jn(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,l(e),r(e),e.options.lineWrapping||h(e),e.options.mode=t.modeOption,Dt(e)}function Xn(e,t){if(t-=e.first,0>t||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var r=e;!r.lines;)for(var n=0;;++n){var i=r.children[n],o=i.chunkSize();if(o>t){r=i;break}t-=o}return r.lines[t]}function _n(e,t,r){var n=[],i=t.line;return e.iter(t.line,r.line+1,function(e){var o=e.text;i==r.line&&(o=o.slice(0,r.ch)),i==t.line&&(o=o.slice(t.ch)),n.push(o),++i}),n}function Yn(e,t,r){var n=[];return e.iter(t,r,function(e){n.push(e.text)}),n}function $n(e,t){var r=t-e.height;if(r)for(var n=e;n;n=n.parent)n.height+=r}function qn(e){if(null==e.parent)return null;for(var t=e.parent,r=Ni(t.lines,e),n=t.parent;n;t=n,n=n.parent)for(var i=0;n.children[i]!=t;++i)r+=n.children[i].chunkSize();return r+t.first}function Zn(e,t){var r=e.first;e:do{for(var n=0;n<e.children.length;++n){var i=e.children[n],o=i.height;if(o>t){e=i;continue e}t-=o,r+=i.chunkSize()}return r}while(!e.lines);for(var n=0;n<e.lines.length;++n){var l=e.lines[n],s=l.height;if(s>t)break;t-=s}return r+n}function Qn(e){e=dn(e);for(var t=0,r=e.parent,n=0;n<r.lines.length;++n){var i=r.lines[n];if(i==e)break;t+=i.height}for(var o=r.parent;o;r=o,o=r.parent)for(var n=0;n<o.children.length;++n){var l=o.children[n];if(l==r)break;t+=l.height}return t}function Jn(e){var t=e.order;return null==t&&(t=e.order=Zl(e.text)),t}function ei(e){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function ti(e,t){var r={from:_(t.from),to:jo(t),text:_n(e,t.from,t.to)};return ai(e,r,t.from.line,t.to.line+1),Kn(e,function(e){ai(e,r,t.from.line,t.to.line+1)},!0),r}function ri(e){for(;e.length;){var t=Mi(e);if(!t.ranges)break;e.pop()}}function ni(e,t){return t?(ri(e.done),Mi(e.done)):e.done.length&&!Mi(e.done).ranges?Mi(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),Mi(e.done)):void 0}function ii(e,t,r,n){var i=e.history;i.undone.length=0;var o,l=+new Date;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>l-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=ni(i,i.lastOp==n))){var s=Mi(o.changes);0==Oo(t.from,t.to)&&0==Oo(t.from,s.to)?s.to=jo(t):o.changes.push(ti(e,t))}else{var a=Mi(i.done);for(a&&a.ranges||si(e.sel,i.done),o={changes:[ti(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=l,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,s||Ll(e,"historyAdded")}function oi(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function li(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||oi(e,o,Mi(i.done),t))?i.done[i.done.length-1]=t:si(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&n.clearRedo!==!1&&ri(i.undone)}function si(e,t){var r=Mi(t);r&&r.ranges&&r.equals(e)||t.push(e)}function ai(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o})}function ui(e){if(!e)return null;for(var t,r=0;r<e.length;++r)e[r].marker.explicitlyCleared?t||(t=e.slice(0,r)):t&&t.push(e[r]);return t?t.length?t:null:e}function ci(e,t){var r=t["spans_"+e.id];if(!r)return null;for(var n=0,i=[];n<t.text.length;++n)i.push(ui(r[n]));return i}function fi(e,t,r){for(var n=0,i=[];n<e.length;++n){var o=e[n];if(o.ranges)i.push(r?ue.prototype.deepCopy.call(o):o);else{var l=o.changes,s=[];i.push({changes:s});for(var a=0;a<l.length;++a){var u,c=l[a];if(s.push({from:c.from,to:c.to,text:c.text}),t)for(var f in c)(u=f.match(/^spans_(\d+)$/))&&Ni(t,Number(u[1]))>-1&&(Mi(s)[f]=c[f],delete c[f])}}}return i}function hi(e,t,r,n){r<e.line?e.line+=n:t<e.line&&(e.line=t,e.ch=0)}function di(e,t,r,n){for(var i=0;i<e.length;++i){var o=e[i],l=!0;if(o.ranges){o.copied||(o=e[i]=o.deepCopy(),o.copied=!0);for(var s=0;s<o.ranges.length;s++)hi(o.ranges[s].anchor,t,r,n),hi(o.ranges[s].head,t,r,n)}else{for(var s=0;s<o.changes.length;++s){var a=o.changes[s];if(r<a.from.line)a.from=Wo(a.from.line+n,a.from.ch),a.to=Wo(a.to.line+n,a.to.ch);else if(t<=a.to.line){l=!1;break}}l||(e.splice(0,i+1),i=0)}}}function pi(e,t){var r=t.from.line,n=t.to.line,i=t.text.length-(n-r)-1;di(e.done,r,n,i),di(e.undone,r,n,i)}function gi(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function vi(e){return e.target||e.srcElement}function mi(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),So&&e.ctrlKey&&1==t&&(t=3),t}function yi(e,t){function r(e){return function(){e.apply(null,o)}}var n=e._handlers&&e._handlers[t];if(n){var i,o=Array.prototype.slice.call(arguments,2);zo?i=zo.delayedCallbacks:kl?i=kl:(i=kl=[],setTimeout(bi,0));for(var l=0;l<n.length;++l)i.push(r(n[l]))}}function bi(){var e=kl;kl=null;for(var t=0;t<e.length;++t)e[t]()}function wi(e,t,r){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Ll(e,r||t.type,e,t),gi(t)||t.codemirrorIgnore}function xi(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var r=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),n=0;n<t.length;++n)-1==Ni(r,t[n])&&r.push(t[n])}function Ci(e,t){var r=e._handlers&&e._handlers[t];return r&&r.length>0}function Si(e){e.prototype.on=function(e,t){Cl(this,e,t)},e.prototype.off=function(e,t){Sl(this,e,t)}}function Li(){this.id=null}function ki(e,t,r){for(var n=0,i=0;;){var o=e.indexOf(" ",n);-1==o&&(o=e.length);var l=o-n;if(o==e.length||i+l>=t)return n+Math.min(l,t-i);if(i+=o-n,i+=r-i%r,n=o+1,i>=t)return n}}function Ti(e){for(;Dl.length<=e;)Dl.push(Mi(Dl)+" ");return Dl[e]}function Mi(e){return e[e.length-1]}function Ni(e,t){for(var r=0;r<e.length;++r)if(e[r]==t)return r;return-1}function Ai(e,t){for(var r=[],n=0;n<e.length;n++)r[n]=t(e[n],n);return r}function Wi(){}function Oi(e,t){var r;return Object.create?r=Object.create(e):(Wi.prototype=e,r=new Wi),t&&Di(t,r),r}function Di(e,t,r){t||(t={});for(var n in e)!e.hasOwnProperty(n)||r===!1&&t.hasOwnProperty(n)||(t[n]=e[n]);return t}function Hi(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function Ii(e,t){return t?t.source.indexOf("\\w")>-1&&El(e)?!0:t.test(e):El(e)}function Pi(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function Ei(e){return e.charCodeAt(0)>=768&&zl.test(e)}function zi(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)i.appendChild(t[o]);return i}function Fi(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function Ri(e,t){return Fi(e).appendChild(t)}function Bi(){return document.activeElement}function Gi(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function Ui(e,t){for(var r=e.split(" "),n=0;n<r.length;n++)r[n]&&!Gi(r[n]).test(t)&&(t+=" "+r[n]);return t}function Vi(e){if(document.body.getElementsByClassName)for(var t=document.body.getElementsByClassName("CodeMirror"),r=0;r<t.length;r++){var n=t[r].CodeMirror;n&&e(n)}}function Ki(){Vl||(ji(),Vl=!0)}function ji(){var e;Cl(window,"resize",function(){null==e&&(e=setTimeout(function(){e=null,Vi(Gt)},100))}),Cl(window,"blur",function(){Vi(hr)})}function Xi(e){if(null==Rl){var t=zi("span","");Ri(e,zi("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Rl=t.offsetWidth<=1&&t.offsetHeight>2&&!(fo&&8>ho))}var r=Rl?zi("span",""):zi("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function _i(e){if(null!=Bl)return Bl;var t=Ri(e,document.createTextNode("AخA")),r=Il(t,0,1).getBoundingClientRect();if(!r||r.left==r.right)return!1;var n=Il(t,1,2).getBoundingClientRect();return Bl=n.right-r.right<3}function Yi(e){if(null!=Yl)return Yl;var t=Ri(e,zi("span","x")),r=t.getBoundingClientRect(),n=Il(t,0,1).getBoundingClientRect();return Yl=Math.abs(r.left-n.left)>1}function $i(e,t,r,n){if(!e)return n(t,r,"ltr");for(var i=!1,o=0;o<e.length;++o){var l=e[o];(l.from<r&&l.to>t||t==r&&l.to==t)&&(n(Math.max(l.from,t),Math.min(l.to,r),1==l.level?"rtl":"ltr"),i=!0)}i||n(t,r,"ltr")}function qi(e){return e.level%2?e.to:e.from}function Zi(e){return e.level%2?e.from:e.to}function Qi(e){var t=Jn(e);return t?qi(t[0]):0}function Ji(e){var t=Jn(e);return t?Zi(Mi(t)):e.text.length}function eo(e,t){var r=Xn(e.doc,t),n=dn(r);n!=r&&(t=qn(n));var i=Jn(n),o=i?i[0].level%2?Ji(n):Qi(n):0;return Wo(t,o)}function to(e,t){for(var r,n=Xn(e.doc,t);r=fn(n);)n=r.find(1,!0).line,t=null;var i=Jn(n),o=i?i[0].level%2?Qi(n):Ji(n):n.text.length;return Wo(null==t?qn(n):t,o)}function ro(e,t){var r=eo(e,t.line),n=Xn(e.doc,r.line),i=Jn(n);if(!i||0==i[0].level){var o=Math.max(0,n.text.search(/\S/)),l=t.line==r.line&&t.ch<=o&&t.ch;return Wo(r.line,l?0:o)}return r}function no(e,t,r){var n=e[0].level;return t==n?!0:r==n?!1:r>t}function io(e,t){ql=null;for(var r,n=0;n<e.length;++n){var i=e[n];if(i.from<t&&i.to>t)return n;if(i.from==t||i.to==t){if(null!=r)return no(e,i.level,e[r].level)?(i.from!=i.to&&(ql=r),n):(i.from!=i.to&&(ql=n),r);r=n}}return r}function oo(e,t,r,n){if(!n)return t+r;do t+=r;while(t>0&&Ei(e.text.charAt(t)));return t}function lo(e,t,r,n){var i=Jn(e);if(!i)return so(e,t,r,n);for(var o=io(i,t),l=i[o],s=oo(e,t,l.level%2?-r:r,n);;){if(s>l.from&&s<l.to)return s;if(s==l.from||s==l.to)return io(i,s)==o?s:(l=i[o+=r],r>0==l.level%2?l.to:l.from);if(l=i[o+=r],!l)return null;s=r>0==l.level%2?oo(e,l.to,-1,n):oo(e,l.from,1,n)}}function so(e,t,r,n){var i=t+r;if(n)for(;i>0&&Ei(e.text.charAt(i));)i+=r;return 0>i||i>e.text.length?null:i}var ao=/gecko\/\d/i.test(navigator.userAgent),uo=/MSIE \d/.test(navigator.userAgent),co=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),fo=uo||co,ho=fo&&(uo?document.documentMode||6:co[1]),po=/WebKit\//.test(navigator.userAgent),go=po&&/Qt\/\d+\.\d+/.test(navigator.userAgent),vo=/Chrome\//.test(navigator.userAgent),mo=/Opera\//.test(navigator.userAgent),yo=/Apple Computer/.test(navigator.vendor),bo=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),wo=/PhantomJS/.test(navigator.userAgent),xo=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),Co=xo||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),So=xo||/Mac/.test(navigator.platform),Lo=/win/i.test(navigator.platform),ko=mo&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);ko&&(ko=Number(ko[1])),ko&&ko>=15&&(mo=!1,po=!0);var To=So&&(go||mo&&(null==ko||12.11>ko)),Mo=ao||fo&&ho>=9,No=!1,Ao=!1;g.prototype=Di({update:function(e){var t=e.scrollWidth>e.clientWidth+1,r=e.scrollHeight>e.clientHeight+1,n=e.nativeBarWidth;if(r){this.vert.style.display="block",this.vert.style.bottom=t?n+"px":"0";var i=e.viewHeight-(t?n:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=r?n+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(r?n:0);this.horiz.firstChild.style.width=e.scrollWidth-e.clientWidth+o+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedOverlay&&e.clientHeight>0&&(0==n&&this.overlayHack(),this.checkedOverlay=!0),{right:r?n:0,bottom:t?n:0}},setScrollLeft:function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e)},setScrollTop:function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e)},overlayHack:function(){var e=So&&!bo?"12px":"18px";this.horiz.style.minHeight=this.vert.style.minWidth=e;var t=this,r=function(e){vi(e)!=t.vert&&vi(e)!=t.horiz&&Mt(t.cm,Kt)(e)};Cl(this.vert,"mousedown",r),Cl(this.horiz,"mousedown",r)},clear:function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)}},g.prototype),v.prototype=Di({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},v.prototype),e.scrollbarModel={"native":g,"null":v},k.prototype.signal=function(e,t){Ci(e,t)&&this.events.push(arguments)},k.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Ll.apply(null,this.events[e])};var Wo=e.Pos=function(e,t){return this instanceof Wo?(this.line=e,void(this.ch=t)):new Wo(e,t)},Oo=e.cmpPos=function(e,t){return e.line-t.line||e.ch-t.ch},Do=null;te.prototype=Di({init:function(e){function t(e){if(n.somethingSelected())Do=n.getSelections(),r.inaccurateSelection&&(r.prevInput="",r.inaccurateSelection=!1,o.value=Do.join("\n"),Hl(o));else{if(!n.options.lineWiseCopyCut)return;var t=J(n);Do=t.text,"cut"==e.type?n.setSelections(t.ranges,null,Nl):(r.prevInput="",o.value=t.text.join("\n"),Hl(o))}"cut"==e.type&&(n.state.cutIncoming=!0)}var r=this,n=this.cm,i=this.wrapper=re(),o=this.textarea=i.firstChild;e.wrapper.insertBefore(i,e.wrapper.firstChild),xo&&(o.style.width="0px"),Cl(o,"input",function(){fo&&ho>=9&&r.hasSelection&&(r.hasSelection=null),r.poll()}),Cl(o,"paste",function(){if(po&&!n.state.fakedLastChar&&!(new Date-n.state.lastMiddleDown<200)){var e=o.selectionStart,t=o.selectionEnd;o.value+="$",o.selectionEnd=t,o.selectionStart=e,n.state.fakedLastChar=!0}n.state.pasteIncoming=!0,r.fastPoll()}),Cl(o,"cut",t),Cl(o,"copy",t),Cl(e.scroller,"paste",function(t){Ut(e,t)||(n.state.pasteIncoming=!0,r.focus())}),Cl(e.lineSpace,"selectstart",function(t){Ut(e,t)||bl(t)}),Cl(o,"compositionstart",function(){var e=n.getCursor("from");r.composing={start:e,range:n.markText(e,n.getCursor("to"),{className:"CodeMirror-composing"})}}),Cl(o,"compositionend",function(){r.composing&&(r.poll(),r.composing.range.clear(),r.composing=null)})},prepareSelection:function(){var e=this.cm,t=e.display,r=e.doc,n=De(e);if(e.options.moveInputWithCursor){var i=ct(e,r.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),l=t.lineDiv.getBoundingClientRect();n.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+l.top-o.top)),n.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+l.left-o.left))}return n},showSelection:function(e){var t=this.cm,r=t.display;Ri(r.cursorDiv,e.cursors),Ri(r.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},reset:function(e){if(!this.contextMenuPending){var t,r,n=this.cm,i=n.doc;if(n.somethingSelected()){this.prevInput="";var o=i.sel.primary();t=_l&&(o.to().line-o.from().line>100||(r=n.getSelection()).length>1e3);var l=t?"-":r||n.getSelection();this.textarea.value=l,n.state.focused&&Hl(this.textarea),fo&&ho>=9&&(this.hasSelection=l)}else e||(this.prevInput=this.textarea.value="",fo&&ho>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!Co||Bi()!=this.textarea))try{this.textarea.focus()}catch(e){}},blur:function(){this.textarea.blur();
|
4 |
+
},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var e=this;e.pollingFast||e.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},fastPoll:function(){function e(){var n=r.poll();n||t?(r.pollingFast=!1,r.slowPoll()):(t=!0,r.polling.set(60,e))}var t=!1,r=this;r.pollingFast=!0,r.polling.set(20,e)},poll:function(){var e=this.cm,t=this.textarea,r=this.prevInput;if(!e.state.focused||Xl(t)&&!r||Z(e)||e.options.disableInput||e.state.keySeq)return!1;e.state.pasteIncoming&&e.state.fakedLastChar&&(t.value=t.value.substring(0,t.value.length-1),e.state.fakedLastChar=!1);var n=t.value;if(n==r&&!e.somethingSelected())return!1;if(fo&&ho>=9&&this.hasSelection===n||So&&/[\uf700-\uf7ff]/.test(n))return e.display.input.reset(),!1;if(e.doc.sel==e.display.selForContextMenu){var i=n.charCodeAt(0);if(8203!=i||r||(r=""),8666==i)return this.reset(),this.cm.execCommand("undo")}for(var o=0,l=Math.min(r.length,n.length);l>o&&r.charCodeAt(o)==n.charCodeAt(o);)++o;var s=this;return Tt(e,function(){Q(e,n.slice(o),r.length-o,null,s.composing?"*compose":null),n.length>1e3||n.indexOf("\n")>-1?t.value=s.prevInput="":s.prevInput=n,s.composing&&(s.composing.range.clear(),s.composing.range=e.markText(s.composing.start,e.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){fo&&ho>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(e){function t(){if(null!=l.selectionStart){var e=i.somethingSelected(),t=""+(e?l.value:"");l.value="⇚",l.value=t,n.prevInput=e?"":"",l.selectionStart=1,l.selectionEnd=t.length,o.selForContextMenu=i.doc.sel}}function r(){if(n.contextMenuPending=!1,n.wrapper.style.position="relative",l.style.cssText=c,fo&&9>ho&&o.scrollbars.setScrollTop(o.scroller.scrollTop=a),null!=l.selectionStart){(!fo||fo&&9>ho)&&t();var e=0,r=function(){o.selForContextMenu==i.doc.sel&&0==l.selectionStart&&l.selectionEnd>0&&""==n.prevInput?Mt(i,rl.selectAll)(i):e++<10?o.detectingSelectAll=setTimeout(r,500):o.input.reset()};o.detectingSelectAll=setTimeout(r,200)}}var n=this,i=n.cm,o=i.display,l=n.textarea,s=Vt(i,e),a=o.scroller.scrollTop;if(s&&!mo){var u=i.options.resetSelectionOnContextMenu;u&&-1==i.doc.sel.contains(s)&&Mt(i,ke)(i.doc,he(s),Nl);var c=l.style.cssText;if(n.wrapper.style.position="absolute",l.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: "+(fo?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",po)var f=window.scrollY;if(o.input.focus(),po&&window.scrollTo(null,f),o.input.reset(),i.somethingSelected()||(l.value=n.prevInput=" "),n.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),fo&&ho>=9&&t(),Mo){xl(e);var h=function(){Sl(window,"mouseup",h),setTimeout(r,20)};Cl(window,"mouseup",h)}else setTimeout(r,50)}},setUneditable:Wi,needsContentAttribute:!1},te.prototype),ne.prototype=Di({init:function(e){function t(e){if(n.somethingSelected())Do=n.getSelections(),"cut"==e.type&&n.replaceSelection("",null,"cut");else{if(!n.options.lineWiseCopyCut)return;var t=J(n);Do=t.text,"cut"==e.type&&n.operation(function(){n.setSelections(t.ranges,0,Nl),n.replaceSelection("",null,"cut")})}if(e.clipboardData&&!xo)e.preventDefault(),e.clipboardData.clearData(),e.clipboardData.setData("text/plain",Do.join("\n"));else{var r=re(),i=r.firstChild;n.display.lineSpace.insertBefore(r,n.display.lineSpace.firstChild),i.value=Do.join("\n");var o=document.activeElement;Hl(i),setTimeout(function(){n.display.lineSpace.removeChild(r),o.focus()},50)}}var r=this,n=r.cm,i=r.div=e.lineDiv;i.contentEditable="true",ee(i),Cl(i,"paste",function(e){var t=e.clipboardData&&e.clipboardData.getData("text/plain");t&&(e.preventDefault(),n.replaceSelection(t,null,"paste"))}),Cl(i,"compositionstart",function(e){var t=e.data;if(r.composing={sel:n.doc.sel,data:t,startData:t},t){var i=n.doc.sel.primary(),o=n.getLine(i.head.line),l=o.indexOf(t,Math.max(0,i.head.ch-t.length));l>-1&&l<=i.head.ch&&(r.composing.sel=he(Wo(i.head.line,l),Wo(i.head.line,l+t.length)))}}),Cl(i,"compositionupdate",function(e){r.composing.data=e.data}),Cl(i,"compositionend",function(e){var t=r.composing;t&&(e.data==t.startData||/\u200b/.test(e.data)||(t.data=e.data),setTimeout(function(){t.handled||r.applyComposition(t),r.composing==t&&(r.composing=null)},50))}),Cl(i,"touchstart",function(){r.forceCompositionEnd()}),Cl(i,"input",function(){r.composing||r.pollContent()||Tt(r.cm,function(){Dt(n)})}),Cl(i,"copy",t),Cl(i,"cut",t)},prepareSelection:function(){var e=De(this.cm,!1);return e.focus=this.cm.state.focused,e},showSelection:function(e){e&&this.cm.display.view.length&&(e.focus&&this.showPrimarySelection(),this.showMultipleSelections(e))},showPrimarySelection:function(){var e=window.getSelection(),t=this.cm.doc.sel.primary(),r=le(this.cm,e.anchorNode,e.anchorOffset),n=le(this.cm,e.focusNode,e.focusOffset);if(!r||r.bad||!n||n.bad||0!=Oo($(r,n),t.from())||0!=Oo(Y(r,n),t.to())){var i=ie(this.cm,t.from()),o=ie(this.cm,t.to());if(i||o){var l=this.cm.display.view,s=e.rangeCount&&e.getRangeAt(0);if(i){if(!o){var a=l[l.length-1].measure,u=a.maps?a.maps[a.maps.length-1]:a.map;o={node:u[u.length-1],offset:u[u.length-2]-u[u.length-3]}}}else i={node:l[0].measure.map[2],offset:0};try{var c=Il(i.node,i.offset,o.offset,o.node)}catch(f){}c&&(e.removeAllRanges(),e.addRange(c),s&&null==e.anchorNode?e.addRange(s):ao&&this.startGracePeriod()),this.rememberSelection()}}},startGracePeriod:function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){e.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(e){Ri(this.cm.display.cursorDiv,e.cursors),Ri(this.cm.display.selectionDiv,e.selection)},rememberSelection:function(){var e=window.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},selectionInEditor:function(){var e=window.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return Fl(this.div,t)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}var t=this;this.selectionInEditor()?this.pollSelection():Tt(this.cm,function(){t.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,e)},selectionChanged:function(){var e=window.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var e=window.getSelection(),t=this.cm;this.rememberSelection();var r=le(t,e.anchorNode,e.anchorOffset),n=le(t,e.focusNode,e.focusOffset);r&&n&&Tt(t,function(){ke(t.doc,he(r,n),Nl),(r.bad||n.bad)&&(t.curOp.selectionChanged=!0)})}},pollContent:function(){var e=this.cm,t=e.display,r=e.doc.sel.primary(),n=r.from(),i=r.to();if(n.line<t.viewFrom||i.line>t.viewTo-1)return!1;var o;if(n.line==t.viewFrom||0==(o=Pt(e,n.line)))var l=qn(t.view[0].line),s=t.view[0].node;else var l=qn(t.view[o].line),s=t.view[o-1].node.nextSibling;var a=Pt(e,i.line);if(a==t.view.length-1)var u=t.viewTo-1,c=t.view[a].node;else var u=qn(t.view[a+1].line)-1,c=t.view[a+1].node.previousSibling;for(var f=jl(ae(e,s,c,l,u)),h=_n(e.doc,Wo(l,0),Wo(u,Xn(e.doc,u).text.length));f.length>1&&h.length>1;)if(Mi(f)==Mi(h))f.pop(),h.pop(),u--;else{if(f[0]!=h[0])break;f.shift(),h.shift(),l++}for(var d=0,p=0,g=f[0],v=h[0],m=Math.min(g.length,v.length);m>d&&g.charCodeAt(d)==v.charCodeAt(d);)++d;for(var y=Mi(f),b=Mi(h),w=Math.min(y.length-(1==f.length?d:0),b.length-(1==h.length?d:0));w>p&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)++p;f[f.length-1]=y.slice(0,y.length-p),f[0]=f[0].slice(d);var x=Wo(l,d),C=Wo(u,h.length?Mi(h).length-p:0);return f.length>1||f[0]||Oo(x,C)?(Tr(e.doc,f,x,C,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(e){e.data&&e.data!=e.startData&&Mt(this.cm,Q)(this.cm,e.data,0,e.sel)},setUneditable:function(e){e.setAttribute("contenteditable","false")},onKeyPress:function(e){e.preventDefault(),Mt(this.cm,Q)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},onContextMenu:Wi,resetPosition:Wi,needsContentAttribute:!0},ne.prototype),e.inputStyles={textarea:te,contenteditable:ne},ue.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var r=this.ranges[t],n=e.ranges[t];if(0!=Oo(r.anchor,n.anchor)||0!=Oo(r.head,n.head))return!1}return!0},deepCopy:function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new ce(_(this.ranges[t].anchor),_(this.ranges[t].head));return new ue(e,this.primIndex)},somethingSelected:function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},contains:function(e,t){t||(t=e);for(var r=0;r<this.ranges.length;r++){var n=this.ranges[r];if(Oo(t,n.from())>=0&&Oo(e,n.to())<=0)return r}return-1}},ce.prototype={from:function(){return $(this.anchor,this.head)},to:function(){return Y(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var Ho,Io,Po,Eo={left:0,right:0,top:0,bottom:0},zo=null,Fo=0,Ro=0,Bo=0,Go=null;fo?Go=-.53:ao?Go=15:vo?Go=-.7:yo&&(Go=-1/3);var Uo=function(e){var t=e.wheelDeltaX,r=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==r&&e.detail&&e.axis==e.VERTICAL_AXIS?r=e.detail:null==r&&(r=e.wheelDelta),{x:t,y:r}};e.wheelEventPixels=function(e){var t=Uo(e);return t.x*=Go,t.y*=Go,t};var Vo=new Li,Ko=null,jo=e.changeEnd=function(e){return e.text?Wo(e.from.line+e.text.length-1,Mi(e.text).length+(1==e.text.length?e.from.ch:0)):e.to};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,t){var r=this.options,n=r[e];(r[e]!=t||"mode"==e)&&(r[e]=t,_o.hasOwnProperty(e)&&Mt(this,_o[e])(this,t,n))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Gr(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,r=0;r<t.length;++r)if(t[r]==e||t[r].name==e)return t.splice(r,1),!0},addOverlay:Nt(function(t,r){var n=t.token?t:e.getMode(this.options,t);if(n.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:n,modeSpec:t,opaque:r&&r.opaque}),this.state.modeGen++,Dt(this)}),removeOverlay:Nt(function(e){for(var t=this.state.overlays,r=0;r<t.length;++r){var n=t[r].modeSpec;if(n==e||"string"==typeof e&&n.name==e)return t.splice(r,1),this.state.modeGen++,void Dt(this)}}),indentLine:Nt(function(e,t,r){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),ve(this.doc,e)&&Ir(this,e,t,r)}),indentSelection:Nt(function(e){for(var t=this.doc.sel.ranges,r=-1,n=0;n<t.length;n++){var i=t[n];if(i.empty())i.head.line>r&&(Ir(this,i.head.line,e,!0),r=i.head.line,n==this.doc.sel.primIndex&&Dr(this));else{var o=i.from(),l=i.to(),s=Math.max(r,o.line);r=Math.min(this.lastLine(),l.line-(l.ch?0:1))+1;for(var a=s;r>a;++a)Ir(this,a,e);var u=this.doc.sel.ranges;0==o.ch&&t.length==u.length&&u[n].from().ch>0&&xe(this.doc,n,new ce(o,u[n].to()),Nl)}}}),getTokenAt:function(e,t){return Mn(this,e,t)},getLineTokens:function(e,t){return Mn(this,Wo(e),t,!0)},getTokenTypeAt:function(e){e=pe(this.doc,e);var t,r=Wn(this,Xn(this.doc,e.line)),n=0,i=(r.length-1)/2,o=e.ch;if(0==o)t=r[2];else for(;;){var l=n+i>>1;if((l?r[2*l-1]:0)>=o)i=l;else{if(!(r[2*l+1]<o)){t=r[2*l+2];break}n=l+1}}var s=t?t.indexOf("cm-overlay "):-1;return 0>s?t:0==s?null:t.slice(0,s-1)},getModeAt:function(t){var r=this.doc.mode;return r.innerMode?e.innerMode(r,this.getTokenAt(t).state).mode:r},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var r=[];if(!Jo.hasOwnProperty(t))return r;var n=Jo[t],i=this.getModeAt(e);if("string"==typeof i[t])n[i[t]]&&r.push(n[i[t]]);else if(i[t])for(var o=0;o<i[t].length;o++){var l=n[i[t][o]];l&&r.push(l)}else i.helperType&&n[i.helperType]?r.push(n[i.helperType]):n[i.name]&&r.push(n[i.name]);for(var o=0;o<n._global.length;o++){var s=n._global[o];s.pred(i,this)&&-1==Ni(r,s.val)&&r.push(s.val)}return r},getStateAfter:function(e,t){var r=this.doc;return e=de(r,null==e?r.first+r.size-1:e),Re(this,e+1,t)},cursorCoords:function(e,t){var r,n=this.doc.sel.primary();return r=null==e?n.head:"object"==typeof e?pe(this.doc,e):e?n.from():n.to(),ct(this,r,t||"page")},charCoords:function(e,t){return ut(this,pe(this.doc,e),t||"page")},coordsChar:function(e,t){return e=at(this,e,t||"page"),dt(this,e.left,e.top)},lineAtHeight:function(e,t){return e=at(this,{top:e,left:0},t||"page").top,Zn(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t){var r,n=!1;if("number"==typeof e){var i=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>i&&(e=i,n=!0),r=Xn(this.doc,e)}else r=e;return st(this,r,{top:0,left:0},t||"page").top+(n?this.doc.height-Qn(r):0)},defaultTextHeight:function(){return gt(this.display)},defaultCharWidth:function(){return vt(this.display)},setGutterMarker:Nt(function(e,t,r){return Pr(this.doc,e,"gutter",function(e){var n=e.gutterMarkers||(e.gutterMarkers={});return n[t]=r,!r&&Pi(n)&&(e.gutterMarkers=null),!0})}),clearGutter:Nt(function(e){var t=this,r=t.doc,n=r.first;r.iter(function(r){r.gutterMarkers&&r.gutterMarkers[e]&&(r.gutterMarkers[e]=null,Ht(t,n,"gutter"),Pi(r.gutterMarkers)&&(r.gutterMarkers=null)),++n})}),lineInfo:function(e){if("number"==typeof e){if(!ve(this.doc,e))return null;var t=e;if(e=Xn(this.doc,e),!e)return null}else{var t=qn(e);if(null==t)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o=this.display;e=ct(this,pe(this.doc,e));var l=e.bottom,s=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==n)l=e.top;else if("above"==n||"near"==n){var a=Math.max(o.wrapper.clientHeight,this.doc.height),u=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>a)&&e.top>t.offsetHeight?l=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=a&&(l=e.bottom),s+t.offsetWidth>u&&(s=u-t.offsetWidth)}t.style.top=l+"px",t.style.left=t.style.right="","right"==i?(s=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?s=0:"middle"==i&&(s=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=s+"px"),r&&Ar(this,s,l,s+t.offsetWidth,l+t.offsetHeight)},triggerOnKeyDown:Nt(lr),triggerOnKeyPress:Nt(ur),triggerOnKeyUp:ar,execCommand:function(e){return rl.hasOwnProperty(e)?rl[e](this):void 0},findPosH:function(e,t,r,n){var i=1;0>t&&(i=-1,t=-t);for(var o=0,l=pe(this.doc,e);t>o&&(l=zr(this.doc,l,i,r,n),!l.hitSide);++o);return l},moveH:Nt(function(e,t){var r=this;r.extendSelectionsBy(function(n){return r.display.shift||r.doc.extend||n.empty()?zr(r.doc,n.head,e,t,r.options.rtlMoveVisually):0>e?n.from():n.to()},Wl)}),deleteH:Nt(function(e,t){var r=this.doc.sel,n=this.doc;r.somethingSelected()?n.replaceSelection("",null,"+delete"):Er(this,function(r){var i=zr(n,r.head,e,t,!1);return 0>e?{from:i,to:r.head}:{from:r.head,to:i}})}),findPosV:function(e,t,r,n){var i=1,o=n;0>t&&(i=-1,t=-t);for(var l=0,s=pe(this.doc,e);t>l;++l){var a=ct(this,s,"div");if(null==o?o=a.left:a.left=o,s=Fr(this,a,i,r),s.hitSide)break}return s},moveV:Nt(function(e,t){var r=this,n=this.doc,i=[],o=!r.display.shift&&!n.extend&&n.sel.somethingSelected();if(n.extendSelectionsBy(function(l){if(o)return 0>e?l.from():l.to();var s=ct(r,l.head,"div");null!=l.goalColumn&&(s.left=l.goalColumn),i.push(s.left);var a=Fr(r,s,e,t);return"page"==t&&l==n.sel.primary()&&Or(r,null,ut(r,a,"div").top-s.top),a},Wl),i.length)for(var l=0;l<n.sel.ranges.length;l++)n.sel.ranges[l].goalColumn=i[l]}),findWordAt:function(e){var t=this.doc,r=Xn(t,e.line).text,n=e.ch,i=e.ch;if(r){var o=this.getHelper(e,"wordChars");(e.xRel<0||i==r.length)&&n?--n:++i;for(var l=r.charAt(n),s=Ii(l,o)?function(e){return Ii(e,o)}:/\s/.test(l)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!Ii(e)};n>0&&s(r.charAt(n-1));)--n;for(;i<r.length&&s(r.charAt(i));)++i}return new ce(Wo(e.line,n),Wo(e.line,i))},toggleOverwrite:function(e){(null==e||e!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?Ul(this.display.cursorDiv,"CodeMirror-overwrite"):Gl(this.display.cursorDiv,"CodeMirror-overwrite"),Ll(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==Bi()},scrollTo:Nt(function(e,t){(null!=e||null!=t)&&Hr(this),null!=e&&(this.curOp.scrollLeft=e),null!=t&&(this.curOp.scrollTop=t)}),getScrollInfo:function(){var e=this.display.scroller;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-Ve(this)-this.display.barHeight,width:e.scrollWidth-Ve(this)-this.display.barWidth,clientHeight:je(this),clientWidth:Ke(this)}},scrollIntoView:Nt(function(e,t){if(null==e?(e={from:this.doc.sel.primary().head,to:null},null==t&&(t=this.options.cursorScrollMargin)):"number"==typeof e?e={from:Wo(e,0),to:null}:null==e.from&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0,null!=e.from.line)Hr(this),this.curOp.scrollToPos=e;else{var r=Wr(this,Math.min(e.from.left,e.to.left),Math.min(e.from.top,e.to.top)-e.margin,Math.max(e.from.right,e.to.right),Math.max(e.from.bottom,e.to.bottom)+e.margin);this.scrollTo(r.scrollLeft,r.scrollTop)}}),setSize:Nt(function(e,t){function r(e){return"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e}var n=this;null!=e&&(n.display.wrapper.style.width=r(e)),null!=t&&(n.display.wrapper.style.height=r(t)),n.options.lineWrapping&&nt(this);var i=n.display.viewFrom;n.doc.iter(i,n.display.viewTo,function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){Ht(n,i,"widget");break}++i}),n.curOp.forceUpdate=!0,Ll(n,"refresh",this)}),operation:function(e){return Tt(this,e)},refresh:Nt(function(){var e=this.display.cachedTextHeight;Dt(this),this.curOp.forceUpdate=!0,it(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),c(this),(null==e||Math.abs(e-gt(this.display))>.5)&&l(this),Ll(this,"refresh",this)}),swapDoc:Nt(function(e){var t=this.doc;return t.cm=null,jn(this,e),it(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,yi(this,"swapDoc",this,t),t}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Si(e);var Xo=e.defaults={},_o=e.optionHandlers={},Yo=e.Init={toString:function(){return"CodeMirror.Init"}};Rr("value","",function(e,t){e.setValue(t)},!0),Rr("mode",null,function(e,t){e.doc.modeOption=t,r(e)},!0),Rr("indentUnit",2,r,!0),Rr("indentWithTabs",!1),Rr("smartIndent",!0),Rr("tabSize",4,function(e){n(e),it(e),Dt(e)},!0),Rr("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(t,r,n){t.state.specialChars=new RegExp(r.source+(r.test(" ")?"":"| "),"g"),n!=e.Init&&t.refresh()}),Rr("specialCharPlaceholder",In,function(e){e.refresh()},!0),Rr("electricChars",!0),Rr("inputStyle",Co?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),Rr("rtlMoveVisually",!Lo),Rr("wholeLineUpdateBefore",!0),Rr("theme","default",function(e){s(e),a(e)},!0),Rr("keyMap","default",function(t,r,n){var i=Gr(r),o=n!=e.Init&&Gr(n);o&&o.detach&&o.detach(t,i),i.attach&&i.attach(t,o||null)}),Rr("extraKeys",null),Rr("lineWrapping",!1,i,!0),Rr("gutters",[],function(e){d(e.options),a(e)},!0),Rr("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?L(e.display)+"px":"0",e.refresh()},!0),Rr("coverGutterNextToScrollbar",!1,function(e){y(e)},!0),Rr("scrollbarStyle","native",function(e){m(e),y(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),Rr("lineNumbers",!1,function(e){d(e.options),a(e)},!0),Rr("firstLineNumber",1,a,!0),Rr("lineNumberFormatter",function(e){return e},a,!0),Rr("showCursorWhenSelecting",!1,Oe,!0),Rr("resetSelectionOnContextMenu",!0),Rr("lineWiseCopyCut",!0),Rr("readOnly",!1,function(e,t){"nocursor"==t?(hr(e),e.display.input.blur(),e.display.disabled=!0):(e.display.disabled=!1,t||e.display.input.reset())}),Rr("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),Rr("dragDrop",!0,Bt),Rr("cursorBlinkRate",530),Rr("cursorScrollMargin",0),Rr("cursorHeight",1,Oe,!0),Rr("singleCursorHeightPerLine",!0,Oe,!0),Rr("workTime",100),Rr("workDelay",100),Rr("flattenSpans",!0,n,!0),Rr("addModeClass",!1,n,!0),Rr("pollInterval",100),Rr("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),Rr("historyEventDelay",1250),Rr("viewportMargin",10,function(e){e.refresh()},!0),Rr("maxHighlightLength",1e4,n,!0),Rr("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),Rr("tabindex",null,function(e,t){e.display.input.getField().tabIndex=t||""}),Rr("autofocus",null);var $o=e.modes={},qo=e.mimeModes={};e.defineMode=function(t,r){e.defaults.mode||"null"==t||(e.defaults.mode=t),arguments.length>2&&(r.dependencies=Array.prototype.slice.call(arguments,2)),$o[t]=r},e.defineMIME=function(e,t){qo[e]=t},e.resolveMode=function(t){if("string"==typeof t&&qo.hasOwnProperty(t))t=qo[t];else if(t&&"string"==typeof t.name&&qo.hasOwnProperty(t.name)){var r=qo[t.name];"string"==typeof r&&(r={name:r}),t=Oi(r,t),t.name=r.name}else if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return e.resolveMode("application/xml");return"string"==typeof t?{name:t}:t||{name:"null"}},e.getMode=function(t,r){var r=e.resolveMode(r),n=$o[r.name];if(!n)return e.getMode(t,"text/plain");var i=n(t,r);if(Zo.hasOwnProperty(r.name)){var o=Zo[r.name];for(var l in o)o.hasOwnProperty(l)&&(i.hasOwnProperty(l)&&(i["_"+l]=i[l]),i[l]=o[l])}if(i.name=r.name,r.helperType&&(i.helperType=r.helperType),r.modeProps)for(var l in r.modeProps)i[l]=r.modeProps[l];return i},e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var Zo=e.modeExtensions={};e.extendMode=function(e,t){var r=Zo.hasOwnProperty(e)?Zo[e]:Zo[e]={};Di(t,r)},e.defineExtension=function(t,r){e.prototype[t]=r},e.defineDocExtension=function(e,t){vl.prototype[e]=t},e.defineOption=Rr;var Qo=[];e.defineInitHook=function(e){Qo.push(e)};var Jo=e.helpers={};e.registerHelper=function(t,r,n){Jo.hasOwnProperty(t)||(Jo[t]=e[t]={_global:[]}),Jo[t][r]=n},e.registerGlobalHelper=function(t,r,n,i){e.registerHelper(t,r,i),Jo[t]._global.push({pred:n,val:i})};var el=e.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var r={};for(var n in t){var i=t[n];i instanceof Array&&(i=i.concat([])),r[n]=i}return r},tl=e.startState=function(e,t,r){return e.startState?e.startState(t,r):!0};e.innerMode=function(e,t){for(;e.innerMode;){var r=e.innerMode(t);if(!r||r.mode==e)break;t=r.state,e=r.mode}return r||{mode:e,state:t}};var rl=e.commands={selectAll:function(e){e.setSelection(Wo(e.firstLine(),0),Wo(e.lastLine()),Nl)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Nl)},killLine:function(e){Er(e,function(t){if(t.empty()){var r=Xn(e.doc,t.head.line).text.length;return t.head.ch==r&&t.head.line<e.lastLine()?{from:t.head,to:Wo(t.head.line+1,0)}:{from:t.head,to:Wo(t.head.line,r)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){Er(e,function(t){return{from:Wo(t.from().line,0),to:pe(e.doc,Wo(t.to().line+1,0))}})},delLineLeft:function(e){Er(e,function(e){return{from:Wo(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){Er(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return{from:n,to:t.from()}})},delWrappedLineRight:function(e){Er(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div");return{from:t.from(),to:n}})},undo:function(e){e.undo()},redo:function(e){e.redo()},undoSelection:function(e){e.undoSelection()},redoSelection:function(e){e.redoSelection()},goDocStart:function(e){e.extendSelection(Wo(e.firstLine(),0))},goDocEnd:function(e){e.extendSelection(Wo(e.lastLine()))},goLineStart:function(e){e.extendSelectionsBy(function(t){return eo(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){e.extendSelectionsBy(function(t){return ro(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){e.extendSelectionsBy(function(t){return to(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div")},Wl)},goLineLeft:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:r},"div")},Wl)},goLineLeftSmart:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return n.ch<e.getLine(n.line).search(/\S/)?ro(e,t.head):n},Wl)},goLineUp:function(e){e.moveV(-1,"line")},goLineDown:function(e){e.moveV(1,"line")},goPageUp:function(e){e.moveV(-1,"page")},goPageDown:function(e){e.moveV(1,"page")},goCharLeft:function(e){e.moveH(-1,"char")},goCharRight:function(e){e.moveH(1,"char")},goColumnLeft:function(e){e.moveH(-1,"column")},goColumnRight:function(e){e.moveH(1,"column")},goWordLeft:function(e){e.moveH(-1,"word")},goGroupRight:function(e){e.moveH(1,"group")},goGroupLeft:function(e){e.moveH(-1,"group")},goWordRight:function(e){e.moveH(1,"word")},delCharBefore:function(e){e.deleteH(-1,"char")},delCharAfter:function(e){e.deleteH(1,"char")},delWordBefore:function(e){e.deleteH(-1,"word")},delWordAfter:function(e){e.deleteH(1,"word")},delGroupBefore:function(e){e.deleteH(-1,"group")},delGroupAfter:function(e){e.deleteH(1,"group")},indentAuto:function(e){e.indentSelection("smart")},indentMore:function(e){e.indentSelection("add")},indentLess:function(e){e.indentSelection("subtract")},insertTab:function(e){e.replaceSelection(" ")},insertSoftTab:function(e){for(var t=[],r=e.listSelections(),n=e.options.tabSize,i=0;i<r.length;i++){var o=r[i].from(),l=Ol(e.getLine(o.line),o.ch,n);t.push(new Array(n-l%n+1).join(" "))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){Tt(e,function(){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++){var i=t[n].head,o=Xn(e.doc,i.line).text;if(o)if(i.ch==o.length&&(i=new Wo(i.line,i.ch-1)),i.ch>0)i=new Wo(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),Wo(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=Xn(e.doc,i.line-1).text;l&&e.replaceRange(o.charAt(0)+"\n"+l.charAt(l.length-1),Wo(i.line-1,l.length-1),Wo(i.line,1),"+transpose")}r.push(new ce(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){Tt(e,function(){for(var t=e.listSelections().length,r=0;t>r;r++){var n=e.listSelections()[r];e.replaceRange("\n",n.anchor,n.head,"+input"),e.indentLine(n.from().line+1,null,!0),Dr(e)}})},toggleOverwrite:function(e){e.toggleOverwrite()}},nl=e.keyMap={};nl.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},nl.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},nl.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},nl.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},nl["default"]=So?nl.macDefault:nl.pcDefault,e.normalizeKeyMap=function(e){var t={};for(var r in e)if(e.hasOwnProperty(r)){var n=e[r];if(/^(name|fallthrough|(de|at)tach)$/.test(r))continue;if("..."==n){delete e[r];continue}for(var i=Ai(r.split(" "),Br),o=0;o<i.length;o++){var l,s;o==i.length-1?(s=r,l=n):(s=i.slice(0,o+1).join(" "),l="...");var a=t[s];if(a){if(a!=l)throw new Error("Inconsistent bindings for "+s)}else t[s]=l}delete e[r]}for(var u in t)e[u]=t[u];return e};var il=e.lookupKey=function(e,t,r,n){t=Gr(t);var i=t.call?t.call(e,n):t[e];if(i===!1)return"nothing";if("..."===i)return"multi";if(null!=i&&r(i))return"handled";if(t.fallthrough){if("[object Array]"!=Object.prototype.toString.call(t.fallthrough))return il(e,t.fallthrough,r,n);for(var o=0;o<t.fallthrough.length;o++){var l=il(e,t.fallthrough[o],r,n);if(l)return l}}},ol=e.isModifierKey=function(e){var t="string"==typeof e?e:$l[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t},ll=e.keyName=function(e,t){if(mo&&34==e.keyCode&&e["char"])return!1;var r=$l[e.keyCode],n=r;return null==n||e.altGraphKey?!1:(e.altKey&&"Alt"!=r&&(n="Alt-"+n),(To?e.metaKey:e.ctrlKey)&&"Ctrl"!=r&&(n="Ctrl-"+n),(To?e.ctrlKey:e.metaKey)&&"Cmd"!=r&&(n="Cmd-"+n),!t&&e.shiftKey&&"Shift"!=r&&(n="Shift-"+n),n)};e.fromTextArea=function(t,r){function n(){t.value=u.getValue()}if(r=r?Di(r):{},r.value=t.value,!r.tabindex&&t.tabIndex&&(r.tabindex=t.tabIndex),!r.placeholder&&t.placeholder&&(r.placeholder=t.placeholder),null==r.autofocus){var i=Bi();r.autofocus=i==t||null!=t.getAttribute("autofocus")&&i==document.body;
|
5 |
+
}if(t.form&&(Cl(t.form,"submit",n),!r.leaveSubmitMethodAlone)){var o=t.form,l=o.submit;try{var s=o.submit=function(){n(),o.submit=l,o.submit(),o.submit=s}}catch(a){}}r.finishInit=function(e){e.save=n,e.getTextArea=function(){return t},e.toTextArea=function(){e.toTextArea=isNaN,n(),t.parentNode.removeChild(e.getWrapperElement()),t.style.display="",t.form&&(Sl(t.form,"submit",n),"function"==typeof t.form.submit&&(t.form.submit=l))}},t.style.display="none";var u=e(function(e){t.parentNode.insertBefore(e,t.nextSibling)},r);return u};var sl=e.StringStream=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};sl.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},eat:function(e){var t=this.string.charAt(this.pos);if("string"==typeof e)var r=t==e;else var r=t&&(e.test?e.test(t):e(t));return r?(++this.pos,t):void 0},eatWhile:function(e){for(var t=this.pos;this.eat(e););return this.pos>t},eatSpace:function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);return t>-1?(this.pos=t,!0):void 0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Ol(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?Ol(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return Ol(this.string,null,this.tabSize)-(this.lineStart?Ol(this.string,this.lineStart,this.tabSize):0)},match:function(e,t,r){if("string"!=typeof e){var n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}var i=function(e){return r?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);return i(o)==i(e)?(t!==!1&&(this.pos+=e.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var al=0,ul=e.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++al};Si(ul),ul.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&mt(e),Ci(this,"clear")){var r=this.find();r&&yi(this,"clear",r.from,r.to)}for(var n=null,i=null,o=0;o<this.lines.length;++o){var l=this.lines[o],s=Yr(l.markedSpans,this);e&&!this.collapsed?Ht(e,qn(l),"text"):e&&(null!=s.to&&(i=qn(l)),null!=s.from&&(n=qn(l))),l.markedSpans=$r(l.markedSpans,s),null==s.from&&this.collapsed&&!mn(this.doc,l)&&e&&$n(l,gt(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var o=0;o<this.lines.length;++o){var a=dn(this.lines[o]),u=f(a);u>e.display.maxLineLength&&(e.display.maxLine=a,e.display.maxLineLength=u,e.display.maxLineChanged=!0)}null!=n&&e&&this.collapsed&&Dt(e,n,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Ne(e.doc)),e&&yi(e,"markerCleared",e,this),t&&bt(e),this.parent&&this.parent.clear()}},ul.prototype.find=function(e,t){null==e&&"bookmark"==this.type&&(e=1);for(var r,n,i=0;i<this.lines.length;++i){var o=this.lines[i],l=Yr(o.markedSpans,this);if(null!=l.from&&(r=Wo(t?o:qn(o),l.from),-1==e))return r;if(null!=l.to&&(n=Wo(t?o:qn(o),l.to),1==e))return n}return r&&{from:r,to:n}},ul.prototype.changed=function(){var e=this.find(-1,!0),t=this,r=this.doc.cm;e&&r&&Tt(r,function(){var n=e.line,i=qn(e.line),o=qe(r,i);if(o&&(rt(o),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!mn(t.doc,n)&&null!=t.height){var l=t.height;t.height=null;var s=wn(t)-l;s&&$n(n,n.height+s)}})},ul.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&-1!=Ni(t.maybeHiddenMarkers,this)||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},ul.prototype.detachLine=function(e){if(this.lines.splice(Ni(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}};var al=0,cl=e.SharedTextMarker=function(e,t){this.markers=e,this.primary=t;for(var r=0;r<e.length;++r)e[r].parent=this};Si(cl),cl.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();yi(this,"clear")}},cl.prototype.find=function(e,t){return this.primary.find(e,t)};var fl=e.LineWidget=function(e,t,r){if(r)for(var n in r)r.hasOwnProperty(n)&&(this[n]=r[n]);this.doc=e,this.node=t};Si(fl),fl.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,r=this.line,n=qn(r);if(null!=n&&t){for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(r.widgets=null);var o=wn(this);$n(r,Math.max(0,r.height-o)),e&&Tt(e,function(){bn(e,r,-o),Ht(e,n,"widget")})}},fl.prototype.changed=function(){var e=this.height,t=this.doc.cm,r=this.line;this.height=null;var n=wn(this)-e;n&&($n(r,r.height+n),t&&Tt(t,function(){t.curOp.forceUpdate=!0,bn(t,r,n)}))};var hl=e.Line=function(e,t,r){this.text=e,on(this,t),this.height=r?r(this):1};Si(hl),hl.prototype.lineNo=function(){return qn(this)};var dl={},pl={};Un.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var r=e,n=e+t;n>r;++r){var i=this.lines[r];this.height-=i.height,Sn(i),yi(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,r){this.height+=r,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var n=0;n<t.length;++n)t[n].parent=this},iterN:function(e,t,r){for(var n=e+t;n>e;++e)if(r(this.lines[e]))return!0}},Vn.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var r=0;r<this.children.length;++r){var n=this.children[r],i=n.chunkSize();if(i>e){var o=Math.min(t,i-e),l=n.height;if(n.removeInner(e,o),this.height-=l-n.height,i==o&&(this.children.splice(r--,1),n.parent=null),0==(t-=o))break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Un))){var s=[];this.collapse(s),this.children=[new Un(s)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,r){this.size+=t.length,this.height+=r;for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>=e){if(i.insertInner(e,t,r),i.lines&&i.lines.length>50){for(;i.lines.length>50;){var l=i.lines.splice(i.lines.length-25,25),s=new Un(l);i.height-=s.height,this.children.splice(n+1,0,s),s.parent=this}this.maybeSpill()}break}e-=o}},maybeSpill:function(){if(!(this.children.length<=10)){var e=this;do{var t=e.children.splice(e.children.length-5,5),r=new Vn(t);if(e.parent){e.size-=r.size,e.height-=r.height;var n=Ni(e.parent.children,e);e.parent.children.splice(n+1,0,r)}else{var i=new Vn(e.children);i.parent=e,e.children=[i,r],e=i}r.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()}},iterN:function(e,t,r){for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>e){var l=Math.min(t,o-e);if(i.iterN(e,l,r))return!0;if(0==(t-=l))break;e=0}else e-=o}}};var gl=0,vl=e.Doc=function(e,t,r){if(!(this instanceof vl))return new vl(e,t,r);null==r&&(r=0),Vn.call(this,[new Un([new hl("",null)])]),this.first=r,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=r;var n=Wo(r,0);this.sel=he(n),this.history=new ei(null),this.id=++gl,this.modeOption=t,"string"==typeof e&&(e=jl(e)),Gn(this,{from:n,to:n,text:e}),ke(this,he(n),Nl)};vl.prototype=Oi(Vn.prototype,{constructor:vl,iter:function(e,t,r){r?this.iterN(e-this.first,t-e,r):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var r=0,n=0;n<t.length;++n)r+=t[n].height;this.insertInner(e-this.first,t,r)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=Yn(this,this.first,this.first+this.size);return e===!1?t:t.join(e||"\n")},setValue:At(function(e){var t=Wo(this.first,0),r=this.first+this.size-1;wr(this,{from:t,to:Wo(r,Xn(this,r).text.length),text:jl(e),origin:"setValue",full:!0},!0),ke(this,he(t))}),replaceRange:function(e,t,r,n){t=pe(this,t),r=r?pe(this,r):t,Tr(this,e,t,r,n)},getRange:function(e,t,r){var n=_n(this,pe(this,e),pe(this,t));return r===!1?n:n.join(r||"\n")},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){return ve(this,e)?Xn(this,e):void 0},getLineNumber:function(e){return qn(e)},getLineHandleVisualStart:function(e){return"number"==typeof e&&(e=Xn(this,e)),dn(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return pe(this,e)},getCursor:function(e){var t,r=this.sel.primary();return t=null==e||"head"==e?r.head:"anchor"==e?r.anchor:"end"==e||"to"==e||e===!1?r.to():r.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:At(function(e,t,r){Ce(this,pe(this,"number"==typeof e?Wo(e,t||0):e),null,r)}),setSelection:At(function(e,t,r){Ce(this,pe(this,e),pe(this,t||e),r)}),extendSelection:At(function(e,t,r){be(this,pe(this,e),t&&pe(this,t),r)}),extendSelections:At(function(e,t){we(this,me(this,e,t))}),extendSelectionsBy:At(function(e,t){we(this,Ai(this.sel.ranges,e),t)}),setSelections:At(function(e,t,r){if(e.length){for(var n=0,i=[];n<e.length;n++)i[n]=new ce(pe(this,e[n].anchor),pe(this,e[n].head));null==t&&(t=Math.min(e.length-1,this.sel.primIndex)),ke(this,fe(i,t),r)}}),addSelection:At(function(e,t,r){var n=this.sel.ranges.slice(0);n.push(new ce(pe(this,e),pe(this,t||e))),ke(this,fe(n,n.length-1),r)}),getSelection:function(e){for(var t,r=this.sel.ranges,n=0;n<r.length;n++){var i=_n(this,r[n].from(),r[n].to());t=t?t.concat(i):i}return e===!1?t:t.join(e||"\n")},getSelections:function(e){for(var t=[],r=this.sel.ranges,n=0;n<r.length;n++){var i=_n(this,r[n].from(),r[n].to());e!==!1&&(i=i.join(e||"\n")),t[n]=i}return t},replaceSelection:function(e,t,r){for(var n=[],i=0;i<this.sel.ranges.length;i++)n[i]=e;this.replaceSelections(n,t,r||"+input")},replaceSelections:At(function(e,t,r){for(var n=[],i=this.sel,o=0;o<i.ranges.length;o++){var l=i.ranges[o];n[o]={from:l.from(),to:l.to(),text:jl(e[o]),origin:r}}for(var s=t&&"end"!=t&&yr(this,n,t),o=n.length-1;o>=0;o--)wr(this,n[o]);s?Le(this,s):this.cm&&Dr(this.cm)}),undo:At(function(){Cr(this,"undo")}),redo:At(function(){Cr(this,"redo")}),undoSelection:At(function(){Cr(this,"undo",!0)}),redoSelection:At(function(){Cr(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,r=0,n=0;n<e.done.length;n++)e.done[n].ranges||++t;for(var n=0;n<e.undone.length;n++)e.undone[n].ranges||++r;return{undo:t,redo:r}},clearHistory:function(){this.history=new ei(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:fi(this.history.done),undone:fi(this.history.undone)}},setHistory:function(e){var t=this.history=new ei(this.history.maxGeneration);t.done=fi(e.done.slice(0),null,!0),t.undone=fi(e.undone.slice(0),null,!0)},addLineClass:At(function(e,t,r){return Pr(this,e,"gutter"==t?"gutter":"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass";if(e[n]){if(Gi(r).test(e[n]))return!1;e[n]+=" "+r}else e[n]=r;return!0})}),removeLineClass:At(function(e,t,r){return Pr(this,e,"gutter"==t?"gutter":"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass",i=e[n];if(!i)return!1;if(null==r)e[n]=null;else{var o=i.match(Gi(r));if(!o)return!1;var l=o.index+o[0].length;e[n]=i.slice(0,o.index)+(o.index&&l!=i.length?" ":"")+i.slice(l)||null}return!0})}),addLineWidget:At(function(e,t,r){return xn(this,e,t,r)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,r){return Ur(this,pe(this,e),pe(this,t),r,"range")},setBookmark:function(e,t){var r={replacedWith:t&&(null==t.nodeType?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return e=pe(this,e),Ur(this,e,e,r,"bookmark")},findMarksAt:function(e){e=pe(this,e);var t=[],r=Xn(this,e.line).markedSpans;if(r)for(var n=0;n<r.length;++n){var i=r[n];(null==i.from||i.from<=e.ch)&&(null==i.to||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,r){e=pe(this,e),t=pe(this,t);var n=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var l=o.markedSpans;if(l)for(var s=0;s<l.length;s++){var a=l[s];i==e.line&&e.ch>a.to||null==a.from&&i!=e.line||i==t.line&&a.from>t.ch||r&&!r(a.marker)||n.push(a.marker.parent||a.marker)}++i}),n},getAllMarks:function(){var e=[];return this.iter(function(t){var r=t.markedSpans;if(r)for(var n=0;n<r.length;++n)null!=r[n].from&&e.push(r[n].marker)}),e},posFromIndex:function(e){var t,r=this.first;return this.iter(function(n){var i=n.text.length+1;return i>e?(t=e,!0):(e-=i,void++r)}),pe(this,Wo(r,t))},indexFromPos:function(e){e=pe(this,e);var t=e.ch;return e.line<this.first||e.ch<0?0:(this.iter(this.first,e.line,function(e){t+=e.text.length+1}),t)},copy:function(e){var t=new vl(Yn(this,this.first,this.first+this.size),this.modeOption,this.first);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,r=this.first+this.size;null!=e.from&&e.from>t&&(t=e.from),null!=e.to&&e.to<r&&(r=e.to);var n=new vl(Yn(this,t,r),e.mode||this.modeOption,t);return e.sharedHist&&(n.history=this.history),(this.linked||(this.linked=[])).push({doc:n,sharedHist:e.sharedHist}),n.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],jr(n,Kr(this)),n},unlinkDoc:function(t){if(t instanceof e&&(t=t.doc),this.linked)for(var r=0;r<this.linked.length;++r){var n=this.linked[r];if(n.doc==t){this.linked.splice(r,1),t.unlinkDoc(this),Xr(Kr(this));break}}if(t.history==this.history){var i=[t.id];Kn(t,function(e){i.push(e.id)},!0),t.history=new ei(null),t.history.done=fi(this.history.done,i),t.history.undone=fi(this.history.undone,i)}},iterLinkedDocs:function(e){Kn(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm}}),vl.prototype.eachLine=vl.prototype.iter;var ml="iter insert remove copy getEditor".split(" ");for(var yl in vl.prototype)vl.prototype.hasOwnProperty(yl)&&Ni(ml,yl)<0&&(e.prototype[yl]=function(e){return function(){return e.apply(this.doc,arguments)}}(vl.prototype[yl]));Si(vl);var bl=e.e_preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},wl=e.e_stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},xl=e.e_stop=function(e){bl(e),wl(e)},Cl=e.on=function(e,t,r){if(e.addEventListener)e.addEventListener(t,r,!1);else if(e.attachEvent)e.attachEvent("on"+t,r);else{var n=e._handlers||(e._handlers={}),i=n[t]||(n[t]=[]);i.push(r)}},Sl=e.off=function(e,t,r){if(e.removeEventListener)e.removeEventListener(t,r,!1);else if(e.detachEvent)e.detachEvent("on"+t,r);else{var n=e._handlers&&e._handlers[t];if(!n)return;for(var i=0;i<n.length;++i)if(n[i]==r){n.splice(i,1);break}}},Ll=e.signal=function(e,t){var r=e._handlers&&e._handlers[t];if(r)for(var n=Array.prototype.slice.call(arguments,2),i=0;i<r.length;++i)r[i].apply(null,n)},kl=null,Tl=30,Ml=e.Pass={toString:function(){return"CodeMirror.Pass"}},Nl={scroll:!1},Al={origin:"*mouse"},Wl={origin:"+move"};Li.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var Ol=e.countColumn=function(e,t,r,n,i){null==t&&(t=e.search(/[^\s\u00a0]/),-1==t&&(t=e.length));for(var o=n||0,l=i||0;;){var s=e.indexOf(" ",o);if(0>s||s>=t)return l+(t-o);l+=s-o,l+=r-l%r,o=s+1}},Dl=[""],Hl=function(e){e.select()};xo?Hl=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:fo&&(Hl=function(e){try{e.select()}catch(t){}});var Il,Pl=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,El=e.isWordChar=function(e){return/\w/.test(e)||e>""&&(e.toUpperCase()!=e.toLowerCase()||Pl.test(e))},zl=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;Il=document.createRange?function(e,t,r,n){var i=document.createRange();return i.setEnd(n||e,r),i.setStart(e,t),i}:function(e,t,r){var n=document.body.createTextRange();try{n.moveToElementText(e.parentNode)}catch(i){return n}return n.collapse(!0),n.moveEnd("character",r),n.moveStart("character",t),n};var Fl=e.contains=function(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do if(11==t.nodeType&&(t=t.host),t==e)return!0;while(t=t.parentNode)};fo&&11>ho&&(Bi=function(){try{return document.activeElement}catch(e){return document.body}});var Rl,Bl,Gl=e.rmClass=function(e,t){var r=e.className,n=Gi(t).exec(r);if(n){var i=r.slice(n.index+n[0].length);e.className=r.slice(0,n.index)+(i?n[1]+i:"")}},Ul=e.addClass=function(e,t){var r=e.className;Gi(t).test(r)||(e.className+=(r?" ":"")+t)},Vl=!1,Kl=function(){if(fo&&9>ho)return!1;var e=zi("div");return"draggable"in e||"dragDrop"in e}(),jl=e.splitLines=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,r=[],n=e.length;n>=t;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),l=o.indexOf("\r");-1!=l?(r.push(o.slice(0,l)),t+=l+1):(r.push(o),t=i+1)}return r}:function(e){return e.split(/\r\n?|\n/)},Xl=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){try{var t=e.ownerDocument.selection.createRange()}catch(r){}return t&&t.parentElement()==e?0!=t.compareEndPoints("StartToEnd",t):!1},_l=function(){var e=zi("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),Yl=null,$l={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};e.keyNames=$l,function(){for(var e=0;10>e;e++)$l[e+48]=$l[e+96]=String(e);for(var e=65;90>=e;e++)$l[e]=String.fromCharCode(e);for(var e=1;12>=e;e++)$l[e+111]=$l[e+63235]="F"+e}();var ql,Zl=function(){function e(e){return 247>=e?r.charAt(e):e>=1424&&1524>=e?"R":e>=1536&&1773>=e?n.charAt(e-1536):e>=1774&&2220>=e?"r":e>=8192&&8203>=e?"w":8204==e?"b":"L"}function t(e,t,r){this.level=e,this.from=t,this.to=r}var r="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",n="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,l=/[LRr]/,s=/[Lb1n]/,a=/[1n]/,u="L";return function(r){if(!i.test(r))return!1;for(var n,c=r.length,f=[],h=0;c>h;++h)f.push(n=e(r.charCodeAt(h)));for(var h=0,d=u;c>h;++h){var n=f[h];"m"==n?f[h]=d:d=n}for(var h=0,p=u;c>h;++h){var n=f[h];"1"==n&&"r"==p?f[h]="n":l.test(n)&&(p=n,"r"==n&&(f[h]="R"))}for(var h=1,d=f[0];c-1>h;++h){var n=f[h];"+"==n&&"1"==d&&"1"==f[h+1]?f[h]="1":","!=n||d!=f[h+1]||"1"!=d&&"n"!=d||(f[h]=d),d=n}for(var h=0;c>h;++h){var n=f[h];if(","==n)f[h]="N";else if("%"==n){for(var g=h+1;c>g&&"%"==f[g];++g);for(var v=h&&"!"==f[h-1]||c>g&&"1"==f[g]?"1":"N",m=h;g>m;++m)f[m]=v;h=g-1}}for(var h=0,p=u;c>h;++h){var n=f[h];"L"==p&&"1"==n?f[h]="L":l.test(n)&&(p=n)}for(var h=0;c>h;++h)if(o.test(f[h])){for(var g=h+1;c>g&&o.test(f[g]);++g);for(var y="L"==(h?f[h-1]:u),b="L"==(c>g?f[g]:u),v=y||b?"L":"R",m=h;g>m;++m)f[m]=v;h=g-1}for(var w,x=[],h=0;c>h;)if(s.test(f[h])){var C=h;for(++h;c>h&&s.test(f[h]);++h);x.push(new t(0,C,h))}else{var S=h,L=x.length;for(++h;c>h&&"L"!=f[h];++h);for(var m=S;h>m;)if(a.test(f[m])){m>S&&x.splice(L,0,new t(1,S,m));var k=m;for(++m;h>m&&a.test(f[m]);++m);x.splice(L,0,new t(2,k,m)),S=m}else++m;h>S&&x.splice(L,0,new t(1,S,h))}return 1==x[0].level&&(w=r.match(/^\s+/))&&(x[0].from=w[0].length,x.unshift(new t(0,0,w[0].length))),1==Mi(x).level&&(w=r.match(/\s+$/))&&(Mi(x).to-=w[0].length,x.push(new t(0,c-w[0].length,c))),2==x[0].level&&x.unshift(new t(1,x[0].to,x[0].to)),x[0].level!=Mi(x).level&&x.push(new t(x[0].level,c,c)),x}}();return e.version="5.2.0",e});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/mode/css/css.min.js
CHANGED
@@ -1,57 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.defineMode("css",function(config,parserConfig){if(!parserConfig.propertyKeywords)parserConfig=CodeMirror.resolveMode("text/css");var indentUnit=config.indentUnit,tokenHooks=parserConfig.tokenHooks,documentTypes=parserConfig.documentTypes||{},mediaTypes=parserConfig.mediaTypes||{},mediaFeatures=parserConfig.mediaFeatures||{},propertyKeywords=parserConfig.propertyKeywords||{},nonStandardPropertyKeywords=parserConfig.nonStandardPropertyKeywords||{},fontProperties=parserConfig.fontProperties||{},counterDescriptors=parserConfig.counterDescriptors||{},colorKeywords=parserConfig.colorKeywords||{},valueKeywords=parserConfig.valueKeywords||{},allowNested=parserConfig.allowNested;var type,override;function ret(style,tp){type=tp;return style;}
|
6 |
-
function tokenBase(stream,state){var ch=stream.next();if(tokenHooks[ch]){var result=tokenHooks[ch](stream,state);if(result!==false)return result;}
|
7 |
-
if(ch=="@"){stream.eatWhile(/[\w\\\-]/);return ret("def",stream.current());}else if(ch=="="||(ch=="~"||ch=="|")&&stream.eat("=")){return ret(null,"compare");}else if(ch=="\""||ch=="'"){state.tokenize=tokenString(ch);return state.tokenize(stream,state);}else if(ch=="#"){stream.eatWhile(/[\w\\\-]/);return ret("atom","hash");}else if(ch=="!"){stream.match(/^\s*\w*/);return ret("keyword","important");}else if(/\d/.test(ch)||ch=="."&&stream.eat(/\d/)){stream.eatWhile(/[\w.%]/);return ret("number","unit");}else if(ch==="-"){if(/[\d.]/.test(stream.peek())){stream.eatWhile(/[\w.%]/);return ret("number","unit");}else if(stream.match(/^-[\w\\\-]+/)){stream.eatWhile(/[\w\\\-]/);if(stream.match(/^\s*:/,false))
|
8 |
-
return ret("variable-2","variable-definition");return ret("variable-2","variable");}else if(stream.match(/^\w+-/)){return ret("meta","meta");}}else if(/[,+>*\/]/.test(ch)){return ret(null,"select-op");}else if(ch=="."&&stream.match(/^-?[_a-z][_a-z0-9-]*/i)){return ret("qualifier","qualifier");}else if(/[:;{}\[\]\(\)]/.test(ch)){return ret(null,ch);}else if((ch=="u"&&stream.match(/rl(-prefix)?\(/))||(ch=="d"&&stream.match("omain("))||(ch=="r"&&stream.match("egexp("))){stream.backUp(1);state.tokenize=tokenParenthesized;return ret("property","word");}else if(/[\w\\\-]/.test(ch)){stream.eatWhile(/[\w\\\-]/);return ret("property","word");}else{return ret(null,null);}}
|
9 |
-
function tokenString(quote){return function(stream,state){var escaped=false,ch;while((ch=stream.next())!=null){if(ch==quote&&!escaped){if(quote==")")stream.backUp(1);break;}
|
10 |
-
escaped=!escaped&&ch=="\\";}
|
11 |
-
if(ch==quote||!escaped&"e!=")")state.tokenize=null;return ret("string","string");};}
|
12 |
-
function tokenParenthesized(stream,state){stream.next();if(!stream.match(/\s*[\"\')]/,false))
|
13 |
-
state.tokenize=tokenString(")");else
|
14 |
-
state.tokenize=null;return ret(null,"(");}
|
15 |
-
function Context(type,indent,prev){this.type=type;this.indent=indent;this.prev=prev;}
|
16 |
-
function pushContext(state,stream,type){state.context=new Context(type,stream.indentation()+indentUnit,state.context);return type;}
|
17 |
-
function popContext(state){state.context=state.context.prev;return state.context.type;}
|
18 |
-
function pass(type,stream,state){return states[state.context.type](type,stream,state);}
|
19 |
-
function popAndPass(type,stream,state,n){for(var i=n||1;i>0;i--)
|
20 |
-
state.context=state.context.prev;return pass(type,stream,state);}
|
21 |
-
function wordAsValue(stream){var word=stream.current().toLowerCase();if(valueKeywords.hasOwnProperty(word))
|
22 |
-
override="atom";else if(colorKeywords.hasOwnProperty(word))
|
23 |
-
override="keyword";else
|
24 |
-
override="variable";}
|
25 |
-
var states={};states.top=function(type,stream,state){if(type=="{"){return pushContext(state,stream,"block");}else if(type=="}"&&state.context.prev){return popContext(state);}else if(/@(media|supports|(-moz-)?document)/.test(type)){return pushContext(state,stream,"atBlock");}else if(/@(font-face|counter-style)/.test(type)){state.stateArg=type;return"restricted_atBlock_before";}else if(/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)){return"keyframes";}else if(type&&type.charAt(0)=="@"){return pushContext(state,stream,"at");}else if(type=="hash"){override="builtin";}else if(type=="word"){override="tag";}else if(type=="variable-definition"){return"maybeprop";}else if(type=="interpolation"){return pushContext(state,stream,"interpolation");}else if(type==":"){return"pseudo";}else if(allowNested&&type=="("){return pushContext(state,stream,"parens");}
|
26 |
-
return state.context.type;};states.block=function(type,stream,state){if(type=="word"){var word=stream.current().toLowerCase();if(propertyKeywords.hasOwnProperty(word)){override="property";return"maybeprop";}else if(nonStandardPropertyKeywords.hasOwnProperty(word)){override="string-2";return"maybeprop";}else if(allowNested){override=stream.match(/^\s*:(?:\s|$)/,false)?"property":"tag";return"block";}else{override+=" error";return"maybeprop";}}else if(type=="meta"){return"block";}else if(!allowNested&&(type=="hash"||type=="qualifier")){override="error";return"block";}else{return states.top(type,stream,state);}};states.maybeprop=function(type,stream,state){if(type==":")return pushContext(state,stream,"prop");return pass(type,stream,state);};states.prop=function(type,stream,state){if(type==";")return popContext(state);if(type=="{"&&allowNested)return pushContext(state,stream,"propBlock");if(type=="}"||type=="{")return popAndPass(type,stream,state);if(type=="(")return pushContext(state,stream,"parens");if(type=="hash"&&!/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(stream.current())){override+=" error";}else if(type=="word"){wordAsValue(stream);}else if(type=="interpolation"){return pushContext(state,stream,"interpolation");}
|
27 |
-
return"prop";};states.propBlock=function(type,_stream,state){if(type=="}")return popContext(state);if(type=="word"){override="property";return"maybeprop";}
|
28 |
-
return state.context.type;};states.parens=function(type,stream,state){if(type=="{"||type=="}")return popAndPass(type,stream,state);if(type==")")return popContext(state);if(type=="(")return pushContext(state,stream,"parens");if(type=="interpolation")return pushContext(state,stream,"interpolation");if(type=="word")wordAsValue(stream);return"parens";};states.pseudo=function(type,stream,state){if(type=="word"){override="variable-3";return state.context.type;}
|
29 |
-
return pass(type,stream,state);};states.atBlock=function(type,stream,state){if(type=="(")return pushContext(state,stream,"atBlock_parens");if(type=="}")return popAndPass(type,stream,state);if(type=="{")return popContext(state)&&pushContext(state,stream,allowNested?"block":"top");if(type=="word"){var word=stream.current().toLowerCase();if(word=="only"||word=="not"||word=="and"||word=="or")
|
30 |
-
override="keyword";else if(documentTypes.hasOwnProperty(word))
|
31 |
-
override="tag";else if(mediaTypes.hasOwnProperty(word))
|
32 |
-
override="attribute";else if(mediaFeatures.hasOwnProperty(word))
|
33 |
-
override="property";else if(propertyKeywords.hasOwnProperty(word))
|
34 |
-
override="property";else if(nonStandardPropertyKeywords.hasOwnProperty(word))
|
35 |
-
override="string-2";else if(valueKeywords.hasOwnProperty(word))
|
36 |
-
override="atom";else
|
37 |
-
override="error";}
|
38 |
-
return state.context.type;};states.atBlock_parens=function(type,stream,state){if(type==")")return popContext(state);if(type=="{"||type=="}")return popAndPass(type,stream,state,2);return states.atBlock(type,stream,state);};states.restricted_atBlock_before=function(type,stream,state){if(type=="{")
|
39 |
-
return pushContext(state,stream,"restricted_atBlock");if(type=="word"&&state.stateArg=="@counter-style"){override="variable";return"restricted_atBlock_before";}
|
40 |
-
return pass(type,stream,state);};states.restricted_atBlock=function(type,stream,state){if(type=="}"){state.stateArg=null;return popContext(state);}
|
41 |
-
if(type=="word"){if((state.stateArg=="@font-face"&&!fontProperties.hasOwnProperty(stream.current().toLowerCase()))||(state.stateArg=="@counter-style"&&!counterDescriptors.hasOwnProperty(stream.current().toLowerCase())))
|
42 |
-
override="error";else
|
43 |
-
override="property";return"maybeprop";}
|
44 |
-
return"restricted_atBlock";};states.keyframes=function(type,stream,state){if(type=="word"){override="variable";return"keyframes";}
|
45 |
-
if(type=="{")return pushContext(state,stream,"top");return pass(type,stream,state);};states.at=function(type,stream,state){if(type==";")return popContext(state);if(type=="{"||type=="}")return popAndPass(type,stream,state);if(type=="word")override="tag";else if(type=="hash")override="builtin";return"at";};states.interpolation=function(type,stream,state){if(type=="}")return popContext(state);if(type=="{"||type==";")return popAndPass(type,stream,state);if(type=="word")override="variable";else if(type!="variable")override="error";return"interpolation";};return{startState:function(base){return{tokenize:null,state:"top",stateArg:null,context:new Context("top",base||0,null)};},token:function(stream,state){if(!state.tokenize&&stream.eatSpace())return null;var style=(state.tokenize||tokenBase)(stream,state);if(style&&typeof style=="object"){type=style[1];style=style[0];}
|
46 |
-
override=style;state.state=states[state.state](type,stream,state);return override;},indent:function(state,textAfter){var cx=state.context,ch=textAfter&&textAfter.charAt(0);var indent=cx.indent;if(cx.type=="prop"&&(ch=="}"||ch==")"))cx=cx.prev;if(cx.prev&&(ch=="}"&&(cx.type=="block"||cx.type=="top"||cx.type=="interpolation"||cx.type=="restricted_atBlock")||ch==")"&&(cx.type=="parens"||cx.type=="atBlock_parens")||ch=="{"&&(cx.type=="at"||cx.type=="atBlock"))){indent=cx.indent-indentUnit;cx=cx.prev;}
|
47 |
-
return indent;},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",fold:"brace"};});function keySet(array){var keys={};for(var i=0;i<array.length;++i){keys[array[i]]=true;}
|
48 |
-
return keys;}
|
49 |
-
var documentTypes_=["domain","regexp","url","url-prefix"],documentTypes=keySet(documentTypes_);var mediaTypes_=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],mediaTypes=keySet(mediaTypes_);var mediaFeatures_=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid"],mediaFeatures=keySet(mediaFeatures_);var propertyKeywords_=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-position","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],propertyKeywords=keySet(propertyKeywords_);var nonStandardPropertyKeywords_=["scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-3d-light-color","scrollbar-track-color","shape-inside","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","zoom"],nonStandardPropertyKeywords=keySet(nonStandardPropertyKeywords_);var fontProperties_=["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],fontProperties=keySet(fontProperties_);var counterDescriptors_=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],counterDescriptors=keySet(counterDescriptors_);var colorKeywords_=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],colorKeywords=keySet(colorKeywords_);var valueKeywords_=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","column","compact","condensed","contain","content","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","footnotes","forwards","from","geometricPrecision","georgian","graytext","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","malayalam","match","matrix","matrix3d","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row-resize","rtl","run-in","running","s-resize","sans-serif","scale","scale3d","scaleX","scaleY","scaleZ","scroll","scrollbar","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","solid","somali","source-atop","source-in","source-out","source-over","space","spell-out","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","symbolic","symbols","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","x-large","x-small","xor","xx-large","xx-small"],valueKeywords=keySet(valueKeywords_);var allWords=documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_).concat(valueKeywords_);CodeMirror.registerHelper("hintWords","css",allWords);function tokenCComment(stream,state){var maybeEnd=false,ch;while((ch=stream.next())!=null){if(maybeEnd&&ch=="/"){state.tokenize=null;break;}
|
50 |
-
maybeEnd=(ch=="*");}
|
51 |
-
return["comment","comment"];}
|
52 |
-
function tokenSGMLComment(stream,state){if(stream.skipTo("-->")){stream.match("-->");state.tokenize=null;}else{stream.skipToEnd();}
|
53 |
-
return["comment","comment"];}
|
54 |
-
CodeMirror.defineMIME("text/css",{documentTypes:documentTypes,mediaTypes:mediaTypes,mediaFeatures:mediaFeatures,propertyKeywords:propertyKeywords,nonStandardPropertyKeywords:nonStandardPropertyKeywords,fontProperties:fontProperties,counterDescriptors:counterDescriptors,colorKeywords:colorKeywords,valueKeywords:valueKeywords,tokenHooks:{"<":function(stream,state){if(!stream.match("!--"))return false;state.tokenize=tokenSGMLComment;return tokenSGMLComment(stream,state);},"/":function(stream,state){if(!stream.eat("*"))return false;state.tokenize=tokenCComment;return tokenCComment(stream,state);}},name:"css"});CodeMirror.defineMIME("text/x-scss",{mediaTypes:mediaTypes,mediaFeatures:mediaFeatures,propertyKeywords:propertyKeywords,nonStandardPropertyKeywords:nonStandardPropertyKeywords,colorKeywords:colorKeywords,valueKeywords:valueKeywords,fontProperties:fontProperties,allowNested:true,tokenHooks:{"/":function(stream,state){if(stream.eat("/")){stream.skipToEnd();return["comment","comment"];}else if(stream.eat("*")){state.tokenize=tokenCComment;return tokenCComment(stream,state);}else{return["operator","operator"];}},":":function(stream){if(stream.match(/\s*\{/))
|
55 |
-
return[null,"{"];return false;},"$":function(stream){stream.match(/^[\w-]+/);if(stream.match(/^\s*:/,false))
|
56 |
-
return["variable-2","variable-definition"];return["variable-2","variable"];},"#":function(stream){if(!stream.eat("{"))return false;return[null,"interpolation"];}},name:"css",helperType:"scss"});CodeMirror.defineMIME("text/x-less",{mediaTypes:mediaTypes,mediaFeatures:mediaFeatures,propertyKeywords:propertyKeywords,nonStandardPropertyKeywords:nonStandardPropertyKeywords,colorKeywords:colorKeywords,valueKeywords:valueKeywords,fontProperties:fontProperties,allowNested:true,tokenHooks:{"/":function(stream,state){if(stream.eat("/")){stream.skipToEnd();return["comment","comment"];}else if(stream.eat("*")){state.tokenize=tokenCComment;return tokenCComment(stream,state);}else{return["operator","operator"];}},"@":function(stream){if(stream.eat("{"))return[null,"interpolation"];if(stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/,false))return false;stream.eatWhile(/[\w\\\-]/);if(stream.match(/^\s*:/,false))
|
57 |
-
return["variable-2","variable-definition"];return["variable-2","variable"];},"&":function(){return["atom","atom"];}},name:"css",helperType:"less"});});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e){for(var t={},r=0;r<e.length;++r)t[e[r]]=!0;return t}function r(e,t){for(var r,o=!1;null!=(r=e.next());){if(o&&"/"==r){t.tokenize=null;break}o="*"==r}return["comment","comment"]}function o(e,t){return e.skipTo("-->")?(e.match("-->"),t.tokenize=null):e.skipToEnd(),["comment","comment"]}e.defineMode("css",function(t,r){function o(e,t){return m=t,e}function a(e,t){var r=e.next();if(g[r]){var a=g[r](e,t);if(a!==!1)return a}return"@"==r?(e.eatWhile(/[\w\\\-]/),o("def",e.current())):"="==r||("~"==r||"|"==r)&&e.eat("=")?o(null,"compare"):'"'==r||"'"==r?(t.tokenize=i(r),t.tokenize(e,t)):"#"==r?(e.eatWhile(/[\w\\\-]/),o("atom","hash")):"!"==r?(e.match(/^\s*\w*/),o("keyword","important")):/\d/.test(r)||"."==r&&e.eat(/\d/)?(e.eatWhile(/[\w.%]/),o("number","unit")):"-"!==r?/[,+>*\/]/.test(r)?o(null,"select-op"):"."==r&&e.match(/^-?[_a-z][_a-z0-9-]*/i)?o("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(r)?o(null,r):"u"==r&&e.match(/rl(-prefix)?\(/)||"d"==r&&e.match("omain(")||"r"==r&&e.match("egexp(")?(e.backUp(1),t.tokenize=n,o("property","word")):/[\w\\\-]/.test(r)?(e.eatWhile(/[\w\\\-]/),o("property","word")):o(null,null):/[\d.]/.test(e.peek())?(e.eatWhile(/[\w.%]/),o("number","unit")):e.match(/^-[\w\\\-]+/)?(e.eatWhile(/[\w\\\-]/),e.match(/^\s*:/,!1)?o("variable-2","variable-definition"):o("variable-2","variable")):e.match(/^\w+-/)?o("meta","meta"):void 0}function i(e){return function(t,r){for(var a,i=!1;null!=(a=t.next());){if(a==e&&!i){")"==e&&t.backUp(1);break}i=!i&&"\\"==a}return(a==e||!i&&")"!=e)&&(r.tokenize=null),o("string","string")}}function n(e,t){return e.next(),e.match(/\s*[\"\')]/,!1)?t.tokenize=null:t.tokenize=i(")"),o(null,"(")}function l(e,t,r){this.type=e,this.indent=t,this.prev=r}function s(e,t,r){return e.context=new l(r,t.indentation()+b,e.context),r}function c(e){return e.context=e.context.prev,e.context.type}function d(e,t,r){return K[r.context.type](e,t,r)}function u(e,t,r,o){for(var a=o||1;a>0;a--)r.context=r.context.prev;return d(e,t,r)}function p(e){var t=e.current().toLowerCase();h=j.hasOwnProperty(t)?"atom":q.hasOwnProperty(t)?"keyword":"variable"}r.propertyKeywords||(r=e.resolveMode("text/css"));var m,h,b=t.indentUnit,g=r.tokenHooks,f=r.documentTypes||{},k=r.mediaTypes||{},w=r.mediaFeatures||{},y=r.propertyKeywords||{},v=r.nonStandardPropertyKeywords||{},x=r.fontProperties||{},z=r.counterDescriptors||{},q=r.colorKeywords||{},j=r.valueKeywords||{},P=r.allowNested,K={};return K.top=function(e,t,r){if("{"==e)return s(r,t,"block");if("}"==e&&r.context.prev)return c(r);if(/@(media|supports|(-moz-)?document)/.test(e))return s(r,t,"atBlock");if(/@(font-face|counter-style)/.test(e))return r.stateArg=e,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(e))return"keyframes";if(e&&"@"==e.charAt(0))return s(r,t,"at");if("hash"==e)h="builtin";else if("word"==e)h="tag";else{if("variable-definition"==e)return"maybeprop";if("interpolation"==e)return s(r,t,"interpolation");if(":"==e)return"pseudo";if(P&&"("==e)return s(r,t,"parens")}return r.context.type},K.block=function(e,t,r){if("word"==e){var o=t.current().toLowerCase();return y.hasOwnProperty(o)?(h="property","maybeprop"):v.hasOwnProperty(o)?(h="string-2","maybeprop"):P?(h=t.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(h+=" error","maybeprop")}return"meta"==e?"block":P||"hash"!=e&&"qualifier"!=e?K.top(e,t,r):(h="error","block")},K.maybeprop=function(e,t,r){return":"==e?s(r,t,"prop"):d(e,t,r)},K.prop=function(e,t,r){if(";"==e)return c(r);if("{"==e&&P)return s(r,t,"propBlock");if("}"==e||"{"==e)return u(e,t,r);if("("==e)return s(r,t,"parens");if("hash"!=e||/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(t.current())){if("word"==e)p(t);else if("interpolation"==e)return s(r,t,"interpolation")}else h+=" error";return"prop"},K.propBlock=function(e,t,r){return"}"==e?c(r):"word"==e?(h="property","maybeprop"):r.context.type},K.parens=function(e,t,r){return"{"==e||"}"==e?u(e,t,r):")"==e?c(r):"("==e?s(r,t,"parens"):"interpolation"==e?s(r,t,"interpolation"):("word"==e&&p(t),"parens")},K.pseudo=function(e,t,r){return"word"==e?(h="variable-3",r.context.type):d(e,t,r)},K.atBlock=function(e,t,r){if("("==e)return s(r,t,"atBlock_parens");if("}"==e)return u(e,t,r);if("{"==e)return c(r)&&s(r,t,P?"block":"top");if("word"==e){var o=t.current().toLowerCase();h="only"==o||"not"==o||"and"==o||"or"==o?"keyword":f.hasOwnProperty(o)?"tag":k.hasOwnProperty(o)?"attribute":w.hasOwnProperty(o)?"property":y.hasOwnProperty(o)?"property":v.hasOwnProperty(o)?"string-2":j.hasOwnProperty(o)?"atom":"error"}return r.context.type},K.atBlock_parens=function(e,t,r){return")"==e?c(r):"{"==e||"}"==e?u(e,t,r,2):K.atBlock(e,t,r)},K.restricted_atBlock_before=function(e,t,r){return"{"==e?s(r,t,"restricted_atBlock"):"word"==e&&"@counter-style"==r.stateArg?(h="variable","restricted_atBlock_before"):d(e,t,r)},K.restricted_atBlock=function(e,t,r){return"}"==e?(r.stateArg=null,c(r)):"word"==e?(h="@font-face"==r.stateArg&&!x.hasOwnProperty(t.current().toLowerCase())||"@counter-style"==r.stateArg&&!z.hasOwnProperty(t.current().toLowerCase())?"error":"property","maybeprop"):"restricted_atBlock"},K.keyframes=function(e,t,r){return"word"==e?(h="variable","keyframes"):"{"==e?s(r,t,"top"):d(e,t,r)},K.at=function(e,t,r){return";"==e?c(r):"{"==e||"}"==e?u(e,t,r):("word"==e?h="tag":"hash"==e&&(h="builtin"),"at")},K.interpolation=function(e,t,r){return"}"==e?c(r):"{"==e||";"==e?u(e,t,r):("word"==e?h="variable":"variable"!=e&&(h="error"),"interpolation")},{startState:function(e){return{tokenize:null,state:"top",stateArg:null,context:new l("top",e||0,null)}},token:function(e,t){if(!t.tokenize&&e.eatSpace())return null;var r=(t.tokenize||a)(e,t);return r&&"object"==typeof r&&(m=r[1],r=r[0]),h=r,t.state=K[t.state](m,e,t),h},indent:function(e,t){var r=e.context,o=t&&t.charAt(0),a=r.indent;return"prop"!=r.type||"}"!=o&&")"!=o||(r=r.prev),!r.prev||("}"!=o||"block"!=r.type&&"top"!=r.type&&"interpolation"!=r.type&&"restricted_atBlock"!=r.type)&&(")"!=o||"parens"!=r.type&&"atBlock_parens"!=r.type)&&("{"!=o||"at"!=r.type&&"atBlock"!=r.type)||(a=r.indent-b,r=r.prev),a},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",fold:"brace"}});var a=["domain","regexp","url","url-prefix"],i=t(a),n=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],l=t(n),s=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid"],c=t(s),d=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-position","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],u=t(d),p=["scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-3d-light-color","scrollbar-track-color","shape-inside","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","zoom"],m=t(p),h=["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],b=t(h),g=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],f=t(g),k=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],w=t(k),y=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","column","compact","condensed","contain","content","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","footnotes","forwards","from","geometricPrecision","georgian","graytext","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","malayalam","match","matrix","matrix3d","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row-resize","rtl","run-in","running","s-resize","sans-serif","scale","scale3d","scaleX","scaleY","scaleZ","scroll","scrollbar","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","solid","somali","source-atop","source-in","source-out","source-over","space","spell-out","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","symbolic","symbols","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","x-large","x-small","xor","xx-large","xx-small"],v=t(y),x=a.concat(n).concat(s).concat(d).concat(p).concat(k).concat(y);e.registerHelper("hintWords","css",x),e.defineMIME("text/css",{documentTypes:i,mediaTypes:l,mediaFeatures:c,propertyKeywords:u,nonStandardPropertyKeywords:m,fontProperties:b,counterDescriptors:f,colorKeywords:w,valueKeywords:v,tokenHooks:{"<":function(e,t){return e.match("!--")?(t.tokenize=o,o(e,t)):!1},"/":function(e,t){return e.eat("*")?(t.tokenize=r,r(e,t)):!1}},name:"css"}),e.defineMIME("text/x-scss",{mediaTypes:l,mediaFeatures:c,propertyKeywords:u,nonStandardPropertyKeywords:m,colorKeywords:w,valueKeywords:v,fontProperties:b,allowNested:!0,tokenHooks:{"/":function(e,t){return e.eat("/")?(e.skipToEnd(),["comment","comment"]):e.eat("*")?(t.tokenize=r,r(e,t)):["operator","operator"]},":":function(e){return e.match(/\s*\{/)?[null,"{"]:!1},$:function(e){return e.match(/^[\w-]+/),e.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(e){return e.eat("{")?[null,"interpolation"]:!1}},name:"css",helperType:"scss"}),e.defineMIME("text/x-less",{mediaTypes:l,mediaFeatures:c,propertyKeywords:u,nonStandardPropertyKeywords:m,colorKeywords:w,valueKeywords:v,fontProperties:b,allowNested:!0,tokenHooks:{"/":function(e,t){return e.eat("/")?(e.skipToEnd(),["comment","comment"]):e.eat("*")?(t.tokenize=r,r(e,t)):["operator","operator"]},"@":function(e){return e.eat("{")?[null,"interpolation"]:e.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/,!1)?!1:(e.eatWhile(/[\w\\\-]/),e.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"])},"&":function(){return["atom","atom"]}},name:"css",helperType:"less"})});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/codemirror/mode/css/less_test.min.js
CHANGED
@@ -1,3 +1 @@
|
|
1 |
-
|
2 |
-
(function(){"use strict";var mode=CodeMirror.getMode({indentUnit:2},"text/x-less");function MT(name){test.mode(name,mode,Array.prototype.slice.call(arguments,1),"less");}
|
3 |
-
MT("variable","[variable-2 @base]: [atom #f04615];","[qualifier .class] {"," [property width]: [variable percentage]([number 0.5]); [comment // returns `50%`]"," [property color]: [variable saturate]([variable-2 @base], [number 5%]);","}");MT("amp","[qualifier .child], [qualifier .sibling] {"," [qualifier .parent] [atom &] {"," [property color]: [keyword black];"," }"," [atom &] + [atom &] {"," [property color]: [keyword red];"," }","}");MT("mixin","[qualifier .mixin] ([variable dark]; [variable-2 @color]) {"," [property color]: [variable darken]([variable-2 @color], [number 10%]);","}","[qualifier .mixin] ([variable light]; [variable-2 @color]) {"," [property color]: [variable lighten]([variable-2 @color], [number 10%]);","}","[qualifier .mixin] ([variable-2 @_]; [variable-2 @color]) {"," [property display]: [atom block];","}","[variable-2 @switch]: [variable light];","[qualifier .class] {"," [qualifier .mixin]([variable-2 @switch]; [atom #888]);","}");MT("nest","[qualifier .one] {"," [def @media] ([property width]: [number 400px]) {"," [property font-size]: [number 1.2em];"," [def @media] [attribute print] [keyword and] [property color] {"," [property color]: [keyword blue];"," }"," }","}");MT("interpolation",".@{[variable foo]} { [property font-weight]: [atom bold]; }");})();
|
1 |
+
!function(){"use strict";function r(r){test.mode(r,e,Array.prototype.slice.call(arguments,1),"less")}var e=CodeMirror.getMode({indentUnit:2},"text/x-less");r("variable","[variable-2 @base]: [atom #f04615];","[qualifier .class] {"," [property width]: [variable percentage]([number 0.5]); [comment // returns `50%`]"," [property color]: [variable saturate]([variable-2 @base], [number 5%]);","}"),r("amp","[qualifier .child], [qualifier .sibling] {"," [qualifier .parent] [atom &] {"," [property color]: [keyword black];"," }"," [atom &] + [atom &] {"," [property color]: [keyword red];"," }","}"),r("mixin","[qualifier .mixin] ([variable dark]; [variable-2 @color]) {"," [property color]: [variable darken]([variable-2 @color], [number 10%]);","}","[qualifier .mixin] ([variable light]; [variable-2 @color]) {"," [property color]: [variable lighten]([variable-2 @color], [number 10%]);","}","[qualifier .mixin] ([variable-2 @_]; [variable-2 @color]) {"," [property display]: [atom block];","}","[variable-2 @switch]: [variable light];","[qualifier .class] {"," [qualifier .mixin]([variable-2 @switch]; [atom #888]);","}"),r("nest","[qualifier .one] {"," [def @media] ([property width]: [number 400px]) {"," [property font-size]: [number 1.2em];"," [def @media] [attribute print] [keyword and] [property color] {"," [property color]: [keyword blue];"," }"," }","}"),r("interpolation",".@{[variable foo]} { [property font-weight]: [atom bold]; }")}();
|
|
|
|
lib/codemirror/mode/css/scss_test.min.js
CHANGED
@@ -1,3 +1 @@
|
|
1 |
-
|
2 |
-
(function(){var mode=CodeMirror.getMode({indentUnit:2},"text/x-scss");function MT(name){test.mode(name,mode,Array.prototype.slice.call(arguments,1),"scss");}
|
3 |
-
MT('url_with_quotation',"[tag foo] { [property background]:[atom url]([string test.jpg]) }");MT('url_with_double_quotes',"[tag foo] { [property background]:[atom url]([string \"test.jpg\"]) }");MT('url_with_single_quotes',"[tag foo] { [property background]:[atom url]([string \'test.jpg\']) }");MT('string',"[def @import] [string \"compass/css3\"]");MT('important_keyword',"[tag foo] { [property background]:[atom url]([string \'test.jpg\']) [keyword !important] }");MT('variable',"[variable-2 $blue]:[atom #333]");MT('variable_as_attribute',"[tag foo] { [property color]:[variable-2 $blue] }");MT('numbers',"[tag foo] { [property padding]:[number 10px] [number 10] [number 10em] [number 8in] }");MT('number_percentage',"[tag foo] { [property width]:[number 80%] }");MT('selector',"[builtin #hello][qualifier .world]{}");MT('singleline_comment',"[comment // this is a comment]");MT('multiline_comment',"[comment /*foobar*/]");MT('attribute_with_hyphen',"[tag foo] { [property font-size]:[number 10px] }");MT('string_after_attribute',"[tag foo] { [property content]:[string \"::\"] }");MT('directives',"[def @include] [qualifier .mixin]");MT('basic_structure',"[tag p] { [property background]:[keyword red]; }");MT('nested_structure',"[tag p] { [tag a] { [property color]:[keyword red]; } }");MT('mixin',"[def @mixin] [tag table-base] {}");MT('number_without_semicolon',"[tag p] {[property width]:[number 12]}","[tag a] {[property color]:[keyword red];}");MT('atom_in_nested_block',"[tag p] { [tag a] { [property color]:[atom #000]; } }");MT('interpolation_in_property',"[tag foo] { #{[variable-2 $hello]}:[number 2]; }");MT('interpolation_in_selector',"[tag foo]#{[variable-2 $hello]} { [property color]:[atom #000]; }");MT('interpolation_error',"[tag foo]#{[variable foo]} { [property color]:[atom #000]; }");MT("divide_operator","[tag foo] { [property width]:[number 4] [operator /] [number 2] }");MT('nested_structure_with_id_selector',"[tag p] { [builtin #hello] { [property color]:[keyword red]; } }");MT('indent_mixin',"[def @mixin] [tag container] ("," [variable-2 $a]: [number 10],"," [variable-2 $b]: [number 10])","{}");MT('indent_nested',"[tag foo] {"," [tag bar] {"," }","}");MT('indent_parentheses',"[tag foo] {"," [property color]: [variable darken]([variable-2 $blue],"," [number 9%]);","}");MT('indent_vardef',"[variable-2 $name]:"," [string 'val'];","[tag tag] {"," [tag inner] {"," [property margin]: [number 3px];"," }","}");})();
|
1 |
+
!function(){function t(t){test.mode(t,r,Array.prototype.slice.call(arguments,1),"scss")}var r=CodeMirror.getMode({indentUnit:2},"text/x-scss");t("url_with_quotation","[tag foo] { [property background]:[atom url]([string test.jpg]) }"),t("url_with_double_quotes",'[tag foo] { [property background]:[atom url]([string "test.jpg"]) }'),t("url_with_single_quotes","[tag foo] { [property background]:[atom url]([string 'test.jpg']) }"),t("string",'[def @import] [string "compass/css3"]'),t("important_keyword","[tag foo] { [property background]:[atom url]([string 'test.jpg']) [keyword !important] }"),t("variable","[variable-2 $blue]:[atom #333]"),t("variable_as_attribute","[tag foo] { [property color]:[variable-2 $blue] }"),t("numbers","[tag foo] { [property padding]:[number 10px] [number 10] [number 10em] [number 8in] }"),t("number_percentage","[tag foo] { [property width]:[number 80%] }"),t("selector","[builtin #hello][qualifier .world]{}"),t("singleline_comment","[comment // this is a comment]"),t("multiline_comment","[comment /*foobar*/]"),t("attribute_with_hyphen","[tag foo] { [property font-size]:[number 10px] }"),t("string_after_attribute",'[tag foo] { [property content]:[string "::"] }'),t("directives","[def @include] [qualifier .mixin]"),t("basic_structure","[tag p] { [property background]:[keyword red]; }"),t("nested_structure","[tag p] { [tag a] { [property color]:[keyword red]; } }"),t("mixin","[def @mixin] [tag table-base] {}"),t("number_without_semicolon","[tag p] {[property width]:[number 12]}","[tag a] {[property color]:[keyword red];}"),t("atom_in_nested_block","[tag p] { [tag a] { [property color]:[atom #000]; } }"),t("interpolation_in_property","[tag foo] { #{[variable-2 $hello]}:[number 2]; }"),t("interpolation_in_selector","[tag foo]#{[variable-2 $hello]} { [property color]:[atom #000]; }"),t("interpolation_error","[tag foo]#{[variable foo]} { [property color]:[atom #000]; }"),t("divide_operator","[tag foo] { [property width]:[number 4] [operator /] [number 2] }"),t("nested_structure_with_id_selector","[tag p] { [builtin #hello] { [property color]:[keyword red]; } }"),t("indent_mixin","[def @mixin] [tag container] ("," [variable-2 $a]: [number 10],"," [variable-2 $b]: [number 10])","{}"),t("indent_nested","[tag foo] {"," [tag bar] {"," }","}"),t("indent_parentheses","[tag foo] {"," [property color]: [variable darken]([variable-2 $blue],"," [number 9%]);","}"),t("indent_vardef","[variable-2 $name]:"," [string 'val'];","[tag tag] {"," [tag inner] {"," [property margin]: [number 3px];"," }","}")}();
|
|
|
|
lib/codemirror/mode/css/test.min.js
CHANGED
@@ -1,3 +1 @@
|
|
1 |
-
|
2 |
-
(function(){var mode=CodeMirror.getMode({indentUnit:2},"css");function MT(name){test.mode(name,mode,Array.prototype.slice.call(arguments,1));}
|
3 |
-
MT("atMediaUnknownType","[def @media] [attribute screen] [keyword and] [error foobarhello] { }");MT("atMediaUnknownProperty","[def @media] [attribute screen] [keyword and] ([error foobarhello]) { }");MT("atMediaMaxWidthNested","[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }");MT("tagSelector","[tag foo] { }");MT("classSelector","[qualifier .foo-bar_hello] { }");MT("idSelector","[builtin #foo] { [error #foo] }");MT("tagSelectorUnclosed","[tag foo] { [property margin]: [number 0] } [tag bar] { }");MT("tagStringNoQuotes","[tag foo] { [property font-family]: [variable hello] [variable world]; }");MT("tagStringDouble","[tag foo] { [property font-family]: [string \"hello world\"]; }");MT("tagStringSingle","[tag foo] { [property font-family]: [string 'hello world']; }");MT("tagColorKeyword","[tag foo] {"," [property color]: [keyword black];"," [property color]: [keyword navy];"," [property color]: [keyword yellow];","}");MT("tagColorHex3","[tag foo] { [property background]: [atom #fff]; }");MT("tagColorHex6","[tag foo] { [property background]: [atom #ffffff]; }");MT("tagColorHex4","[tag foo] { [property background]: [atom&error #ffff]; }");MT("tagColorHexInvalid","[tag foo] { [property background]: [atom&error #ffg]; }");MT("tagNegativeNumber","[tag foo] { [property margin]: [number -5px]; }");MT("tagPositiveNumber","[tag foo] { [property padding]: [number 5px]; }");MT("tagVendor","[tag foo] { [meta -foo-][property box-sizing]: [meta -foo-][atom border-box]; }");MT("tagBogusProperty","[tag foo] { [property&error barhelloworld]: [number 0]; }");MT("tagTwoProperties","[tag foo] { [property margin]: [number 0]; [property padding]: [number 0]; }");MT("tagTwoPropertiesURL","[tag foo] { [property background]: [atom url]([string //example.com/foo.png]); [property padding]: [number 0]; }");MT("commentSGML","[comment <!--comment-->]");MT("commentSGML2","[comment <!--comment]","[comment -->] [tag div] {}");MT("indent_tagSelector","[tag strong], [tag em] {"," [property background]: [atom rgba]("," [number 255], [number 255], [number 0], [number .2]"," );","}");MT("indent_atMedia","[def @media] {"," [tag foo] {"," [property color]:"," [keyword yellow];"," }","}");MT("indent_comma","[tag foo] {"," [property font-family]: [variable verdana],"," [atom sans-serif];","}");MT("indent_parentheses","[tag foo]:[variable-3 before] {"," [property background]: [atom url](","[string blahblah]","[string etc]","[string ]) [keyword !important];","}");MT("font_face","[def @font-face] {"," [property font-family]: [string 'myfont'];"," [error nonsense]: [string 'abc'];"," [property src]: [atom url]([string http://blah]),"," [atom url]([string http://foo]);","}");MT("empty_url","[def @import] [tag url]() [tag screen];");MT("parens","[qualifier .foo] {"," [property background-image]: [variable fade]([atom #000], [number 20%]);"," [property border-image]: [atom linear-gradient]("," [atom to] [atom bottom],"," [variable fade]([atom #000], [number 20%]) [number 0%],"," [variable fade]([atom #000], [number 20%]) [number 100%]"," );","}");MT("css_variable",":[variable-3 root] {"," [variable-2 --main-color]: [atom #06c];","}","[tag h1][builtin #foo] {"," [property color]: [atom var]([variable-2 --main-color]);","}");MT("supports","[def @supports] ([keyword not] (([property text-align-last]: [atom justify]) [keyword or] ([meta -moz-][property text-align-last]: [atom justify])) {"," [property text-align-last]: [atom justify];","}");MT("document","[def @document] [tag url]([string http://blah]),"," [tag url-prefix]([string https://]),"," [tag domain]([string blah.com]),"," [tag regexp]([string \".*blah.+\"]) {"," [builtin #id] {"," [property background-color]: [keyword white];"," }"," [tag foo] {"," [property font-family]: [variable Verdana], [atom sans-serif];"," }"," }");MT("document_url","[def @document] [tag url]([string http://blah]) { [qualifier .class] { } }");MT("document_urlPrefix","[def @document] [tag url-prefix]([string https://]) { [builtin #id] { } }");MT("document_domain","[def @document] [tag domain]([string blah.com]) { [tag foo] { } }");MT("document_regexp","[def @document] [tag regexp]([string \".*blah.+\"]) { [builtin #id] { } }");MT("counter-style","[def @counter-style] [variable binary] {"," [property system]: [atom numeric];"," [property symbols]: [number 0] [number 1];"," [property suffix]: [string \".\"];"," [property range]: [atom infinite];"," [property speak-as]: [atom numeric];","}");MT("counter-style-additive-symbols","[def @counter-style] [variable simple-roman] {"," [property system]: [atom additive];"," [property additive-symbols]: [number 10] [variable X], [number 5] [variable V], [number 1] [variable I];"," [property range]: [number 1] [number 49];","}");MT("counter-style-use","[tag ol][qualifier .roman] { [property list-style]: [variable simple-roman]; }");MT("counter-style-symbols","[tag ol] { [property list-style]: [atom symbols]([atom cyclic] [string \"*\"] [string \"\\2020\"] [string \"\\2021\"] [string \"\\A7\"]); }");})();
|
1 |
+
!function(){function r(r){test.mode(r,o,Array.prototype.slice.call(arguments,1))}var o=CodeMirror.getMode({indentUnit:2},"css");r("atMediaUnknownType","[def @media] [attribute screen] [keyword and] [error foobarhello] { }"),r("atMediaUnknownProperty","[def @media] [attribute screen] [keyword and] ([error foobarhello]) { }"),r("atMediaMaxWidthNested","[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }"),r("tagSelector","[tag foo] { }"),r("classSelector","[qualifier .foo-bar_hello] { }"),r("idSelector","[builtin #foo] { [error #foo] }"),r("tagSelectorUnclosed","[tag foo] { [property margin]: [number 0] } [tag bar] { }"),r("tagStringNoQuotes","[tag foo] { [property font-family]: [variable hello] [variable world]; }"),r("tagStringDouble",'[tag foo] { [property font-family]: [string "hello world"]; }'),r("tagStringSingle","[tag foo] { [property font-family]: [string 'hello world']; }"),r("tagColorKeyword","[tag foo] {"," [property color]: [keyword black];"," [property color]: [keyword navy];"," [property color]: [keyword yellow];","}"),r("tagColorHex3","[tag foo] { [property background]: [atom #fff]; }"),r("tagColorHex6","[tag foo] { [property background]: [atom #ffffff]; }"),r("tagColorHex4","[tag foo] { [property background]: [atom&error #ffff]; }"),r("tagColorHexInvalid","[tag foo] { [property background]: [atom&error #ffg]; }"),r("tagNegativeNumber","[tag foo] { [property margin]: [number -5px]; }"),r("tagPositiveNumber","[tag foo] { [property padding]: [number 5px]; }"),r("tagVendor","[tag foo] { [meta -foo-][property box-sizing]: [meta -foo-][atom border-box]; }"),r("tagBogusProperty","[tag foo] { [property&error barhelloworld]: [number 0]; }"),r("tagTwoProperties","[tag foo] { [property margin]: [number 0]; [property padding]: [number 0]; }"),r("tagTwoPropertiesURL","[tag foo] { [property background]: [atom url]([string //example.com/foo.png]); [property padding]: [number 0]; }"),r("commentSGML","[comment <!--comment-->]"),r("commentSGML2","[comment <!--comment]","[comment -->] [tag div] {}"),r("indent_tagSelector","[tag strong], [tag em] {"," [property background]: [atom rgba]("," [number 255], [number 255], [number 0], [number .2]"," );","}"),r("indent_atMedia","[def @media] {"," [tag foo] {"," [property color]:"," [keyword yellow];"," }","}"),r("indent_comma","[tag foo] {"," [property font-family]: [variable verdana],"," [atom sans-serif];","}"),r("indent_parentheses","[tag foo]:[variable-3 before] {"," [property background]: [atom url](","[string blahblah]","[string etc]","[string ]) [keyword !important];","}"),r("font_face","[def @font-face] {"," [property font-family]: [string 'myfont'];"," [error nonsense]: [string 'abc'];"," [property src]: [atom url]([string http://blah]),"," [atom url]([string http://foo]);","}"),r("empty_url","[def @import] [tag url]() [tag screen];"),r("parens","[qualifier .foo] {"," [property background-image]: [variable fade]([atom #000], [number 20%]);"," [property border-image]: [atom linear-gradient]("," [atom to] [atom bottom],"," [variable fade]([atom #000], [number 20%]) [number 0%],"," [variable fade]([atom #000], [number 20%]) [number 100%]"," );","}"),r("css_variable",":[variable-3 root] {"," [variable-2 --main-color]: [atom #06c];","}","[tag h1][builtin #foo] {"," [property color]: [atom var]([variable-2 --main-color]);","}"),r("supports","[def @supports] ([keyword not] (([property text-align-last]: [atom justify]) [keyword or] ([meta -moz-][property text-align-last]: [atom justify])) {"," [property text-align-last]: [atom justify];","}"),r("document","[def @document] [tag url]([string http://blah]),"," [tag url-prefix]([string https://]),"," [tag domain]([string blah.com]),",' [tag regexp]([string ".*blah.+"]) {'," [builtin #id] {"," [property background-color]: [keyword white];"," }"," [tag foo] {"," [property font-family]: [variable Verdana], [atom sans-serif];"," }"," }"),r("document_url","[def @document] [tag url]([string http://blah]) { [qualifier .class] { } }"),r("document_urlPrefix","[def @document] [tag url-prefix]([string https://]) { [builtin #id] { } }"),r("document_domain","[def @document] [tag domain]([string blah.com]) { [tag foo] { } }"),r("document_regexp",'[def @document] [tag regexp]([string ".*blah.+"]) { [builtin #id] { } }'),r("counter-style","[def @counter-style] [variable binary] {"," [property system]: [atom numeric];"," [property symbols]: [number 0] [number 1];",' [property suffix]: [string "."];'," [property range]: [atom infinite];"," [property speak-as]: [atom numeric];","}"),r("counter-style-additive-symbols","[def @counter-style] [variable simple-roman] {"," [property system]: [atom additive];"," [property additive-symbols]: [number 10] [variable X], [number 5] [variable V], [number 1] [variable I];"," [property range]: [number 1] [number 49];","}"),r("counter-style-use","[tag ol][qualifier .roman] { [property list-style]: [variable simple-roman]; }"),r("counter-style-symbols",'[tag ol] { [property list-style]: [atom symbols]([atom cyclic] [string "*"] [string "\\2020"] [string "\\2021"] [string "\\A7"]); }')}();
|
|
|
|
lib/codemirror/mode/sass/sass.min.js
CHANGED
@@ -1,67 +1 @@
|
|
1 |
-
|
2 |
-
(function(mod){if(typeof exports=="object"&&typeof module=="object")
|
3 |
-
mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)
|
4 |
-
define(["../../lib/codemirror"],mod);else
|
5 |
-
mod(CodeMirror);})(function(CodeMirror){"use strict";CodeMirror.defineMode("sass",function(config){function tokenRegexp(words){return new RegExp("^"+words.join("|"));}
|
6 |
-
var keywords=["true","false","null","auto"];var keywordsRegexp=new RegExp("^"+keywords.join("|"));var operators=["\\(","\\)","=",">","<","==",">=","<=","\\+","-","\\!=","/","\\*","%","and","or","not",";","\\{","\\}",":"];var opRegexp=tokenRegexp(operators);var pseudoElementsRegexp=/^::?[a-zA-Z_][\w\-]*/;function urlTokens(stream,state){var ch=stream.peek();if(ch===")"){stream.next();state.tokenizer=tokenBase;return"operator";}else if(ch==="("){stream.next();stream.eatSpace();return"operator";}else if(ch==="'"||ch==='"'){state.tokenizer=buildStringTokenizer(stream.next());return"string";}else{state.tokenizer=buildStringTokenizer(")",false);return"string";}}
|
7 |
-
function comment(indentation,multiLine){return function(stream,state){if(stream.sol()&&stream.indentation()<=indentation){state.tokenizer=tokenBase;return tokenBase(stream,state);}
|
8 |
-
if(multiLine&&stream.skipTo("*/")){stream.next();stream.next();state.tokenizer=tokenBase;}else{stream.skipToEnd();}
|
9 |
-
return"comment";};}
|
10 |
-
function buildStringTokenizer(quote,greedy){if(greedy==null){greedy=true;}
|
11 |
-
function stringTokenizer(stream,state){var nextChar=stream.next();var peekChar=stream.peek();var previousChar=stream.string.charAt(stream.pos-2);var endingString=((nextChar!=="\\"&&peekChar===quote)||(nextChar===quote&&previousChar!=="\\"));if(endingString){if(nextChar!==quote&&greedy){stream.next();}
|
12 |
-
state.tokenizer=tokenBase;return"string";}else if(nextChar==="#"&&peekChar==="{"){state.tokenizer=buildInterpolationTokenizer(stringTokenizer);stream.next();return"operator";}else{return"string";}}
|
13 |
-
return stringTokenizer;}
|
14 |
-
function buildInterpolationTokenizer(currentTokenizer){return function(stream,state){if(stream.peek()==="}"){stream.next();state.tokenizer=currentTokenizer;return"operator";}else{return tokenBase(stream,state);}};}
|
15 |
-
function indent(state){if(state.indentCount==0){state.indentCount++;var lastScopeOffset=state.scopes[0].offset;var currentOffset=lastScopeOffset+config.indentUnit;state.scopes.unshift({offset:currentOffset});}}
|
16 |
-
function dedent(state){if(state.scopes.length==1)return;state.scopes.shift();}
|
17 |
-
function tokenBase(stream,state){var ch=stream.peek();if(stream.match("/*")){state.tokenizer=comment(stream.indentation(),true);return state.tokenizer(stream,state);}
|
18 |
-
if(stream.match("//")){state.tokenizer=comment(stream.indentation(),false);return state.tokenizer(stream,state);}
|
19 |
-
if(stream.match("#{")){state.tokenizer=buildInterpolationTokenizer(tokenBase);return"operator";}
|
20 |
-
if(ch==='"'||ch==="'"){stream.next();state.tokenizer=buildStringTokenizer(ch);return"string";}
|
21 |
-
if(!state.cursorHalf){if(ch==="."){stream.next();if(stream.match(/^[\w-]+/)){indent(state);return"atom";}else if(stream.peek()==="#"){indent(state);return"atom";}}
|
22 |
-
if(ch==="#"){stream.next();if(stream.match(/^[\w-]+/)){indent(state);return"atom";}
|
23 |
-
if(stream.peek()==="#"){indent(state);return"atom";}}
|
24 |
-
if(ch==="$"){stream.next();stream.eatWhile(/[\w-]/);return"variable-2";}
|
25 |
-
if(stream.match(/^-?[0-9\.]+/))
|
26 |
-
return"number";if(stream.match(/^(px|em|in)\b/))
|
27 |
-
return"unit";if(stream.match(keywordsRegexp))
|
28 |
-
return"keyword";if(stream.match(/^url/)&&stream.peek()==="("){state.tokenizer=urlTokens;return"atom";}
|
29 |
-
if(ch==="="){if(stream.match(/^=[\w-]+/)){indent(state);return"meta";}}
|
30 |
-
if(ch==="+"){if(stream.match(/^\+[\w-]+/)){return"variable-3";}}
|
31 |
-
if(ch==="@"){if(stream.match(/@extend/)){if(!stream.match(/\s*[\w]/))
|
32 |
-
dedent(state);}}
|
33 |
-
if(stream.match(/^@(else if|if|media|else|for|each|while|mixin|function)/)){indent(state);return"meta";}
|
34 |
-
if(ch==="@"){stream.next();stream.eatWhile(/[\w-]/);return"meta";}
|
35 |
-
if(stream.eatWhile(/[\w-]/)){if(stream.match(/ *: *[\w-\+\$#!\("']/,false)){return"property";}
|
36 |
-
else if(stream.match(/ *:/,false)){indent(state);state.cursorHalf=1;return"atom";}
|
37 |
-
else if(stream.match(/ *,/,false)){return"atom";}
|
38 |
-
else{indent(state);return"atom";}}
|
39 |
-
if(ch===":"){if(stream.match(pseudoElementsRegexp)){return"keyword";}
|
40 |
-
stream.next();state.cursorHalf=1;return"operator";}}
|
41 |
-
else{if(ch==="#"){stream.next();if(stream.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/)){if(!stream.peek()){state.cursorHalf=0;}
|
42 |
-
return"number";}}
|
43 |
-
if(stream.match(/^-?[0-9\.]+/)){if(!stream.peek()){state.cursorHalf=0;}
|
44 |
-
return"number";}
|
45 |
-
if(stream.match(/^(px|em|in)\b/)){if(!stream.peek()){state.cursorHalf=0;}
|
46 |
-
return"unit";}
|
47 |
-
if(stream.match(keywordsRegexp)){if(!stream.peek()){state.cursorHalf=0;}
|
48 |
-
return"keyword";}
|
49 |
-
if(stream.match(/^url/)&&stream.peek()==="("){state.tokenizer=urlTokens;if(!stream.peek()){state.cursorHalf=0;}
|
50 |
-
return"atom";}
|
51 |
-
if(ch==="$"){stream.next();stream.eatWhile(/[\w-]/);if(!stream.peek()){state.cursorHalf=0;}
|
52 |
-
return"variable-3";}
|
53 |
-
if(ch==="!"){stream.next();if(!stream.peek()){state.cursorHalf=0;}
|
54 |
-
return stream.match(/^[\w]+/)?"keyword":"operator";}
|
55 |
-
if(stream.match(opRegexp)){if(!stream.peek()){state.cursorHalf=0;}
|
56 |
-
return"operator";}
|
57 |
-
if(stream.eatWhile(/[\w-]/)){if(!stream.peek()){state.cursorHalf=0;}
|
58 |
-
return"attribute";}
|
59 |
-
if(!stream.peek()){state.cursorHalf=0;return null;}}
|
60 |
-
if(stream.match(opRegexp))
|
61 |
-
return"operator";stream.next();return null;}
|
62 |
-
function tokenLexer(stream,state){if(stream.sol())state.indentCount=0;var style=state.tokenizer(stream,state);var current=stream.current();if(current==="@return"||current==="}"){dedent(state);}
|
63 |
-
if(style!==null){var startOfToken=stream.pos-current.length;var withCurrentIndent=startOfToken+(config.indentUnit*state.indentCount);var newScopes=[];for(var i=0;i<state.scopes.length;i++){var scope=state.scopes[i];if(scope.offset<=withCurrentIndent)
|
64 |
-
newScopes.push(scope);}
|
65 |
-
state.scopes=newScopes;}
|
66 |
-
return style;}
|
67 |
-
return{startState:function(){return{tokenizer:tokenBase,scopes:[{offset:0,type:"sass"}],indentCount:0,cursorHalf:0,definedVars:[],definedMixins:[]};},token:function(stream,state){var style=tokenLexer(stream,state);state.lastToken={style:style,content:stream.current()};return style;},indent:function(state){return state.scopes[0].offset;}};});CodeMirror.defineMIME("text/x-sass","sass");});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.defineMode("sass",function(e){function t(e){return new RegExp("^"+e.join("|"))}function r(e,t){var r=e.peek();return")"===r?(e.next(),t.tokenizer=f,"operator"):"("===r?(e.next(),e.eatSpace(),"operator"):"'"===r||'"'===r?(t.tokenizer=o(e.next()),"string"):(t.tokenizer=o(")",!1),"string")}function n(e,t){return function(r,n){return r.sol()&&r.indentation()<=e?(n.tokenizer=f,f(r,n)):(t&&r.skipTo("*/")?(r.next(),r.next(),n.tokenizer=f):r.skipToEnd(),"comment")}}function o(e,t){function r(n,o){var a=n.next(),u=n.peek(),c=n.string.charAt(n.pos-2),s="\\"!==a&&u===e||a===e&&"\\"!==c;return s?(a!==e&&t&&n.next(),o.tokenizer=f,"string"):"#"===a&&"{"===u?(o.tokenizer=i(r),n.next(),"operator"):"string"}return null==t&&(t=!0),r}function i(e){return function(t,r){return"}"===t.peek()?(t.next(),r.tokenizer=e,"operator"):f(t,r)}}function a(t){if(0==t.indentCount){t.indentCount++;var r=t.scopes[0].offset,n=r+e.indentUnit;t.scopes.unshift({offset:n})}}function u(e){1!=e.scopes.length&&e.scopes.shift()}function f(e,t){var c=e.peek();if(e.match("/*"))return t.tokenizer=n(e.indentation(),!0),t.tokenizer(e,t);if(e.match("//"))return t.tokenizer=n(e.indentation(),!1),t.tokenizer(e,t);if(e.match("#{"))return t.tokenizer=i(f),"operator";if('"'===c||"'"===c)return e.next(),t.tokenizer=o(c),"string";if(t.cursorHalf){if("#"===c&&(e.next(),e.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/)))return e.peek()||(t.cursorHalf=0),"number";if(e.match(/^-?[0-9\.]+/))return e.peek()||(t.cursorHalf=0),"number";if(e.match(/^(px|em|in)\b/))return e.peek()||(t.cursorHalf=0),"unit";if(e.match(p))return e.peek()||(t.cursorHalf=0),"keyword";if(e.match(/^url/)&&"("===e.peek())return t.tokenizer=r,e.peek()||(t.cursorHalf=0),"atom";if("$"===c)return e.next(),e.eatWhile(/[\w-]/),e.peek()||(t.cursorHalf=0),"variable-3";if("!"===c)return e.next(),e.peek()||(t.cursorHalf=0),e.match(/^[\w]+/)?"keyword":"operator";if(e.match(l))return e.peek()||(t.cursorHalf=0),"operator";if(e.eatWhile(/[\w-]/))return e.peek()||(t.cursorHalf=0),"attribute";if(!e.peek())return t.cursorHalf=0,null}else{if("."===c){if(e.next(),e.match(/^[\w-]+/))return a(t),"atom";if("#"===e.peek())return a(t),"atom"}if("#"===c){if(e.next(),e.match(/^[\w-]+/))return a(t),"atom";if("#"===e.peek())return a(t),"atom"}if("$"===c)return e.next(),e.eatWhile(/[\w-]/),"variable-2";if(e.match(/^-?[0-9\.]+/))return"number";if(e.match(/^(px|em|in)\b/))return"unit";if(e.match(p))return"keyword";if(e.match(/^url/)&&"("===e.peek())return t.tokenizer=r,"atom";if("="===c&&e.match(/^=[\w-]+/))return a(t),"meta";if("+"===c&&e.match(/^\+[\w-]+/))return"variable-3";if("@"===c&&e.match(/@extend/)&&(e.match(/\s*[\w]/)||u(t)),e.match(/^@(else if|if|media|else|for|each|while|mixin|function)/))return a(t),"meta";if("@"===c)return e.next(),e.eatWhile(/[\w-]/),"meta";if(e.eatWhile(/[\w-]/))return e.match(/ *: *[\w-\+\$#!\("']/,!1)?"property":e.match(/ *:/,!1)?(a(t),t.cursorHalf=1,"atom"):e.match(/ *,/,!1)?"atom":(a(t),"atom");if(":"===c)return e.match(k)?"keyword":(e.next(),t.cursorHalf=1,"operator")}return e.match(l)?"operator":(e.next(),null)}function c(t,r){t.sol()&&(r.indentCount=0);var n=r.tokenizer(t,r),o=t.current();if(("@return"===o||"}"===o)&&u(r),null!==n){for(var i=t.pos-o.length,a=i+e.indentUnit*r.indentCount,f=[],c=0;c<r.scopes.length;c++){var s=r.scopes[c];s.offset<=a&&f.push(s)}r.scopes=f}return n}var s=["true","false","null","auto"],p=new RegExp("^"+s.join("|")),m=["\\(","\\)","=",">","<","==",">=","<=","\\+","-","\\!=","/","\\*","%","and","or","not",";","\\{","\\}",":"],l=t(m),k=/^::?[a-zA-Z_][\w\-]*/;return{startState:function(){return{tokenizer:f,scopes:[{offset:0,type:"sass"}],indentCount:0,cursorHalf:0,definedVars:[],definedMixins:[]}},token:function(e,t){var r=c(e,t);return t.lastToken={style:r,content:e.current()},r},indent:function(e){return e.scopes[0].offset}}}),e.defineMIME("text/x-sass","sass")});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/minicolors/jquery.minicolors.min.js
CHANGED
@@ -1,49 +1 @@
|
|
1 |
-
|
2 |
-
(function($){$.minicolors={defaults:{animationSpeed:50,animationEasing:'swing',change:null,changeDelay:0,control:'hue',dataUris:true,defaultValue:'',hide:null,hideSpeed:100,inline:false,letterCase:'lowercase',opacity:false,position:'bottom left',show:null,showSpeed:100,theme:'default'}};$.extend($.fn,{minicolors:function(method,data){switch(method){case'destroy':$(this).each(function(){destroy($(this));});return $(this);case'hide':hide();return $(this);case'opacity':if(data===undefined){return $(this).attr('data-opacity');}else{$(this).each(function(){updateFromInput($(this).attr('data-opacity',data));});}
|
3 |
-
return $(this);case'rgbObject':return rgbObject($(this),method==='rgbaObject');case'rgbString':case'rgbaString':return rgbString($(this),method==='rgbaString');case'settings':if(data===undefined){return $(this).data('minicolors-settings');}else{$(this).each(function(){var settings=$(this).data('minicolors-settings')||{};destroy($(this));$(this).minicolors($.extend(true,settings,data));});}
|
4 |
-
return $(this);case'show':show($(this).eq(0));return $(this);case'value':if(data===undefined){return $(this).val();}else{$(this).each(function(){updateFromInput($(this).val(data));});}
|
5 |
-
return $(this);default:if(method!=='create')data=method;$(this).each(function(){init($(this),data);});return $(this);}}});function init(input,settings){var minicolors=$('<div class="minicolors" />'),defaults=$.minicolors.defaults;if(input.data('minicolors-initialized'))return;settings=$.extend(true,{},defaults,settings);minicolors.addClass('minicolors-theme-'+settings.theme).toggleClass('minicolors-with-opacity',settings.opacity).toggleClass('minicolors-no-data-uris',settings.dataUris!==true);if(settings.position!==undefined){$.each(settings.position.split(' '),function(){minicolors.addClass('minicolors-position-'+this);});}
|
6 |
-
input.addClass('minicolors-input').data('minicolors-initialized',false).data('minicolors-settings',settings).prop('size',7).wrap(minicolors).after('<div class="minicolors-panel minicolors-slider-'+settings.control+'">'+'<div class="minicolors-slider minicolors-sprite">'+'<div class="minicolors-picker"></div>'+'</div>'+'<div class="minicolors-opacity-slider minicolors-sprite">'+'<div class="minicolors-picker"></div>'+'</div>'+'<div class="minicolors-grid minicolors-sprite">'+'<div class="minicolors-grid-inner"></div>'+'<div class="minicolors-picker"><div></div></div>'+'</div>'+'</div>');if(!settings.inline){input.after('<span class="minicolors-swatch minicolors-sprite"><span class="minicolors-swatch-color"></span></span>');input.next('.minicolors-swatch').on('click',function(event){event.preventDefault();input.focus();});}
|
7 |
-
input.parent().find('.minicolors-panel').on('selectstart',function(){return false;}).end();if(settings.inline)input.parent().addClass('minicolors-inline');updateFromInput(input,false);input.data('minicolors-initialized',true);}
|
8 |
-
function destroy(input){var minicolors=input.parent();input.removeData('minicolors-initialized').removeData('minicolors-settings').removeProp('size').removeClass('minicolors-input');minicolors.before(input).remove();}
|
9 |
-
function show(input){var minicolors=input.parent(),panel=minicolors.find('.minicolors-panel'),settings=input.data('minicolors-settings');if(!input.data('minicolors-initialized')||input.prop('disabled')||minicolors.hasClass('minicolors-inline')||minicolors.hasClass('minicolors-focus'))return;hide();minicolors.addClass('minicolors-focus');panel.stop(true,true).fadeIn(settings.showSpeed,function(){if(settings.show)settings.show.call(input.get(0));});}
|
10 |
-
function hide(){$('.minicolors-focus').each(function(){var minicolors=$(this),input=minicolors.find('.minicolors-input'),panel=minicolors.find('.minicolors-panel'),settings=input.data('minicolors-settings');panel.fadeOut(settings.hideSpeed,function(){if(settings.hide)settings.hide.call(input.get(0));minicolors.removeClass('minicolors-focus');});});}
|
11 |
-
function move(target,event,animate){var input=target.parents('.minicolors').find('.minicolors-input'),settings=input.data('minicolors-settings'),picker=target.find('[class$=-picker]'),offsetX=target.offset().left,offsetY=target.offset().top,x=Math.round(event.pageX-offsetX),y=Math.round(event.pageY-offsetY),duration=animate?settings.animationSpeed:0,wx,wy,r,phi;if(event.originalEvent.changedTouches){x=event.originalEvent.changedTouches[0].pageX-offsetX;y=event.originalEvent.changedTouches[0].pageY-offsetY;}
|
12 |
-
if(x<0)x=0;if(y<0)y=0;if(x>target.width())x=target.width();if(y>target.height())y=target.height();if(target.parent().is('.minicolors-slider-wheel')&&picker.parent().is('.minicolors-grid')){wx=75-x;wy=75-y;r=Math.sqrt(wx*wx+wy*wy);phi=Math.atan2(wy,wx);if(phi<0)phi+=Math.PI*2;if(r>75){r=75;x=75-(75*Math.cos(phi));y=75-(75*Math.sin(phi));}
|
13 |
-
x=Math.round(x);y=Math.round(y);}
|
14 |
-
if(target.is('.minicolors-grid')){picker.stop(true).animate({top:y+'px',left:x+'px'},duration,settings.animationEasing,function(){updateFromControl(input,target);});}else{picker.stop(true).animate({top:y+'px'},duration,settings.animationEasing,function(){updateFromControl(input,target);});}}
|
15 |
-
function updateFromControl(input,target){function getCoords(picker,container){var left,top;if(!picker.length||!container)return null;left=picker.offset().left;top=picker.offset().top;return{x:left-container.offset().left+(picker.outerWidth()/2),y:top-container.offset().top+(picker.outerHeight()/2)};}
|
16 |
-
var hue,saturation,brightness,x,y,r,phi,hex=input.val(),opacity=input.attr('data-opacity'),minicolors=input.parent(),settings=input.data('minicolors-settings'),swatch=minicolors.find('.minicolors-swatch'),grid=minicolors.find('.minicolors-grid'),slider=minicolors.find('.minicolors-slider'),opacitySlider=minicolors.find('.minicolors-opacity-slider'),gridPicker=grid.find('[class$=-picker]'),sliderPicker=slider.find('[class$=-picker]'),opacityPicker=opacitySlider.find('[class$=-picker]'),gridPos=getCoords(gridPicker,grid),sliderPos=getCoords(sliderPicker,slider),opacityPos=getCoords(opacityPicker,opacitySlider);if(target.is('.minicolors-grid, .minicolors-slider')){switch(settings.control){case'wheel':x=(grid.width()/2)-gridPos.x;y=(grid.height()/2)-gridPos.y;r=Math.sqrt(x*x+y*y);phi=Math.atan2(y,x);if(phi<0)phi+=Math.PI*2;if(r>75){r=75;gridPos.x=69-(75*Math.cos(phi));gridPos.y=69-(75*Math.sin(phi));}
|
17 |
-
saturation=keepWithin(r/0.75,0,100);hue=keepWithin(phi*180/Math.PI,0,360);brightness=keepWithin(100-Math.floor(sliderPos.y*(100/slider.height())),0,100);hex=hsb2hex({h:hue,s:saturation,b:brightness});slider.css('backgroundColor',hsb2hex({h:hue,s:saturation,b:100}));break;case'saturation':hue=keepWithin(parseInt(gridPos.x*(360/grid.width()),10),0,360);saturation=keepWithin(100-Math.floor(sliderPos.y*(100/slider.height())),0,100);brightness=keepWithin(100-Math.floor(gridPos.y*(100/grid.height())),0,100);hex=hsb2hex({h:hue,s:saturation,b:brightness});slider.css('backgroundColor',hsb2hex({h:hue,s:100,b:brightness}));minicolors.find('.minicolors-grid-inner').css('opacity',saturation/100);break;case'brightness':hue=keepWithin(parseInt(gridPos.x*(360/grid.width()),10),0,360);saturation=keepWithin(100-Math.floor(gridPos.y*(100/grid.height())),0,100);brightness=keepWithin(100-Math.floor(sliderPos.y*(100/slider.height())),0,100);hex=hsb2hex({h:hue,s:saturation,b:brightness});slider.css('backgroundColor',hsb2hex({h:hue,s:saturation,b:100}));minicolors.find('.minicolors-grid-inner').css('opacity',1-(brightness/100));break;default:hue=keepWithin(360-parseInt(sliderPos.y*(360/slider.height()),10),0,360);saturation=keepWithin(Math.floor(gridPos.x*(100/grid.width())),0,100);brightness=keepWithin(100-Math.floor(gridPos.y*(100/grid.height())),0,100);hex=hsb2hex({h:hue,s:saturation,b:brightness});grid.css('backgroundColor',hsb2hex({h:hue,s:100,b:100}));break;}
|
18 |
-
input.val(convertCase(hex,settings.letterCase));}
|
19 |
-
if(target.is('.minicolors-opacity-slider')){if(settings.opacity){opacity=parseFloat(1-(opacityPos.y/opacitySlider.height())).toFixed(2);}else{opacity=1;}
|
20 |
-
if(settings.opacity)input.attr('data-opacity',opacity);}
|
21 |
-
swatch.find('SPAN').css({backgroundColor:hex,opacity:opacity});doChange(input,hex,opacity);}
|
22 |
-
function updateFromInput(input,preserveInputValue){var hex,hsb,opacity,x,y,r,phi,minicolors=input.parent(),settings=input.data('minicolors-settings'),swatch=minicolors.find('.minicolors-swatch'),grid=minicolors.find('.minicolors-grid'),slider=minicolors.find('.minicolors-slider'),opacitySlider=minicolors.find('.minicolors-opacity-slider'),gridPicker=grid.find('[class$=-picker]'),sliderPicker=slider.find('[class$=-picker]'),opacityPicker=opacitySlider.find('[class$=-picker]');hex=convertCase(parseHex(input.val(),true),settings.letterCase);if(!hex){hex=convertCase(parseHex(settings.defaultValue,true),settings.letterCase);}
|
23 |
-
hsb=hex2hsb(hex);if(!preserveInputValue)input.val(hex);if(settings.opacity){opacity=input.attr('data-opacity')===''?1:keepWithin(parseFloat(input.attr('data-opacity')).toFixed(2),0,1);if(isNaN(opacity))opacity=1;input.attr('data-opacity',opacity);swatch.find('SPAN').css('opacity',opacity);y=keepWithin(opacitySlider.height()-(opacitySlider.height()*opacity),0,opacitySlider.height());opacityPicker.css('top',y+'px');}
|
24 |
-
swatch.find('SPAN').css('backgroundColor',hex);switch(settings.control){case'wheel':r=keepWithin(Math.ceil(hsb.s*0.75),0,grid.height()/2);phi=hsb.h*Math.PI/180;x=keepWithin(75-Math.cos(phi)*r,0,grid.width());y=keepWithin(75-Math.sin(phi)*r,0,grid.height());gridPicker.css({top:y+'px',left:x+'px'});y=150-(hsb.b/(100/grid.height()));if(hex==='')y=0;sliderPicker.css('top',y+'px');slider.css('backgroundColor',hsb2hex({h:hsb.h,s:hsb.s,b:100}));break;case'saturation':x=keepWithin((5*hsb.h)/12,0,150);y=keepWithin(grid.height()-Math.ceil(hsb.b/(100/grid.height())),0,grid.height());gridPicker.css({top:y+'px',left:x+'px'});y=keepWithin(slider.height()-(hsb.s*(slider.height()/100)),0,slider.height());sliderPicker.css('top',y+'px');slider.css('backgroundColor',hsb2hex({h:hsb.h,s:100,b:hsb.b}));minicolors.find('.minicolors-grid-inner').css('opacity',hsb.s/100);break;case'brightness':x=keepWithin((5*hsb.h)/12,0,150);y=keepWithin(grid.height()-Math.ceil(hsb.s/(100/grid.height())),0,grid.height());gridPicker.css({top:y+'px',left:x+'px'});y=keepWithin(slider.height()-(hsb.b*(slider.height()/100)),0,slider.height());sliderPicker.css('top',y+'px');slider.css('backgroundColor',hsb2hex({h:hsb.h,s:hsb.s,b:100}));minicolors.find('.minicolors-grid-inner').css('opacity',1-(hsb.b/100));break;default:x=keepWithin(Math.ceil(hsb.s/(100/grid.width())),0,grid.width());y=keepWithin(grid.height()-Math.ceil(hsb.b/(100/grid.height())),0,grid.height());gridPicker.css({top:y+'px',left:x+'px'});y=keepWithin(slider.height()-(hsb.h/(360/slider.height())),0,slider.height());sliderPicker.css('top',y+'px');grid.css('backgroundColor',hsb2hex({h:hsb.h,s:100,b:100}));break;}
|
25 |
-
if(input.data('minicolors-initialized')){doChange(input,hex,opacity);}}
|
26 |
-
function doChange(input,hex,opacity){var settings=input.data('minicolors-settings'),lastChange=input.data('minicolors-lastChange');if(!lastChange||lastChange.hex!==hex||lastChange.opacity!==opacity){input.data('minicolors-lastChange',{hex:hex,opacity:opacity});if(settings.change){if(settings.changeDelay){clearTimeout(input.data('minicolors-changeTimeout'));input.data('minicolors-changeTimeout',setTimeout(function(){settings.change.call(input.get(0),hex,opacity);},settings.changeDelay));}else{settings.change.call(input.get(0),hex,opacity);}}
|
27 |
-
input.trigger('change').trigger('input');}}
|
28 |
-
function rgbObject(input){var hex=parseHex($(input).val(),true),rgb=hex2rgb(hex),opacity=$(input).attr('data-opacity');if(!rgb)return null;if(opacity!==undefined)$.extend(rgb,{a:parseFloat(opacity)});return rgb;}
|
29 |
-
function rgbString(input,alpha){var hex=parseHex($(input).val(),true),rgb=hex2rgb(hex),opacity=$(input).attr('data-opacity');if(!rgb)return null;if(opacity===undefined)opacity=1;if(alpha){return'rgba('+rgb.r+', '+rgb.g+', '+rgb.b+', '+parseFloat(opacity)+')';}else{return'rgb('+rgb.r+', '+rgb.g+', '+rgb.b+')';}}
|
30 |
-
function convertCase(string,letterCase){return letterCase==='uppercase'?string.toUpperCase():string.toLowerCase();}
|
31 |
-
function parseHex(string,expand){string=string.replace(/[^A-F0-9]/ig,'');if(string.length!==3&&string.length!==6)return'';if(string.length===3&&expand){string=string[0]+string[0]+string[1]+string[1]+string[2]+string[2];}
|
32 |
-
return'#'+string;}
|
33 |
-
function keepWithin(value,min,max){if(value<min)value=min;if(value>max)value=max;return value;}
|
34 |
-
function hsb2rgb(hsb){var rgb={};var h=Math.round(hsb.h);var s=Math.round(hsb.s*255/100);var v=Math.round(hsb.b*255/100);if(s===0){rgb.r=rgb.g=rgb.b=v;}else{var t1=v;var t2=(255-s)*v/255;var t3=(t1-t2)*(h%60)/60;if(h===360)h=0;if(h<60){rgb.r=t1;rgb.b=t2;rgb.g=t2+t3;}
|
35 |
-
else if(h<120){rgb.g=t1;rgb.b=t2;rgb.r=t1-t3;}
|
36 |
-
else if(h<180){rgb.g=t1;rgb.r=t2;rgb.b=t2+t3;}
|
37 |
-
else if(h<240){rgb.b=t1;rgb.r=t2;rgb.g=t1-t3;}
|
38 |
-
else if(h<300){rgb.b=t1;rgb.g=t2;rgb.r=t2+t3;}
|
39 |
-
else if(h<360){rgb.r=t1;rgb.g=t2;rgb.b=t1-t3;}
|
40 |
-
else{rgb.r=0;rgb.g=0;rgb.b=0;}}
|
41 |
-
return{r:Math.round(rgb.r),g:Math.round(rgb.g),b:Math.round(rgb.b)};}
|
42 |
-
function rgb2hex(rgb){var hex=[rgb.r.toString(16),rgb.g.toString(16),rgb.b.toString(16)];$.each(hex,function(nr,val){if(val.length===1)hex[nr]='0'+val;});return'#'+hex.join('');}
|
43 |
-
function hsb2hex(hsb){return rgb2hex(hsb2rgb(hsb));}
|
44 |
-
function hex2hsb(hex){var hsb=rgb2hsb(hex2rgb(hex));if(hsb.s===0)hsb.h=360;return hsb;}
|
45 |
-
function rgb2hsb(rgb){var hsb={h:0,s:0,b:0};var min=Math.min(rgb.r,rgb.g,rgb.b);var max=Math.max(rgb.r,rgb.g,rgb.b);var delta=max-min;hsb.b=max;hsb.s=max!==0?255*delta/max:0;if(hsb.s!==0){if(rgb.r===max){hsb.h=(rgb.g-rgb.b)/delta;}else if(rgb.g===max){hsb.h=2+(rgb.b-rgb.r)/delta;}else{hsb.h=4+(rgb.r-rgb.g)/delta;}}else{hsb.h=-1;}
|
46 |
-
hsb.h*=60;if(hsb.h<0){hsb.h+=360;}
|
47 |
-
hsb.s*=100/255;hsb.b*=100/255;return hsb;}
|
48 |
-
function hex2rgb(hex){hex=parseInt(((hex.indexOf('#')>-1)?hex.substring(1):hex),16);return{r:hex>>16,g:(hex&0x00FF00)>>8,b:(hex&0x0000FF)};}
|
49 |
-
$(document).on('mousedown.minicolors touchstart.minicolors',function(event){if(!$(event.target).parents().add(event.target).hasClass('minicolors')){hide();}}).on('mousedown.minicolors touchstart.minicolors','.minicolors-grid, .minicolors-slider, .minicolors-opacity-slider',function(event){var target=$(this);event.preventDefault();$(document).data('minicolors-target',target);move(target,event,true);}).on('mousemove.minicolors touchmove.minicolors',function(event){var target=$(document).data('minicolors-target');if(target)move(target,event);}).on('mouseup.minicolors touchend.minicolors',function(){$(this).removeData('minicolors-target');}).on('mousedown.minicolors touchstart.minicolors','.minicolors-swatch',function(event){var input=$(this).parent().find('.minicolors-input');event.preventDefault();show(input);}).on('focus.minicolors','.minicolors-input',function(){var input=$(this);if(!input.data('minicolors-initialized'))return;show(input);}).on('blur.minicolors','.minicolors-input',function(){var input=$(this),settings=input.data('minicolors-settings');if(!input.data('minicolors-initialized'))return;input.val(parseHex(input.val(),true));if(input.val()==='')input.val(parseHex(settings.defaultValue,true));input.val(convertCase(input.val(),settings.letterCase));}).on('keydown.minicolors','.minicolors-input',function(event){var input=$(this);if(!input.data('minicolors-initialized'))return;switch(event.keyCode){case 9:hide();break;case 13:case 27:hide();input.blur();break;}}).on('keyup.minicolors','.minicolors-input',function(){var input=$(this);if(!input.data('minicolors-initialized'))return;updateFromInput(input,true);}).on('paste.minicolors','.minicolors-input',function(){var input=$(this);if(!input.data('minicolors-initialized'))return;setTimeout(function(){updateFromInput(input,true);},1);});})(jQuery);
|
1 |
+
!function(i){function t(t,o){var n=i('<div class="minicolors" />'),s=i.minicolors.defaults;t.data("minicolors-initialized")||(o=i.extend(!0,{},s,o),n.addClass("minicolors-theme-"+o.theme).toggleClass("minicolors-with-opacity",o.opacity).toggleClass("minicolors-no-data-uris",o.dataUris!==!0),void 0!==o.position&&i.each(o.position.split(" "),function(){n.addClass("minicolors-position-"+this)}),t.addClass("minicolors-input").data("minicolors-initialized",!1).data("minicolors-settings",o).prop("size",7).wrap(n).after('<div class="minicolors-panel minicolors-slider-'+o.control+'"><div class="minicolors-slider minicolors-sprite"><div class="minicolors-picker"></div></div><div class="minicolors-opacity-slider minicolors-sprite"><div class="minicolors-picker"></div></div><div class="minicolors-grid minicolors-sprite"><div class="minicolors-grid-inner"></div><div class="minicolors-picker"><div></div></div></div></div>'),o.inline||(t.after('<span class="minicolors-swatch minicolors-sprite"><span class="minicolors-swatch-color"></span></span>'),t.next(".minicolors-swatch").on("click",function(i){i.preventDefault(),t.focus()})),t.parent().find(".minicolors-panel").on("selectstart",function(){return!1}).end(),o.inline&&t.parent().addClass("minicolors-inline"),r(t,!1),t.data("minicolors-initialized",!0))}function o(i){var t=i.parent();i.removeData("minicolors-initialized").removeData("minicolors-settings").removeProp("size").removeClass("minicolors-input"),t.before(i).remove()}function n(i){var t=i.parent(),o=t.find(".minicolors-panel"),n=i.data("minicolors-settings");!i.data("minicolors-initialized")||i.prop("disabled")||t.hasClass("minicolors-inline")||t.hasClass("minicolors-focus")||(s(),t.addClass("minicolors-focus"),o.stop(!0,!0).fadeIn(n.showSpeed,function(){n.show&&n.show.call(i.get(0))}))}function s(){i(".minicolors-focus").each(function(){var t=i(this),o=t.find(".minicolors-input"),n=t.find(".minicolors-panel"),s=o.data("minicolors-settings");n.fadeOut(s.hideSpeed,function(){s.hide&&s.hide.call(o.get(0)),t.removeClass("minicolors-focus")})})}function a(i,t,o){var n,s,a,r,c=i.parents(".minicolors").find(".minicolors-input"),l=c.data("minicolors-settings"),h=i.find("[class$=-picker]"),d=i.offset().left,u=i.offset().top,g=Math.round(t.pageX-d),m=Math.round(t.pageY-u),p=o?l.animationSpeed:0;t.originalEvent.changedTouches&&(g=t.originalEvent.changedTouches[0].pageX-d,m=t.originalEvent.changedTouches[0].pageY-u),0>g&&(g=0),0>m&&(m=0),g>i.width()&&(g=i.width()),m>i.height()&&(m=i.height()),i.parent().is(".minicolors-slider-wheel")&&h.parent().is(".minicolors-grid")&&(n=75-g,s=75-m,a=Math.sqrt(n*n+s*s),r=Math.atan2(s,n),0>r&&(r+=2*Math.PI),a>75&&(a=75,g=75-75*Math.cos(r),m=75-75*Math.sin(r)),g=Math.round(g),m=Math.round(m)),i.is(".minicolors-grid")?h.stop(!0).animate({top:m+"px",left:g+"px"},p,l.animationEasing,function(){e(c,i)}):h.stop(!0).animate({top:m+"px"},p,l.animationEasing,function(){e(c,i)})}function e(i,t){function o(i,t){var o,n;return i.length&&t?(o=i.offset().left,n=i.offset().top,{x:o-t.offset().left+i.outerWidth()/2,y:n-t.offset().top+i.outerHeight()/2}):null}var n,s,a,e,r,l,h,u=i.val(),m=i.attr("data-opacity"),p=i.parent(),v=i.data("minicolors-settings"),b=p.find(".minicolors-swatch"),y=p.find(".minicolors-grid"),M=p.find(".minicolors-slider"),w=p.find(".minicolors-opacity-slider"),x=y.find("[class$=-picker]"),C=M.find("[class$=-picker]"),k=w.find("[class$=-picker]"),S=o(x,y),z=o(C,M),D=o(k,w);if(t.is(".minicolors-grid, .minicolors-slider")){switch(v.control){case"wheel":e=y.width()/2-S.x,r=y.height()/2-S.y,l=Math.sqrt(e*e+r*r),h=Math.atan2(r,e),0>h&&(h+=2*Math.PI),l>75&&(l=75,S.x=69-75*Math.cos(h),S.y=69-75*Math.sin(h)),s=g(l/.75,0,100),n=g(180*h/Math.PI,0,360),a=g(100-Math.floor(z.y*(100/M.height())),0,100),u=f({h:n,s:s,b:a}),M.css("backgroundColor",f({h:n,s:s,b:100}));break;case"saturation":n=g(parseInt(S.x*(360/y.width()),10),0,360),s=g(100-Math.floor(z.y*(100/M.height())),0,100),a=g(100-Math.floor(S.y*(100/y.height())),0,100),u=f({h:n,s:s,b:a}),M.css("backgroundColor",f({h:n,s:100,b:a})),p.find(".minicolors-grid-inner").css("opacity",s/100);break;case"brightness":n=g(parseInt(S.x*(360/y.width()),10),0,360),s=g(100-Math.floor(S.y*(100/y.height())),0,100),a=g(100-Math.floor(z.y*(100/M.height())),0,100),u=f({h:n,s:s,b:a}),M.css("backgroundColor",f({h:n,s:s,b:100})),p.find(".minicolors-grid-inner").css("opacity",1-a/100);break;default:n=g(360-parseInt(z.y*(360/M.height()),10),0,360),s=g(Math.floor(S.x*(100/y.width())),0,100),a=g(100-Math.floor(S.y*(100/y.height())),0,100),u=f({h:n,s:s,b:a}),y.css("backgroundColor",f({h:n,s:100,b:100}))}i.val(d(u,v.letterCase))}t.is(".minicolors-opacity-slider")&&(m=v.opacity?parseFloat(1-D.y/w.height()).toFixed(2):1,v.opacity&&i.attr("data-opacity",m)),b.find("SPAN").css({backgroundColor:u,opacity:m}),c(i,u,m)}function r(i,t){var o,n,s,a,e,r,l,h=i.parent(),m=i.data("minicolors-settings"),p=h.find(".minicolors-swatch"),b=h.find(".minicolors-grid"),y=h.find(".minicolors-slider"),M=h.find(".minicolors-opacity-slider"),w=b.find("[class$=-picker]"),x=y.find("[class$=-picker]"),C=M.find("[class$=-picker]");switch(o=d(u(i.val(),!0),m.letterCase),o||(o=d(u(m.defaultValue,!0),m.letterCase)),n=v(o),t||i.val(o),m.opacity&&(s=""===i.attr("data-opacity")?1:g(parseFloat(i.attr("data-opacity")).toFixed(2),0,1),isNaN(s)&&(s=1),i.attr("data-opacity",s),p.find("SPAN").css("opacity",s),e=g(M.height()-M.height()*s,0,M.height()),C.css("top",e+"px")),p.find("SPAN").css("backgroundColor",o),m.control){case"wheel":r=g(Math.ceil(.75*n.s),0,b.height()/2),l=n.h*Math.PI/180,a=g(75-Math.cos(l)*r,0,b.width()),e=g(75-Math.sin(l)*r,0,b.height()),w.css({top:e+"px",left:a+"px"}),e=150-n.b/(100/b.height()),""===o&&(e=0),x.css("top",e+"px"),y.css("backgroundColor",f({h:n.h,s:n.s,b:100}));break;case"saturation":a=g(5*n.h/12,0,150),e=g(b.height()-Math.ceil(n.b/(100/b.height())),0,b.height()),w.css({top:e+"px",left:a+"px"}),e=g(y.height()-n.s*(y.height()/100),0,y.height()),x.css("top",e+"px"),y.css("backgroundColor",f({h:n.h,s:100,b:n.b})),h.find(".minicolors-grid-inner").css("opacity",n.s/100);break;case"brightness":a=g(5*n.h/12,0,150),e=g(b.height()-Math.ceil(n.s/(100/b.height())),0,b.height()),w.css({top:e+"px",left:a+"px"}),e=g(y.height()-n.b*(y.height()/100),0,y.height()),x.css("top",e+"px"),y.css("backgroundColor",f({h:n.h,s:n.s,b:100})),h.find(".minicolors-grid-inner").css("opacity",1-n.b/100);break;default:a=g(Math.ceil(n.s/(100/b.width())),0,b.width()),e=g(b.height()-Math.ceil(n.b/(100/b.height())),0,b.height()),w.css({top:e+"px",left:a+"px"}),e=g(y.height()-n.h/(360/y.height()),0,y.height()),x.css("top",e+"px"),b.css("backgroundColor",f({h:n.h,s:100,b:100}))}i.data("minicolors-initialized")&&c(i,o,s)}function c(i,t,o){var n=i.data("minicolors-settings"),s=i.data("minicolors-lastChange");s&&s.hex===t&&s.opacity===o||(i.data("minicolors-lastChange",{hex:t,opacity:o}),n.change&&(n.changeDelay?(clearTimeout(i.data("minicolors-changeTimeout")),i.data("minicolors-changeTimeout",setTimeout(function(){n.change.call(i.get(0),t,o)},n.changeDelay))):n.change.call(i.get(0),t,o)),i.trigger("change").trigger("input"))}function l(t){var o=u(i(t).val(),!0),n=y(o),s=i(t).attr("data-opacity");return n?(void 0!==s&&i.extend(n,{a:parseFloat(s)}),n):null}function h(t,o){var n=u(i(t).val(),!0),s=y(n),a=i(t).attr("data-opacity");return s?(void 0===a&&(a=1),o?"rgba("+s.r+", "+s.g+", "+s.b+", "+parseFloat(a)+")":"rgb("+s.r+", "+s.g+", "+s.b+")"):null}function d(i,t){return"uppercase"===t?i.toUpperCase():i.toLowerCase()}function u(i,t){return i=i.replace(/[^A-F0-9]/gi,""),3!==i.length&&6!==i.length?"":(3===i.length&&t&&(i=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]),"#"+i)}function g(i,t,o){return t>i&&(i=t),i>o&&(i=o),i}function m(i){var t={},o=Math.round(i.h),n=Math.round(255*i.s/100),s=Math.round(255*i.b/100);if(0===n)t.r=t.g=t.b=s;else{var a=s,e=(255-n)*s/255,r=(a-e)*(o%60)/60;360===o&&(o=0),60>o?(t.r=a,t.b=e,t.g=e+r):120>o?(t.g=a,t.b=e,t.r=a-r):180>o?(t.g=a,t.r=e,t.b=e+r):240>o?(t.b=a,t.r=e,t.g=a-r):300>o?(t.b=a,t.g=e,t.r=e+r):360>o?(t.r=a,t.g=e,t.b=a-r):(t.r=0,t.g=0,t.b=0)}return{r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b)}}function p(t){var o=[t.r.toString(16),t.g.toString(16),t.b.toString(16)];return i.each(o,function(i,t){1===t.length&&(o[i]="0"+t)}),"#"+o.join("")}function f(i){return p(m(i))}function v(i){var t=b(y(i));return 0===t.s&&(t.h=360),t}function b(i){var t={h:0,s:0,b:0},o=Math.min(i.r,i.g,i.b),n=Math.max(i.r,i.g,i.b),s=n-o;return t.b=n,t.s=0!==n?255*s/n:0,0!==t.s?i.r===n?t.h=(i.g-i.b)/s:i.g===n?t.h=2+(i.b-i.r)/s:t.h=4+(i.r-i.g)/s:t.h=-1,t.h*=60,t.h<0&&(t.h+=360),t.s*=100/255,t.b*=100/255,t}function y(i){return i=parseInt(i.indexOf("#")>-1?i.substring(1):i,16),{r:i>>16,g:(65280&i)>>8,b:255&i}}i.minicolors={defaults:{animationSpeed:50,animationEasing:"swing",change:null,changeDelay:0,control:"hue",dataUris:!0,defaultValue:"",hide:null,hideSpeed:100,inline:!1,letterCase:"lowercase",opacity:!1,position:"bottom left",show:null,showSpeed:100,theme:"default"}},i.extend(i.fn,{minicolors:function(a,e){switch(a){case"destroy":return i(this).each(function(){o(i(this))}),i(this);case"hide":return s(),i(this);case"opacity":return void 0===e?i(this).attr("data-opacity"):(i(this).each(function(){r(i(this).attr("data-opacity",e))}),i(this));case"rgbObject":return l(i(this),"rgbaObject"===a);case"rgbString":case"rgbaString":return h(i(this),"rgbaString"===a);case"settings":return void 0===e?i(this).data("minicolors-settings"):(i(this).each(function(){var t=i(this).data("minicolors-settings")||{};o(i(this)),i(this).minicolors(i.extend(!0,t,e))}),i(this));case"show":return n(i(this).eq(0)),i(this);case"value":return void 0===e?i(this).val():(i(this).each(function(){r(i(this).val(e))}),i(this));default:return"create"!==a&&(e=a),i(this).each(function(){t(i(this),e)}),i(this)}}}),i(document).on("mousedown.minicolors touchstart.minicolors",function(t){i(t.target).parents().add(t.target).hasClass("minicolors")||s()}).on("mousedown.minicolors touchstart.minicolors",".minicolors-grid, .minicolors-slider, .minicolors-opacity-slider",function(t){var o=i(this);t.preventDefault(),i(document).data("minicolors-target",o),a(o,t,!0)}).on("mousemove.minicolors touchmove.minicolors",function(t){var o=i(document).data("minicolors-target");o&&a(o,t)}).on("mouseup.minicolors touchend.minicolors",function(){i(this).removeData("minicolors-target")}).on("mousedown.minicolors touchstart.minicolors",".minicolors-swatch",function(t){var o=i(this).parent().find(".minicolors-input");t.preventDefault(),n(o)}).on("focus.minicolors",".minicolors-input",function(){var t=i(this);t.data("minicolors-initialized")&&n(t)}).on("blur.minicolors",".minicolors-input",function(){var t=i(this),o=t.data("minicolors-settings");t.data("minicolors-initialized")&&(t.val(u(t.val(),!0)),""===t.val()&&t.val(u(o.defaultValue,!0)),t.val(d(t.val(),o.letterCase)))}).on("keydown.minicolors",".minicolors-input",function(t){var o=i(this);if(o.data("minicolors-initialized"))switch(t.keyCode){case 9:s();break;case 13:case 27:s(),o.blur()}}).on("keyup.minicolors",".minicolors-input",function(){var t=i(this);t.data("minicolors-initialized")&&r(t,!0)}).on("paste.minicolors",".minicolors-input",function(){var t=i(this);t.data("minicolors-initialized")&&setTimeout(function(){r(t,!0)},1)})}(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== SiteOrigin CSS ===
|
2 |
Tags: css, design, edit, customize
|
3 |
Requires at least: 3.9
|
4 |
-
Tested up to: 4.
|
5 |
-
Stable tag: 1.0.
|
6 |
-
License:
|
7 |
Contributors: gpriday
|
8 |
|
9 |
== Description ==
|
@@ -30,7 +30,7 @@ SiteOrigin CSS has a powerful CSS editor, the likes of which you'd usually only
|
|
30 |
|
31 |
= It's Free =
|
32 |
|
33 |
-
We're committed to keeping SiteOrigin CSS free. You can install it on as many sites as you like without ever worrying about licensing. All future updates and upgrades will be free, and we even offer free support over on our friendly support forums.
|
34 |
|
35 |
= Works With Any Theme =
|
36 |
|
@@ -61,8 +61,13 @@ We offer free support on the [SiteOrigin support forums](https://siteorigin.com/
|
|
61 |
|
62 |
== Changelog ==
|
63 |
|
|
|
|
|
|
|
|
|
|
|
64 |
= 1.0.2 =
|
65 |
-
* Dequeue functionality
|
66 |
* Removed wp_styles for compatibility with older versions of WordPress
|
67 |
|
68 |
= 1.0.1 =
|
1 |
=== SiteOrigin CSS ===
|
2 |
Tags: css, design, edit, customize
|
3 |
Requires at least: 3.9
|
4 |
+
Tested up to: 4.3.1
|
5 |
+
Stable tag: 1.0.2
|
6 |
+
License: GPLv2 or later
|
7 |
Contributors: gpriday
|
8 |
|
9 |
== Description ==
|
30 |
|
31 |
= It's Free =
|
32 |
|
33 |
+
We're committed to keeping SiteOrigin CSS, free. You can install it on as many sites as you like without ever worrying about licensing. All future updates and upgrades will be free, and we even offer free support over on our friendly support forums.
|
34 |
|
35 |
= Works With Any Theme =
|
36 |
|
61 |
|
62 |
== Changelog ==
|
63 |
|
64 |
+
= 1.0.3 - 29 October 2015=
|
65 |
+
* Changed video image
|
66 |
+
* Adjust revision times by GMT offset.
|
67 |
+
* Don't overwrite media queries sub styles, rather just append them.
|
68 |
+
|
69 |
= 1.0.2 =
|
70 |
+
* Dequeue functionality that conflicted with WordPress color picker, if it's enqueued.
|
71 |
* Removed wp_styles for compatibility with older versions of WordPress
|
72 |
|
73 |
= 1.0.1 =
|
so-css.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: SiteOrigin CSS
|
4 |
Description: An advanced CSS editor from SiteOrigin.
|
5 |
-
Version: 1.0.
|
6 |
Author: SiteOrigin
|
7 |
Author URI: https://siteorigin.com
|
8 |
Plugin URI: https://siteorigin.com/css/
|
@@ -13,8 +13,8 @@ License URI: https://www.gnu.org/licenses/gpl-3.0.txt
|
|
13 |
// Handle the legacy CSS editor that came with SiteOrigin themes
|
14 |
include plugin_dir_path(__FILE__) . '/inc/legacy.php';
|
15 |
|
16 |
-
define('SOCSS_VERSION', '1.0.
|
17 |
-
define('SOCSS_JS_SUFFIX', '');
|
18 |
|
19 |
/**
|
20 |
* Class SiteOrigin_CSS The main class for the SiteOrigin CSS Editor
|
2 |
/*
|
3 |
Plugin Name: SiteOrigin CSS
|
4 |
Description: An advanced CSS editor from SiteOrigin.
|
5 |
+
Version: 1.0.3
|
6 |
Author: SiteOrigin
|
7 |
Author URI: https://siteorigin.com
|
8 |
Plugin URI: https://siteorigin.com/css/
|
13 |
// Handle the legacy CSS editor that came with SiteOrigin themes
|
14 |
include plugin_dir_path(__FILE__) . '/inc/legacy.php';
|
15 |
|
16 |
+
define('SOCSS_VERSION', '1.0.3');
|
17 |
+
define('SOCSS_JS_SUFFIX', '.min');
|
18 |
|
19 |
/**
|
20 |
* Class SiteOrigin_CSS The main class for the SiteOrigin CSS Editor
|
tpl/page.php
CHANGED
@@ -8,12 +8,7 @@
|
|
8 |
|
9 |
|
10 |
<?php if( isset($_POST['siteorigin_custom_css_save']) ) : ?>
|
11 |
-
<div class="updated settings-error">
|
12 |
-
<p>
|
13 |
-
<?php _e('Site design updated.', 'so-css') ?>
|
14 |
-
<?php printf( __('<a href="%s" target="_blank">Tweet</a> your new design to find out what your followers think.', 'so-css'), esc_url( SiteOrigin_CSS::single()->get_tweet_url() ) ) ?>
|
15 |
-
</p>
|
16 |
-
</div>
|
17 |
<?php endif; ?>
|
18 |
|
19 |
<?php if(!empty($revision)) : ?>
|
@@ -52,7 +47,7 @@
|
|
52 |
foreach($custom_css_revisions as $time => $css) {
|
53 |
?>
|
54 |
<li>
|
55 |
-
<a href="<?php echo add_query_arg(array('theme' => $theme, 'time' => $time)) ?>" class="load-css-revision"><?php echo date('j F Y @ H:i:s', $time) ?></a>
|
56 |
(<?php printf(__('%d chars', 'so-css'), strlen($css)) ?>)
|
57 |
</li>
|
58 |
<?php
|
8 |
|
9 |
|
10 |
<?php if( isset($_POST['siteorigin_custom_css_save']) ) : ?>
|
11 |
+
<div class="updated settings-error"><p><?php _e('Site design updated.', 'so-css') ?></p></div>
|
|
|
|
|
|
|
|
|
|
|
12 |
<?php endif; ?>
|
13 |
|
14 |
<?php if(!empty($revision)) : ?>
|
47 |
foreach($custom_css_revisions as $time => $css) {
|
48 |
?>
|
49 |
<li>
|
50 |
+
<a href="<?php echo add_query_arg(array('theme' => $theme, 'time' => $time)) ?>" class="load-css-revision"><?php echo date('j F Y @ H:i:s', $time + get_option('gmt_offset') * 60 * 60) ?></a>
|
51 |
(<?php printf(__('%d chars', 'so-css'), strlen($css)) ?>)
|
52 |
</li>
|
53 |
<?php
|