SiteOrigin CSS - Version 1.1.3

Version Description

  • 31 January 2017 =
  • Removed leading slash in paths after plugin_dir_url().
  • Updated to latest CodeMirror.
  • Fixed padding issue that was causing problems with Firefox and the color picker.
Download this release

Release Info

Developer gpriday
Plugin Icon 128x128 SiteOrigin CSS
Version 1.1.3
Comparing to
See all releases

Code changes from version 1.1.2 to 1.1.3

css/admin.css CHANGED
@@ -335,7 +335,9 @@
335
  padding: 5px 8px;
336
  }
337
  #so-custom-css-properties .sections .fields-table .minicolors input {
338
- padding: 14px 0 14px 30px;
 
 
339
  }
340
  #so-custom-css-properties .sections .fields-table .select {
341
  display: block;
335
  padding: 5px 8px;
336
  }
337
  #so-custom-css-properties .sections .fields-table .minicolors input {
338
+ box-sizing: border-box;
339
+ height: 30px;
340
+ padding: 5px 0 5px 30px;
341
  }
342
  #so-custom-css-properties .sections .fields-table .select {
343
  display: block;
lib/codemirror/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2014 by Marijn Haverbeke <marijnh@gmail.com> and others
2
 
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
  of this software and associated documentation files (the "Software"), to deal
1
+ Copyright (C) 2017 by Marijn Haverbeke <marijnh@gmail.com> and others
2
 
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
  of this software and associated documentation files (the "Software"), to deal
lib/codemirror/addon/fold/brace-fold.js CHANGED
@@ -13,7 +13,7 @@
13
 
14
  CodeMirror.registerHelper("fold", "brace", function(cm, start) {
15
  var line = start.line, lineText = cm.getLine(line);
16
- var startCh, tokenType;
17
 
18
  function findOpening(openCh) {
19
  for (var at = start.ch, pass = 0;;) {
@@ -72,15 +72,15 @@ CodeMirror.registerHelper("fold", "import", function(cm, start) {
72
  }
73
  }
74
 
75
- var start = start.line, has = hasImport(start), prev;
76
- if (!has || hasImport(start - 1) || ((prev = hasImport(start - 2)) && prev.end.line == start - 1))
77
  return null;
78
  for (var end = has.end;;) {
79
  var next = hasImport(end.line + 1);
80
  if (next == null) break;
81
  end = next.end;
82
  }
83
- return {from: cm.clipPos(CodeMirror.Pos(start, has.startCh + 1)), to: end};
84
  });
85
 
86
  CodeMirror.registerHelper("fold", "include", function(cm, start) {
@@ -91,14 +91,14 @@ CodeMirror.registerHelper("fold", "include", function(cm, start) {
91
  if (start.type == "meta" && start.string.slice(0, 8) == "#include") return start.start + 8;
92
  }
93
 
94
- var start = start.line, has = hasInclude(start);
95
- if (has == null || hasInclude(start - 1) != null) return null;
96
- for (var end = start;;) {
97
  var next = hasInclude(end + 1);
98
  if (next == null) break;
99
  ++end;
100
  }
101
- return {from: CodeMirror.Pos(start, has + 1),
102
  to: cm.clipPos(CodeMirror.Pos(end))};
103
  });
104
 
13
 
14
  CodeMirror.registerHelper("fold", "brace", function(cm, start) {
15
  var line = start.line, lineText = cm.getLine(line);
16
+ var tokenType;
17
 
18
  function findOpening(openCh) {
19
  for (var at = start.ch, pass = 0;;) {
72
  }
73
  }
74
 
75
+ var startLine = start.line, has = hasImport(startLine), prev;
76
+ if (!has || hasImport(startLine - 1) || ((prev = hasImport(startLine - 2)) && prev.end.line == startLine - 1))
77
  return null;
78
  for (var end = has.end;;) {
79
  var next = hasImport(end.line + 1);
80
  if (next == null) break;
81
  end = next.end;
82
  }
83
+ return {from: cm.clipPos(CodeMirror.Pos(startLine, has.startCh + 1)), to: end};
84
  });
85
 
86
  CodeMirror.registerHelper("fold", "include", function(cm, start) {
91
  if (start.type == "meta" && start.string.slice(0, 8) == "#include") return start.start + 8;
92
  }
93
 
94
+ var startLine = start.line, has = hasInclude(startLine);
95
+ if (has == null || hasInclude(startLine - 1) != null) return null;
96
+ for (var end = startLine;;) {
97
  var next = hasInclude(end + 1);
98
  if (next == null) break;
99
  ++end;
100
  }
101
+ return {from: CodeMirror.Pos(startLine, has + 1),
102
  to: cm.clipPos(CodeMirror.Pos(end))};
103
  });
104
 
lib/codemirror/addon/fold/brace-fold.min.js CHANGED
@@ -1 +1 @@
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=i<=0?-1:f.lastIndexOf(t,i-1);if(u!=-1){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;v<=g;++v)for(var p=r.getLine(v),m=v==l?i:0;;){var P=p.indexOf(s,m),k=p.indexOf(u,m);if(P<0&&(P=p.length),k<0&&(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);i<=o;++i){var l=r.getLine(i),f=l.indexOf(";");if(f!=-1)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))}})});
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 f=n.ch,s=0;;){var u=f<=0?-1:l.lastIndexOf(t,f-1);if(u!=-1){if(1==s&&u<n.ch)break;if(i=r.getTokenTypeAt(e.Pos(o,u+1)),!/^(comment|string)/.test(i))return u+1;f=u-1}else{if(1==s)break;s=1,f=l.length}}}var i,o=n.line,l=r.getLine(o),f="{",s="}",u=t("{");if(null==u&&(f="[",s="]",u=t("[")),null!=u){var a,d,c=1,g=r.lastLine();e:for(var v=o;v<=g;++v)for(var p=r.getLine(v),m=v==o?u:0;;){var P=p.indexOf(f,m),k=p.indexOf(s,m);if(P<0&&(P=p.length),k<0&&(k=p.length),m=Math.min(P,k),m==p.length)break;if(r.getTokenTypeAt(e.Pos(v,m+1))==i)if(m==P)++c;else if(!--c){a=v,d=m;break e}++m}if(null!=a&&(o!=a||d!=u))return{from:e.Pos(o,u),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);i<=o;++i){var l=r.getLine(i),f=l.indexOf(";");if(f!=-1)return{startCh:t.end,end:e.Pos(i,f)}}}var i,o=n.line,l=t(o);if(!l||t(o-1)||(i=t(o-2))&&i.end.line==o-1)return null;for(var f=l.end;;){var s=t(f.line+1);if(null==s)break;f=s.end}return{from:r.clipPos(e.Pos(o,l.startCh+1)),to:f}}),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 i=n.line,o=t(i);if(null==o||null!=t(i-1))return null;for(var l=i;;){var f=t(l+1);if(null==f)break;++l}return{from:e.Pos(i,o+1),to:r.clipPos(e.Pos(l))}})});
lib/codemirror/addon/fold/comment-fold.js CHANGED
@@ -29,7 +29,7 @@ CodeMirror.registerGlobalHelper("fold", "comment", function(mode) {
29
  }
30
  if (pass == 1 && found < start.ch) return;
31
  if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1))) &&
32
- (lineText.slice(found - endToken.length, found) == endToken ||
33
  !/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found))))) {
34
  startCh = found + startToken.length;
35
  break;
29
  }
30
  if (pass == 1 && found < start.ch) return;
31
  if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1))) &&
32
+ (found == 0 || lineText.slice(found - endToken.length, found) == endToken ||
33
  !/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found))))) {
34
  startCh = found + startToken.length;
35
  break;
lib/codemirror/addon/fold/comment-fold.min.js CHANGED
@@ -1 +1 @@
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=m<=0?-1:c.lastIndexOf(r,m-1);if(d!=-1){if(1==a&&d<n.ch)return;if(/comment/.test(t.getTokenTypeAt(e.Pos(l,d+1)))&&(c.slice(d-i.length,d)==i||!/comment/.test(t.getTokenTypeAt(e.Pos(l,d))))){f=d+r.length;break}m=d-1}else{if(1==a)return;a=1,m=c.length}}var s,u,b=1,g=t.lastLine();e:for(var h=l;h<=g;++h)for(var k=t.getLine(h),p=h==l?f:0;;){var v=k.indexOf(r,p),y=k.indexOf(i,p);if(v<0&&(v=k.length),y<0&&(y=k.length),p=Math.min(v,y),p==k.length)break;if(p==v)++b;else if(!--b){s=h,u=p;break e}++p}if(null!=s&&(l!=s||u!=f))return{from:e.Pos(l,f),to:e.Pos(s,u)}}})});
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=m<=0?-1:c.lastIndexOf(r,m-1);if(d!=-1){if(1==a&&d<n.ch)return;if(/comment/.test(t.getTokenTypeAt(e.Pos(l,d+1)))&&(0==d||c.slice(d-i.length,d)==i||!/comment/.test(t.getTokenTypeAt(e.Pos(l,d))))){f=d+r.length;break}m=d-1}else{if(1==a)return;a=1,m=c.length}}var s,u,b=1,g=t.lastLine();e:for(var h=l;h<=g;++h)for(var k=t.getLine(h),p=h==l?f:0;;){var v=k.indexOf(r,p),y=k.indexOf(i,p);if(v<0&&(v=k.length),y<0&&(y=k.length),p=Math.min(v,y),p==k.length)break;if(p==v)++b;else if(!--b){s=h,u=p;break e}++p}if(null!=s&&(l!=s||u!=f))return{from:e.Pos(l,f),to:e.Pos(s,u)}}})});
lib/codemirror/addon/fold/foldcode.js CHANGED
@@ -49,7 +49,7 @@
49
  });
50
  var myRange = cm.markText(range.from, range.to, {
51
  replacedWith: myWidget,
52
- clearOnEnter: true,
53
  __isFold: true
54
  });
55
  myRange.on("clear", function(from, to) {
@@ -129,7 +129,8 @@
129
  rangeFinder: CodeMirror.fold.auto,
130
  widget: "\u2194",
131
  minFoldSize: 0,
132
- scanUp: false
 
133
  };
134
 
135
  CodeMirror.defineOption("foldOptions", null);
49
  });
50
  var myRange = cm.markText(range.from, range.to, {
51
  replacedWith: myWidget,
52
+ clearOnEnter: getOption(cm, options, "clearOnEnter"),
53
  __isFold: true
54
  });
55
  myRange.on("clear", function(from, to) {
129
  rangeFinder: CodeMirror.fold.auto,
130
  widget: "\u2194",
131
  minFoldSize: 0,
132
+ scanUp: false,
133
+ clearOnEnter: true
134
  };
135
 
136
  CodeMirror.defineOption("foldOptions", null);
lib/codemirror/addon/fold/foldcode.min.js CHANGED
@@ -1 +1 @@
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();e<=r;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();e<=r;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)})});
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,l){function f(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"!==l){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=f(!0);if(r(o,t,"scanUp"))for(;!a&&i.line>o.firstLine();)i=n.Pos(i.line-1,0),a=f(!1);if(a&&!a.cleared&&"unfold"!==l){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:r(o,t,"clearOnEnter"),__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();e<=r;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();e<=r;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,clearOnEnter:!0};n.defineOption("foldOptions",null),n.defineExtension("foldOption",function(n,o){return r(this,n,o)})});
lib/codemirror/addon/fold/foldgutter.js CHANGED
@@ -20,7 +20,7 @@
20
  cm.off("viewportChange", onViewportChange);
21
  cm.off("fold", onFold);
22
  cm.off("unfold", onFold);
23
- cm.off("swapDoc", updateInViewport);
24
  }
25
  if (val) {
26
  cm.state.foldGutter = new State(parseOptions(val));
@@ -30,7 +30,7 @@
30
  cm.on("viewportChange", onViewportChange);
31
  cm.on("fold", onFold);
32
  cm.on("unfold", onFold);
33
- cm.on("swapDoc", updateInViewport);
34
  }
35
  });
36
 
@@ -50,7 +50,7 @@
50
  }
51
 
52
  function isFolded(cm, line) {
53
- var marks = cm.findMarksAt(Pos(line));
54
  for (var i = 0; i < marks.length; ++i)
55
  if (marks[i].__isFold && marks[i].find().from.line == line) return marks[i];
56
  }
20
  cm.off("viewportChange", onViewportChange);
21
  cm.off("fold", onFold);
22
  cm.off("unfold", onFold);
23
+ cm.off("swapDoc", onChange);
24
  }
25
  if (val) {
26
  cm.state.foldGutter = new State(parseOptions(val));
30
  cm.on("viewportChange", onViewportChange);
31
  cm.on("fold", onFold);
32
  cm.on("unfold", onFold);
33
+ cm.on("swapDoc", onChange);
34
  }
35
  });
36
 
50
  }
51
 
52
  function isFolded(cm, line) {
53
+ var marks = cm.findMarks(Pos(line, 0), Pos(line + 1, 0));
54
  for (var i = 0; i < marks.length; ++i)
55
  if (marks[i].__isFold && marks[i].find().from.line == line) return marks[i];
56
  }
lib/codemirror/addon/fold/foldgutter.min.js CHANGED
@@ -1 +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});
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.findMarks(c(t,0),c(t+1,0)),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",a)),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",a))});var c=o.Pos});
lib/codemirror/addon/fold/xml-fold.js CHANGED
@@ -21,8 +21,8 @@
21
  function Iter(cm, line, ch, range) {
22
  this.line = line; this.ch = ch;
23
  this.cm = cm; this.text = cm.getLine(line);
24
- this.min = range ? range.from : cm.firstLine();
25
- this.max = range ? range.to - 1 : cm.lastLine();
26
  }
27
 
28
  function tagAt(iter, ch) {
@@ -140,9 +140,9 @@
140
  var openTag = toNextTag(iter), end;
141
  if (!openTag || iter.line != start.line || !(end = toTagEnd(iter))) return;
142
  if (!openTag[1] && end != "selfClose") {
143
- var start = Pos(iter.line, iter.ch);
144
- var close = findMatchingClose(iter, openTag[2]);
145
- return close && {from: start, to: close.from};
146
  }
147
  }
148
  });
21
  function Iter(cm, line, ch, range) {
22
  this.line = line; this.ch = ch;
23
  this.cm = cm; this.text = cm.getLine(line);
24
+ this.min = range ? Math.max(range.from, cm.firstLine()) : cm.firstLine();
25
+ this.max = range ? Math.min(range.to - 1, cm.lastLine()) : cm.lastLine();
26
  }
27
 
28
  function tagAt(iter, ch) {
140
  var openTag = toNextTag(iter), end;
141
  if (!openTag || iter.line != start.line || !(end = toTagEnd(iter))) return;
142
  if (!openTag[1] && end != "selfClose") {
143
+ var startPos = Pos(iter.line, iter.ch);
144
+ var endPos = findMatchingClose(iter, openTag[2]);
145
+ return endPos && {from: startPos, to: endPos.from};
146
  }
147
  }
148
  });
lib/codemirror/addon/fold/xml-fold.min.js CHANGED
@@ -1 +1 @@
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){if(!(e.line>=e.max))return e.ch=0,e.text=e.cm.getLine(++e.line),!0}function f(e){if(!(e.line<=e.min))return 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(n==-1){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(n==-1){if(f(e))continue;return}if(i(e,n+1)){v.lastIndex=n,e.ch=n;var t=v.exec(e.text);if(t&&t.index==n)return t}else e.ch=n}}function c(e){for(;;){v.lastIndex=e.ch;var n=v.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(n==-1){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(l<0&&(!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(c<0&&(!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",g=x+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",v=new RegExp("<(/?)(["+x+"]["+g+"]*)","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(f.text.indexOf(">")!=-1||f.text.indexOf("<")!=-1){var c=o(f),l=c&&h(f.line,f.ch),x=c&&u(f);if(c&&x&&!(n(f,i)>0)){var g={from:h(f.line,f.ch),to:l,tag:x[2]};return"selfClose"==c?{open:g,close:null,at:"open"}:x[1]?{open:s(f,x[2]),close:g,at:"close"}:(f=new t(e,l.line,l.ch,r),{open:g,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)}});
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?Math.max(i.from,e.firstLine()):e.firstLine(),this.max=i?Math.min(i.to-1,e.lastLine()):e.lastLine()}function i(e,n){var t=e.cm.getTokenTypeAt(h(e.line,n));return t&&/\btag\b/.test(t)}function r(e){if(!(e.line>=e.max))return e.ch=0,e.text=e.cm.getLine(++e.line),!0}function f(e){if(!(e.line<=e.min))return 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(n==-1){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(n==-1){if(f(e))continue;return}if(i(e,n+1)){v.lastIndex=n,e.ch=n;var t=v.exec(e.text);if(t&&t.index==n)return t}else e.ch=n}}function l(e){for(;;){v.lastIndex=e.ch;var n=v.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 c(e){for(;;){var n=e.ch?e.text.lastIndexOf(">",e.ch-1):-1;if(n==-1){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=l(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 c=t.length-1;c>=0;--c)if(t[c]==r[2]){t.length=c;break}if(c<0&&(!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=c(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 l=t.length-1;l>=0;--l)if(t[l]==o[2]){t.length=l;break}if(l<0&&(!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",g=x+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",v=new RegExp("<(/?)(["+x+"]["+g+"]*)","g");e.registerHelper("fold","xml",function(e,n){for(var i=new t(e,n.line,0);;){var r,f=l(i);if(!f||i.line!=n.line||!(r=o(i)))return;if(!f[1]&&"selfClose"!=r){var u=h(i.line,i.ch),c=a(i,f[2]);return c&&{from:u,to:c.from}}}}),e.findMatchingTag=function(e,i,r){var f=new t(e,i.line,i.ch,r);if(f.text.indexOf(">")!=-1||f.text.indexOf("<")!=-1){var l=o(f),c=l&&h(f.line,f.ch),x=l&&u(f);if(l&&x&&!(n(f,i)>0)){var g={from:h(f.line,f.ch),to:c,tag:x[2]};return"selfClose"==l?{open:g,close:null,at:"open"}:x[1]?{open:s(f,x[2]),close:g,at:"close"}:(f=new t(e,c.line,c.ch,r),{open:g,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/javascript-hint.js CHANGED
@@ -97,6 +97,15 @@
97
  var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
98
  "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(" ");
99
 
 
 
 
 
 
 
 
 
 
100
  function getCompletions(token, context, keywords, options) {
101
  var found = [], start = token.string, global = options && options.globalScope || window;
102
  function maybeAdd(str) {
@@ -106,7 +115,7 @@
106
  if (typeof obj == "string") forEach(stringProps, maybeAdd);
107
  else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
108
  else if (obj instanceof Function) forEach(funcProps, maybeAdd);
109
- for (var name in obj) maybeAdd(name);
110
  }
111
 
112
  if (context && context.length) {
97
  var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
98
  "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(" ");
99
 
100
+ function forAllProps(obj, callback) {
101
+ if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) {
102
+ for (var name in obj) callback(name)
103
+ } else {
104
+ for (var o = obj; o; o = Object.getPrototypeOf(o))
105
+ Object.getOwnPropertyNames(o).forEach(callback)
106
+ }
107
+ }
108
+
109
  function getCompletions(token, context, keywords, options) {
110
  var found = [], start = token.string, global = options && options.globalScope || window;
111
  function maybeAdd(str) {
115
  if (typeof obj == "string") forEach(stringProps, maybeAdd);
116
  else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
117
  else if (obj instanceof Function) forEach(funcProps, maybeAdd);
118
+ forAllProps(obj, maybeAdd)
119
  }
120
 
121
  if (context && context.length) {
lib/codemirror/addon/hint/javascript-hint.min.js CHANGED
@@ -1 +1 @@
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;r<n;++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 t.indexOf(e)!=-1}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(" ")});
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;r<n;++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 t.indexOf(e)!=-1}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 a=s;"property"==a.type;){if(a=n(e,l(o.line,a.start)),"."!=a.string)return;if(a=n(e,l(o.line,a.start)),!c)var c=[];c.push(a)}return{list:f(s,c,r,i),from:l(o.line,s.start),to:l(o.line,s.end)}}}function i(t,e){return n(t,g,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,e){if(Object.getOwnPropertyNames&&Object.getPrototypeOf)for(var r=t;r;r=Object.getPrototypeOf(r))Object.getOwnPropertyNames(r).forEach(e);else for(var n in t)e(n)}function f(t,n,i,o){function s(t){0!=t.lastIndexOf(g,0)||r(l,t)||l.push(t)}function f(t){"string"==typeof t?e(c,s):t instanceof Array?e(p,s):t instanceof Function&&e(u,s),a(t,s)}var l=[],g=t.string,d=o&&o.globalScope||window;if(n&&n.length){var y,h=n.pop();for(h.type&&0===h.type.indexOf("variable")?(o&&o.additionalContext&&(y=o.additionalContext[h.string]),o&&o.useGlobalScope===!1||(y=y||d[h.string])):"string"==h.type?y="":"atom"==h.type?y=1:"function"==h.type&&(null==d.jQuery||"$"!=h.string&&"jQuery"!=h.string||"function"!=typeof d.jQuery?null!=d._&&"_"==h.string&&"function"==typeof d._&&(y=d._()):y=d.jQuery());null!=y&&n.length;)y=y[n.pop().string];null!=y&&f(y)}else{for(var b=t.state.localVars;b;b=b.next)s(b.name);for(var b=t.state.globalVars;b;b=b.next)s(b.name);o&&o.useGlobalScope===!1||f(d),e(i,s)}return l}var l=t.Pos;t.registerHelper("hint","javascript",i),t.registerHelper("hint","coffeescript",s);var c="charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight toUpperCase toLowerCase split concat match replace search".split(" "),p="length concat join splice push pop shift unshift slice reverse sort indexOf lastIndexOf every some filter forEach map reduce reduceRight ".split(" "),u="prototype apply call bind".split(" "),g="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.css CHANGED
@@ -25,8 +25,6 @@
25
  margin: 0;
26
  padding: 0 4px;
27
  border-radius: 2px;
28
- max-width: 19em;
29
- overflow: hidden;
30
  white-space: pre;
31
  color: black;
32
  cursor: pointer;
25
  margin: 0;
26
  padding: 0 4px;
27
  border-radius: 2px;
 
 
28
  white-space: pre;
29
  color: black;
30
  cursor: pointer;
lib/codemirror/addon/hint/show-hint.js CHANGED
@@ -108,24 +108,22 @@
108
  },
109
 
110
  update: function(first) {
111
- if (this.tick == null) return;
112
- if (!this.options.hint.async) {
113
- this.finishUpdate(this.options.hint(this.cm, this.options), first);
114
- } else {
115
- var myTick = ++this.tick, self = this;
116
- this.options.hint(this.cm, function(data) {
117
- if (self.tick == myTick) self.finishUpdate(data, first);
118
- }, this.options);
119
- }
120
  },
121
 
122
  finishUpdate: function(data, first) {
123
  if (this.data) CodeMirror.signal(this.data, "update");
124
- if (data && this.data && CodeMirror.cmpPos(data.from, this.data.from)) data = null;
125
- this.data = data;
126
 
127
  var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
128
  if (this.widget) this.widget.close();
 
 
 
 
129
  if (data && data.list.length) {
130
  if (picked && data.list.length == 1) {
131
  this.pick(data, 0);
@@ -137,6 +135,11 @@
137
  }
138
  };
139
 
 
 
 
 
 
140
  function parseOptions(cm, pos, options) {
141
  var editor = cm.options.hintOptions;
142
  var out = {};
@@ -226,6 +229,9 @@
226
  var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
227
  (completion.options.container || document.body).appendChild(hints);
228
  var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
 
 
 
229
  if (overlapY > 0) {
230
  var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
231
  if (curTop - height > 0) { // Fits above cursor
@@ -250,6 +256,8 @@
250
  }
251
  hints.style.left = (left = pos.left - overlapX) + "px";
252
  }
 
 
253
 
254
  cm.addKeyMap(this.keyMap = buildKeyMap(completion, {
255
  moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },
@@ -267,7 +275,6 @@
267
  cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); });
268
  }
269
 
270
- var startScroll = cm.getScrollInfo();
271
  cm.on("scroll", this.onScroll = function() {
272
  var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
273
  var newTop = top + startScroll.top - curScroll.top;
@@ -355,40 +362,31 @@
355
  return result
356
  }
357
 
 
 
 
 
 
 
 
 
 
 
358
  function resolveAutoHints(cm, pos) {
359
  var helpers = cm.getHelpers(pos, "hint"), words
360
  if (helpers.length) {
361
- var async = false, resolved
362
- for (var i = 0; i < helpers.length; i++) if (helpers[i].async) async = true
363
- if (async) {
364
- resolved = function(cm, callback, options) {
365
- var app = applicableHelpers(cm, helpers)
366
- function run(i, result) {
367
- if (i == app.length) return callback(null)
368
- var helper = app[i]
369
- if (helper.async) {
370
- helper(cm, function(result) {
371
- if (result) callback(result)
372
- else run(i + 1)
373
- }, options)
374
- } else {
375
- var result = helper(cm, options)
376
- if (result) callback(result)
377
- else run(i + 1)
378
- }
379
- }
380
- run(0)
381
- }
382
- resolved.async = true
383
- } else {
384
- resolved = function(cm, options) {
385
- var app = applicableHelpers(cm, helpers)
386
- for (var i = 0; i < app.length; i++) {
387
- var cur = app[i](cm, options)
388
- if (cur && cur.list.length) return cur
389
- }
390
  }
 
391
  }
 
392
  resolved.supportsSelection = true
393
  return resolved
394
  } else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
108
  },
109
 
110
  update: function(first) {
111
+ if (this.tick == null) return
112
+ var self = this, myTick = ++this.tick
113
+ fetchHints(this.options.hint, this.cm, this.options, function(data) {
114
+ if (self.tick == myTick) self.finishUpdate(data, first)
115
+ })
 
 
 
 
116
  },
117
 
118
  finishUpdate: function(data, first) {
119
  if (this.data) CodeMirror.signal(this.data, "update");
 
 
120
 
121
  var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
122
  if (this.widget) this.widget.close();
123
+
124
+ if (data && this.data && isNewCompletion(this.data, data)) return;
125
+ this.data = data;
126
+
127
  if (data && data.list.length) {
128
  if (picked && data.list.length == 1) {
129
  this.pick(data, 0);
135
  }
136
  };
137
 
138
+ function isNewCompletion(old, nw) {
139
+ var moved = CodeMirror.cmpPos(nw.from, old.from)
140
+ return moved > 0 && old.to.ch - old.from.ch != nw.to.ch - nw.from.ch
141
+ }
142
+
143
  function parseOptions(cm, pos, options) {
144
  var editor = cm.options.hintOptions;
145
  var out = {};
229
  var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
230
  (completion.options.container || document.body).appendChild(hints);
231
  var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
232
+ var scrolls = hints.scrollHeight > hints.clientHeight + 1
233
+ var startScroll = cm.getScrollInfo();
234
+
235
  if (overlapY > 0) {
236
  var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
237
  if (curTop - height > 0) { // Fits above cursor
256
  }
257
  hints.style.left = (left = pos.left - overlapX) + "px";
258
  }
259
+ if (scrolls) for (var node = hints.firstChild; node; node = node.nextSibling)
260
+ node.style.paddingRight = cm.display.nativeBarWidth + "px"
261
 
262
  cm.addKeyMap(this.keyMap = buildKeyMap(completion, {
263
  moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },
275
  cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); });
276
  }
277
 
 
278
  cm.on("scroll", this.onScroll = function() {
279
  var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
280
  var newTop = top + startScroll.top - curScroll.top;
362
  return result
363
  }
364
 
365
+ function fetchHints(hint, cm, options, callback) {
366
+ if (hint.async) {
367
+ hint(cm, callback, options)
368
+ } else {
369
+ var result = hint(cm, options)
370
+ if (result && result.then) result.then(callback)
371
+ else callback(result)
372
+ }
373
+ }
374
+
375
  function resolveAutoHints(cm, pos) {
376
  var helpers = cm.getHelpers(pos, "hint"), words
377
  if (helpers.length) {
378
+ var resolved = function(cm, callback, options) {
379
+ var app = applicableHelpers(cm, helpers);
380
+ function run(i) {
381
+ if (i == app.length) return callback(null)
382
+ fetchHints(app[i], cm, options, function(result) {
383
+ if (result && result.list.length > 0) callback(result)
384
+ else run(i + 1)
385
+ })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
386
  }
387
+ run(0)
388
  }
389
+ resolved.async = true
390
  resolved.supportsSelection = true
391
  return resolved
392
  } else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
lib/codemirror/addon/hint/show-hint.min.js CHANGED
@@ -1 +1 @@
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=i,this.widget=null,this.debounce=0,this.tick=0,this.startPos=this.cm.getCursor("start"),this.startLen=this.cm.getLine(this.startPos.line).length-this.cm.getSelection().length;var e=this;t.on("cursorActivity",this.activityFunc=function(){e.cursorActivity()})}function e(t,i,e){var n=t.options.hintOptions,o={};for(var s in d)o[s]=d[s];if(n)for(var s in n)void 0!==n[s]&&(o[s]=n[s]);if(e)for(var s in e)void 0!==e[s]&&(o[s]=e[s]);return o.hint.resolve&&(o.hint=o.hint.resolve(t,i)),o}function n(t){return"string"==typeof t?t:t.text}function o(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 r=t.options.extraKeys;if(r)for(var c in r)r.hasOwnProperty(c)&&e(c,r[c]);return s}function s(t,i){for(;i&&i!=t;){if("LI"===i.nodeName.toUpperCase()&&i.parentNode==t)return i;i=i.parentNode}}function c(i,e){this.completion=i,this.data=e,this.picked=!1;var c=this,r=i.cm,h=this.hints=document.createElement("ul");h.className="CodeMirror-hints",this.selectedHint=e.selectedHint||0;for(var u=e.list,f=0;f<u.length;++f){var d=h.appendChild(document.createElement("li")),p=u[f],m=l+(f!=this.selectedHint?"":" "+a);null!=p.className&&(m=p.className+" "+m),d.className=m,p.render?p.render(d,e,p):d.appendChild(document.createTextNode(p.displayText||n(p))),d.hintId=f}var g=r.cursorCoords(i.options.alignWithWord?e.from:null),v=g.left,y=g.bottom,w=!0;h.style.left=v+"px",h.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(h);var C=h.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)h.style.top=(y=g.top-A)+"px",w=!1;else if(A>H){h.style.height=H-5+"px",h.style.top=(y=g.bottom-C.top)+"px";var S=r.getCursor();e.from.ch!=S.ch&&(g=r.cursorCoords(S),h.style.left=(v=g.left)+"px",C=h.getBoundingClientRect())}}var T=C.right-k;if(T>0&&(C.right-C.left>k&&(h.style.width=k-5+"px",T-=C.right-C.left-k),h.style.left=(v=g.left-T)+"px"),r.addKeyMap(this.keyMap=o(i,{moveFocus:function(t,i){c.changeActive(c.selectedHint+t,i)},setFocus:function(t){c.changeActive(t)},menuSize:function(){return c.screenAmount()},length:u.length,close:function(){i.close()},pick:function(){c.pick()},data:e})),i.options.closeOnUnfocus){var M;r.on("blur",this.onBlur=function(){M=setTimeout(function(){i.close()},100)}),r.on("focus",this.onFocus=function(){clearTimeout(M)})}var F=r.getScrollInfo();return r.on("scroll",this.onScroll=function(){var t=r.getScrollInfo(),e=r.getWrapperElement().getBoundingClientRect(),n=y+F.top-t.top,o=n-(window.pageYOffset||(document.documentElement||document.body).scrollTop);return w||(o+=h.offsetHeight),o<=e.top||o>=e.bottom?i.close():(h.style.top=n+"px",void(h.style.left=v+F.left-t.left+"px"))}),t.on(h,"dblclick",function(t){var i=s(h,t.target||t.srcElement);i&&null!=i.hintId&&(c.changeActive(i.hintId),c.pick())}),t.on(h,"click",function(t){var e=s(h,t.target||t.srcElement);e&&null!=e.hintId&&(c.changeActive(e.hintId),i.options.completeOnSingleClick&&c.pick())}),t.on(h,"mousedown",function(){setTimeout(function(){r.focus()},20)}),t.signal(e,"select",u[0],h.firstChild),!0}function r(t,i){if(!t.somethingSelected())return i;for(var e=[],n=0;n<i.length;n++)i[n].supportsSelection&&e.push(i[n]);return e}function h(i,e){var n,o=i.getHelpers(e,"hint");if(o.length){for(var s,c=!1,h=0;h<o.length;h++)o[h].async&&(c=!0);return c?(s=function(t,i,e){function n(o,c){if(o==s.length)return i(null);var r=s[o];if(r.async)r(t,function(t){t?i(t):n(o+1)},e);else{var c=r(t,e);c?i(c):n(o+1)}}var s=r(t,o);n(0)},s.async=!0):s=function(t,i){for(var e=r(t,o),n=0;n<e.length;n++){var s=e[n](t,i);if(s&&s.list.length)return s}},s.supportsSelection=!0,s}return(n=i.getHelper(i.getCursor(),"hintWords"))?function(i){return t.hint.fromList(i,{words:n})}:t.hint.anyword?function(i,e){return t.hint.anyword(i,e)}:function(){}}var l="CodeMirror-hint",a="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(n){n=e(this,this.getCursor("start"),n);var o=this.listSelections();if(!(o.length>1)){if(this.somethingSelected()){if(!n.hint.supportsSelection)return;for(var s=0;s<o.length;s++)if(o[s].head.line!=o[s].anchor.line)return}this.state.completionActive&&this.state.completionActive.close();var c=this.state.completionActive=new i(this,n);c.options.hint&&(t.signal(this,"startCompletion",this),c.update(!0))}});var u=window.requestAnimationFrame||function(t){return setTimeout(t,1e3/60)},f=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.data&&t.signal(this.data,"close"),this.widget&&this.widget.close(),t.signal(this.cm,"endCompletion",this.cm))},active:function(){return this.cm.state.completionActive==this},pick:function(i,e){var o=i.list[e];o.hint?o.hint(this.cm,i,o):this.cm.replaceRange(n(o),o.from||i.from,o.to||i.to,"complete"),t.signal(i,"pick",o),this.close()},cursorActivity:function(){this.debounce&&(f(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=u(function(){e.update()}),this.widget&&this.widget.disable()}},update:function(t){if(null!=this.tick)if(this.options.hint.async){var i=++this.tick,e=this;this.options.hint(this.cm,function(n){e.tick==i&&e.finishUpdate(n,t)},this.options)}else this.finishUpdate(this.options.hint(this.cm,this.options),t)},finishUpdate:function(i,e){this.data&&t.signal(this.data,"update"),i&&this.data&&t.cmpPos(i.from,this.data.from)&&(i=null),this.data=i;var n=this.widget&&this.widget.picked||e&&this.options.completeSingle;this.widget&&this.widget.close(),i&&i.list.length&&(n&&1==i.list.length?this.pick(i,0):(this.widget=new c(this,i),t.signal(i,"shown")))}},c.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:i<0&&(i=e?0:this.data.list.length-1),this.selectedHint!=i){var n=this.hints.childNodes[this.selectedHint];n.className=n.className.replace(" "+a,""),n=this.hints.childNodes[this.selectedHint=i],n.className+=" "+a,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",{resolve:h}),t.registerHelper("hint","fromList",function(i,e){var n=i.getCursor(),o=i.getTokenAt(n),s=t.Pos(n.line,o.end);if(o.string&&/\w/.test(o.string[o.string.length-1]))var c=o.string,r=t.Pos(n.line,o.start);else var c="",r=s;for(var h=[],l=0;l<e.words.length;l++){var a=e.words[l];a.slice(0,c.length)==c&&h.push(a)}if(h.length)return{list:h,from:r,to:s}}),t.commands.autocomplete=t.showHint;var d={hint:t.hint.auto,completeSingle:!0,alignWithWord:!0,closeCharacters:/[\s()\[\]{};:>,]/,closeOnUnfocus:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null};t.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=i,this.widget=null,this.debounce=0,this.tick=0,this.startPos=this.cm.getCursor("start"),this.startLen=this.cm.getLine(this.startPos.line).length-this.cm.getSelection().length;var e=this;t.on("cursorActivity",this.activityFunc=function(){e.cursorActivity()})}function e(i,e){var n=t.cmpPos(e.from,i.from);return n>0&&i.to.ch-i.from.ch!=e.to.ch-e.from.ch}function n(t,i,e){var n=t.options.hintOptions,o={};for(var s in m)o[s]=m[s];if(n)for(var s in n)void 0!==n[s]&&(o[s]=n[s]);if(e)for(var s in e)void 0!==e[s]&&(o[s]=e[s]);return o.hint.resolve&&(o.hint=o.hint.resolve(t,i)),o}function o(t){return"string"==typeof t?t:t.text}function s(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 r=t.options.extraKeys;if(r)for(var c in r)r.hasOwnProperty(c)&&e(c,r[c]);return s}function c(t,i){for(;i&&i!=t;){if("LI"===i.nodeName.toUpperCase()&&i.parentNode==t)return i;i=i.parentNode}}function r(i,e){this.completion=i,this.data=e,this.picked=!1;var n=this,r=i.cm,h=this.hints=document.createElement("ul");h.className="CodeMirror-hints",this.selectedHint=e.selectedHint||0;for(var l=e.list,a=0;a<l.length;++a){var d=h.appendChild(document.createElement("li")),p=l[a],m=u+(a!=this.selectedHint?"":" "+f);null!=p.className&&(m=p.className+" "+m),d.className=m,p.render?p.render(d,e,p):d.appendChild(document.createTextNode(p.displayText||o(p))),d.hintId=a}var g=r.cursorCoords(i.options.alignWithWord?e.from:null),v=g.left,y=g.bottom,w=!0;h.style.left=v+"px",h.style.top=y+"px";var H=window.innerWidth||Math.max(document.body.offsetWidth,document.documentElement.offsetWidth),k=window.innerHeight||Math.max(document.body.offsetHeight,document.documentElement.offsetHeight);(i.options.container||document.body).appendChild(h);var C=h.getBoundingClientRect(),b=C.bottom-k,x=h.scrollHeight>h.clientHeight+1,A=r.getScrollInfo();if(b>0){var S=C.bottom-C.top,T=g.top-(g.bottom-C.top);if(T-S>0)h.style.top=(y=g.top-S)+"px",w=!1;else if(S>k){h.style.height=k-5+"px",h.style.top=(y=g.bottom-C.top)+"px";var M=r.getCursor();e.from.ch!=M.ch&&(g=r.cursorCoords(M),h.style.left=(v=g.left)+"px",C=h.getBoundingClientRect())}}var F=C.right-H;if(F>0&&(C.right-C.left>H&&(h.style.width=H-5+"px",F-=C.right-C.left-H),h.style.left=(v=g.left-F)+"px"),x)for(var N=h.firstChild;N;N=N.nextSibling)N.style.paddingRight=r.display.nativeBarWidth+"px";if(r.addKeyMap(this.keyMap=s(i,{moveFocus:function(t,i){n.changeActive(n.selectedHint+t,i)},setFocus:function(t){n.changeActive(t)},menuSize:function(){return n.screenAmount()},length:l.length,close:function(){i.close()},pick:function(){n.pick()},data:e})),i.options.closeOnUnfocus){var E;r.on("blur",this.onBlur=function(){E=setTimeout(function(){i.close()},100)}),r.on("focus",this.onFocus=function(){clearTimeout(E)})}return r.on("scroll",this.onScroll=function(){var t=r.getScrollInfo(),e=r.getWrapperElement().getBoundingClientRect(),n=y+A.top-t.top,o=n-(window.pageYOffset||(document.documentElement||document.body).scrollTop);return w||(o+=h.offsetHeight),o<=e.top||o>=e.bottom?i.close():(h.style.top=n+"px",void(h.style.left=v+A.left-t.left+"px"))}),t.on(h,"dblclick",function(t){var i=c(h,t.target||t.srcElement);i&&null!=i.hintId&&(n.changeActive(i.hintId),n.pick())}),t.on(h,"click",function(t){var e=c(h,t.target||t.srcElement);e&&null!=e.hintId&&(n.changeActive(e.hintId),i.options.completeOnSingleClick&&n.pick())}),t.on(h,"mousedown",function(){setTimeout(function(){r.focus()},20)}),t.signal(e,"select",l[0],h.firstChild),!0}function h(t,i){if(!t.somethingSelected())return i;for(var e=[],n=0;n<i.length;n++)i[n].supportsSelection&&e.push(i[n]);return e}function l(t,i,e,n){if(t.async)t(i,n,e);else{var o=t(i,e);o&&o.then?o.then(n):n(o)}}function a(i,e){var n,o=i.getHelpers(e,"hint");if(o.length){var s=function(t,i,e){function n(o){return o==s.length?i(null):void l(s[o],t,e,function(t){t&&t.list.length>0?i(t):n(o+1)})}var s=h(t,o);n(0)};return s.async=!0,s.supportsSelection=!0,s}return(n=i.getHelper(i.getCursor(),"hintWords"))?function(i){return t.hint.fromList(i,{words:n})}:t.hint.anyword?function(i,e){return t.hint.anyword(i,e)}:function(){}}var u="CodeMirror-hint",f="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){e=n(this,this.getCursor("start"),e);var o=this.listSelections();if(!(o.length>1)){if(this.somethingSelected()){if(!e.hint.supportsSelection)return;for(var s=0;s<o.length;s++)if(o[s].head.line!=o[s].anchor.line)return}this.state.completionActive&&this.state.completionActive.close();var c=this.state.completionActive=new i(this,e);c.options.hint&&(t.signal(this,"startCompletion",this),c.update(!0))}});var d=window.requestAnimationFrame||function(t){return setTimeout(t,1e3/60)},p=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.data&&t.signal(this.data,"close"),this.widget&&this.widget.close(),t.signal(this.cm,"endCompletion",this.cm))},active:function(){return this.cm.state.completionActive==this},pick:function(i,e){var n=i.list[e];n.hint?n.hint(this.cm,i,n):this.cm.replaceRange(o(n),n.from||i.from,n.to||i.to,"complete"),t.signal(i,"pick",n),this.close()},cursorActivity:function(){this.debounce&&(p(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=d(function(){e.update()}),this.widget&&this.widget.disable()}},update:function(t){if(null!=this.tick){var i=this,e=++this.tick;l(this.options.hint,this.cm,this.options,function(n){i.tick==e&&i.finishUpdate(n,t)})}},finishUpdate:function(i,n){this.data&&t.signal(this.data,"update");var o=this.widget&&this.widget.picked||n&&this.options.completeSingle;this.widget&&this.widget.close(),i&&this.data&&e(this.data,i)||(this.data=i,i&&i.list.length&&(o&&1==i.list.length?this.pick(i,0):(this.widget=new r(this,i),t.signal(i,"shown"))))}},r.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:i<0&&(i=e?0:this.data.list.length-1),this.selectedHint!=i){var n=this.hints.childNodes[this.selectedHint];n.className=n.className.replace(" "+f,""),n=this.hints.childNodes[this.selectedHint=i],n.className+=" "+f,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",{resolve:a}),t.registerHelper("hint","fromList",function(i,e){var n=i.getCursor(),o=i.getTokenAt(n),s=t.Pos(n.line,o.end);if(o.string&&/\w/.test(o.string[o.string.length-1]))var c=o.string,r=t.Pos(n.line,o.start);else var c="",r=s;for(var h=[],l=0;l<e.words.length;l++){var a=e.words[l];a.slice(0,c.length)==c&&h.push(a)}if(h.length)return{list:h,from:r,to:s}}),t.commands.autocomplete=t.showHint;var m={hint:t.hint.auto,completeSingle:!0,alignWithWord:!0,closeCharacters:/[\s()\[\]{};:>,]/,closeOnUnfocus:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null};t.defineOption("hintOptions",null)});
lib/codemirror/addon/hint/sql-hint.js CHANGED
@@ -18,7 +18,9 @@
18
  QUERY_DIV: ";",
19
  ALIAS_KEYWORD: "AS"
20
  };
21
- var Pos = CodeMirror.Pos;
 
 
22
 
23
  function getKeywords(editor) {
24
  var mode = editor.doc.modeOption;
@@ -30,10 +32,28 @@
30
  return typeof item == "string" ? item : item.text;
31
  }
32
 
33
- function getItem(list, item) {
34
- if (!list.slice) return list[item];
35
- for (var i = list.length - 1; i >= 0; i--) if (getText(list[i]) == item)
36
- return list[i];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
38
 
39
  function shallowClone(object) {
@@ -50,11 +70,18 @@
50
  }
51
 
52
  function addMatches(result, search, wordlist, formatter) {
53
- for (var word in wordlist) {
54
- if (!wordlist.hasOwnProperty(word)) continue;
55
- if (wordlist.slice) word = wordlist[word];
56
-
57
- if (match(search, word)) result.push(formatter(word));
 
 
 
 
 
 
 
58
  }
59
  }
60
 
@@ -78,7 +105,7 @@
78
  }
79
 
80
  function nameCompletion(cur, token, result, editor) {
81
- // Try to complete table, colunm names and return start position of completion
82
  var useBacktick = false;
83
  var nameParts = [];
84
  var start = token.start;
@@ -115,13 +142,13 @@
115
  var alias = false;
116
  var aliasTable = table;
117
  // Check if table is available. If not, find table by Alias
118
- if (!getItem(tables, table)) {
119
  var oldTable = table;
120
  table = findTableByAlias(table, editor);
121
  if (table !== oldTable) alias = true;
122
  }
123
 
124
- var columns = getItem(tables, table);
125
  if (columns && columns.columns)
126
  columns = columns.columns;
127
 
@@ -151,15 +178,6 @@
151
  }
152
  }
153
 
154
- function convertCurToNumber(cur) {
155
- // max characters of a line is 999,999.
156
- return cur.line + cur.ch / Math.pow(10, 6);
157
- }
158
-
159
- function convertNumberToCur(num) {
160
- return Pos(Math.floor(num), +num.toString().split('.').pop());
161
- }
162
-
163
  function findTableByAlias(alias, editor) {
164
  var doc = editor.doc;
165
  var fullQuery = doc.getValue();
@@ -182,15 +200,14 @@
182
  separator.push(Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).text.length));
183
 
184
  //find valid range
185
- var prevItem = 0;
186
- var current = convertCurToNumber(editor.getCursor());
187
- for (var i=0; i< separator.length; i++) {
188
- var _v = convertCurToNumber(separator[i]);
189
- if (current > prevItem && current <= _v) {
190
- validRange = { start: convertNumberToCur(prevItem), end: convertNumberToCur(_v) };
191
  break;
192
  }
193
- prevItem = _v;
194
  }
195
 
196
  var query = doc.getRange(validRange.start, validRange.end, false);
@@ -199,7 +216,7 @@
199
  var lineText = query[i];
200
  eachWord(lineText, function(word) {
201
  var wordUpperCase = word.toUpperCase();
202
- if (wordUpperCase === aliasUpperCase && getItem(tables, previousWord))
203
  table = previousWord;
204
  if (wordUpperCase !== CONS.ALIAS_KEYWORD)
205
  previousWord = word;
@@ -210,11 +227,11 @@
210
  }
211
 
212
  CodeMirror.registerHelper("hint", "sql", function(editor, options) {
213
- tables = (options && options.tables) || {};
214
  var defaultTableName = options && options.defaultTable;
215
  var disableKeywords = options && options.disableKeywords;
216
- defaultTable = defaultTableName && getItem(tables, defaultTableName);
217
- keywords = keywords || getKeywords(editor);
218
 
219
  if (defaultTableName && !defaultTable)
220
  defaultTable = findTableByAlias(defaultTableName, editor);
18
  QUERY_DIV: ";",
19
  ALIAS_KEYWORD: "AS"
20
  };
21
+ var Pos = CodeMirror.Pos, cmpPos = CodeMirror.cmpPos;
22
+
23
+ function isArray(val) { return Object.prototype.toString.call(val) == "[object Array]" }
24
 
25
  function getKeywords(editor) {
26
  var mode = editor.doc.modeOption;
32
  return typeof item == "string" ? item : item.text;
33
  }
34
 
35
+ function wrapTable(name, value) {
36
+ if (isArray(value)) value = {columns: value}
37
+ if (!value.text) value.text = name
38
+ return value
39
+ }
40
+
41
+ function parseTables(input) {
42
+ var result = {}
43
+ if (isArray(input)) {
44
+ for (var i = input.length - 1; i >= 0; i--) {
45
+ var item = input[i]
46
+ result[getText(item).toUpperCase()] = wrapTable(getText(item), item)
47
+ }
48
+ } else if (input) {
49
+ for (var name in input)
50
+ result[name.toUpperCase()] = wrapTable(name, input[name])
51
+ }
52
+ return result
53
+ }
54
+
55
+ function getTable(name) {
56
+ return tables[name.toUpperCase()]
57
  }
58
 
59
  function shallowClone(object) {
70
  }
71
 
72
  function addMatches(result, search, wordlist, formatter) {
73
+ if (isArray(wordlist)) {
74
+ for (var i = 0; i < wordlist.length; i++)
75
+ if (match(search, wordlist[i])) result.push(formatter(wordlist[i]))
76
+ } else {
77
+ for (var word in wordlist) if (wordlist.hasOwnProperty(word)) {
78
+ var val = wordlist[word]
79
+ if (!val || val === true)
80
+ val = word
81
+ else
82
+ val = val.displayText ? {text: val.text, displayText: val.displayText} : val.text
83
+ if (match(search, val)) result.push(formatter(val))
84
+ }
85
  }
86
  }
87
 
105
  }
106
 
107
  function nameCompletion(cur, token, result, editor) {
108
+ // Try to complete table, column names and return start position of completion
109
  var useBacktick = false;
110
  var nameParts = [];
111
  var start = token.start;
142
  var alias = false;
143
  var aliasTable = table;
144
  // Check if table is available. If not, find table by Alias
145
+ if (!getTable(table)) {
146
  var oldTable = table;
147
  table = findTableByAlias(table, editor);
148
  if (table !== oldTable) alias = true;
149
  }
150
 
151
+ var columns = getTable(table);
152
  if (columns && columns.columns)
153
  columns = columns.columns;
154
 
178
  }
179
  }
180
 
 
 
 
 
 
 
 
 
 
181
  function findTableByAlias(alias, editor) {
182
  var doc = editor.doc;
183
  var fullQuery = doc.getValue();
200
  separator.push(Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).text.length));
201
 
202
  //find valid range
203
+ var prevItem = null;
204
+ var current = editor.getCursor()
205
+ for (var i = 0; i < separator.length; i++) {
206
+ if ((prevItem == null || cmpPos(current, prevItem) > 0) && cmpPos(current, separator[i]) <= 0) {
207
+ validRange = {start: prevItem, end: separator[i]};
 
208
  break;
209
  }
210
+ prevItem = separator[i];
211
  }
212
 
213
  var query = doc.getRange(validRange.start, validRange.end, false);
216
  var lineText = query[i];
217
  eachWord(lineText, function(word) {
218
  var wordUpperCase = word.toUpperCase();
219
+ if (wordUpperCase === aliasUpperCase && getTable(previousWord))
220
  table = previousWord;
221
  if (wordUpperCase !== CONS.ALIAS_KEYWORD)
222
  previousWord = word;
227
  }
228
 
229
  CodeMirror.registerHelper("hint", "sql", function(editor, options) {
230
+ tables = parseTables(options && options.tables)
231
  var defaultTableName = options && options.defaultTable;
232
  var disableKeywords = options && options.disableKeywords;
233
+ defaultTable = defaultTableName && getTable(defaultTableName);
234
+ keywords = getKeywords(editor);
235
 
236
  if (defaultTableName && !defaultTable)
237
  defaultTable = findTableByAlias(defaultTableName, editor);
lib/codemirror/addon/hint/sql-hint.min.js CHANGED
@@ -1 +1 @@
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,d,function(t){return f?u(t):t}),s(n,v,h,function(t){return f?u(t):t}),v=c.pop();var m=c.join("."),b=!1,x=m;if(!e(d,m)){var y=m;m=g(m,i),m!==y&&(b=!0)}var q=e(d,m);return q&&q.columns&&(q=q.columns),q&&s(n,v,q,function(t){var r=m;return 1==b&&(r=x),"string"==typeof t?t=r+"."+t:(t=o(t),t.text=r+"."+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);g!=-1;)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 h=0,v=l(r.getCursor()),b=0;b<u.length;b++){var x=l(u[b]);if(v>h&&v<=x){f={start:p(h),end:p(x)};break}h=x}for(var y=n.getRange(f.start,f.end,!1),b=0;b<y.length;b++){var q=y[b];if(c(q,function(t){var r=t.toUpperCase();r===i&&e(d,s)&&(a=s),r!==m.ALIAS_KEYWORD&&(s=t)}),a)break}return a}var d,h,v,m={QUERY_DIV:";",ALIAS_KEYWORD:"AS"},A=t.Pos;t.registerHelper("hint","sql",function(t,n){d=n&&n.tables||{};var o=n&&n.defaultTable,i=n&&n.disableKeywords;h=o&&e(d,o),v=v||r(t),o&&!h&&(h=g(o,t)),h=h||[],h.columns&&(h=h.columns);var a,u,c,l=t.getCursor(),p=[],m=t.getTokenAt(l);return m.end>l.ch&&(m.end=l.ch,m.string=m.string.slice(0,l.ch-m.start)),m.string.match(/^[.`\w@]\w*$/)?(c=m.string,a=m.start,u=m.end):(a=u=l.ch,c=""),"."==c.charAt(0)||"`"==c.charAt(0)?a=f(l,m,p,t):(s(p,c,d,function(t){return t}),s(p,c,h,function(t){return t}),i||s(p,c,v,function(t){return t.toUpperCase()})),{list:p,from:A(l.line,a),to:A(l.line,u)}})});
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(t){return"[object Array]"==Object.prototype.toString.call(t)}function e(r){var e=r.doc.modeOption;return"sql"===e&&(e="text/x-sql"),t.resolveMode(e).keywords}function n(t){return"string"==typeof t?t:t.text}function o(t,e){return r(e)&&(e={columns:e}),e.text||(e.text=t),e}function i(t){var e={};if(r(t))for(var i=t.length-1;i>=0;i--){var s=t[i];e[n(s).toUpperCase()]=o(n(s),s)}else if(t)for(var a in t)e[a.toUpperCase()]=o(a,t[a]);return e}function s(t){return v[t.toUpperCase()]}function a(t){var r={};for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e]);return r}function u(t,r){var e=t.length,o=n(r).substr(0,e);return t.toUpperCase()===o.toUpperCase()}function f(t,e,n,o){if(r(n))for(var i=0;i<n.length;i++)u(e,n[i])&&t.push(o(n[i]));else for(var s in n)if(n.hasOwnProperty(s)){var a=n[s];a=a&&a!==!0?a.displayText?{text:a.text,displayText:a.displayText}:a.text:s,u(e,a)&&t.push(o(a))}}function l(t){return"."==t.charAt(0)&&(t=t.substr(1)),t.replace(/`/g,"")}function c(t){for(var r=n(t).split("."),e=0;e<r.length;e++)r[e]="`"+r[e]+"`";var o=r.join(".");return"string"==typeof t?o:(t=a(t),t.text=o,t)}function p(t,r,e,n){for(var o=!1,i=[],u=r.start,p=!0;p;)p="."==r.string.charAt(0),o=o||"`"==r.string.charAt(0),u=r.start,i.unshift(l(r.string)),r=n.getTokenAt(y(t.line,r.start)),"."==r.string&&(p=!0,r=n.getTokenAt(y(t.line,r.start)));var g=i.join(".");f(e,g,v,function(t){return o?c(t):t}),f(e,g,h,function(t){return o?c(t):t}),g=i.pop();var x=i.join("."),m=!1,A=x;if(!s(x)){var b=x;x=d(x,n),x!==b&&(m=!0)}var C=s(x);return C&&C.columns&&(C=C.columns),C&&f(e,g,C,function(t){var r=x;return 1==m&&(r=A),"string"==typeof t?t=r+"."+t:(t=a(t),t.text=r+"."+t.text),o?c(t):t}),u}function g(t,r){if(t)for(var e=/[,;]/g,n=t.split(" "),o=0;o<n.length;o++)r(n[o]?n[o].replace(e,""):"")}function d(t,r){for(var e=r.doc,n=e.getValue(),o=t.toUpperCase(),i="",a="",u=[],f={start:y(0,0),end:y(r.lastLine(),r.getLineHandle(r.lastLine()).length)},l=n.indexOf(m.QUERY_DIV);l!=-1;)u.push(e.posFromIndex(l)),l=n.indexOf(m.QUERY_DIV,l+1);u.unshift(y(0,0)),u.push(y(r.lastLine(),r.getLineHandle(r.lastLine()).text.length));for(var c=null,p=r.getCursor(),d=0;d<u.length;d++){if((null==c||A(p,c)>0)&&A(p,u[d])<=0){f={start:c,end:u[d]};break}c=u[d]}for(var v=e.getRange(f.start,f.end,!1),d=0;d<v.length;d++){var h=v[d];if(g(h,function(t){var r=t.toUpperCase();r===o&&s(i)&&(a=i),r!==m.ALIAS_KEYWORD&&(i=t)}),a)break}return a}var v,h,x,m={QUERY_DIV:";",ALIAS_KEYWORD:"AS"},y=t.Pos,A=t.cmpPos;t.registerHelper("hint","sql",function(t,r){v=i(r&&r.tables);var n=r&&r.defaultTable,o=r&&r.disableKeywords;h=n&&s(n),x=e(t),n&&!h&&(h=d(n,t)),h=h||[],h.columns&&(h=h.columns);var a,u,l,c=t.getCursor(),g=[],m=t.getTokenAt(c);return m.end>c.ch&&(m.end=c.ch,m.string=m.string.slice(0,c.ch-m.start)),m.string.match(/^[.`\w@]\w*$/)?(l=m.string,a=m.start,u=m.end):(a=u=c.ch,l=""),"."==l.charAt(0)||"`"==l.charAt(0)?a=p(c,m,g,t):(f(g,l,v,function(t){return t}),f(g,l,h,function(t){return t}),o||f(g,l,x,function(t){return t.toUpperCase()})),{list:g,from:y(c.line,a),to:y(c.line,u)}})});
lib/codemirror/addon/lint/css-lint.js CHANGED
@@ -26,7 +26,7 @@ CodeMirror.registerHelper("lint", "css", function(text) {
26
  "empty-rules": 1,
27
  "known-properties": 1
28
  }), messages = results.messages, message = null;
29
-
30
  for ( var i = 0; i < messages.length; i++) {
31
  message = messages[i];
32
  var startLine = message.line -1, endLine = message.line -1, startCol = message.col -1, endCol = message.col;
26
  "empty-rules": 1,
27
  "known-properties": 1
28
  }), messages = results.messages, message = null;
29
+
30
  for ( var i = 0; i < messages.length; i++) {
31
  message = messages[i];
32
  var startLine = message.line -1, endLine = message.line -1, startCol = message.col -1, endCol = message.col;
lib/codemirror/addon/lint/lint.css CHANGED
@@ -4,10 +4,10 @@
4
  }
5
 
6
  .CodeMirror-lint-tooltip {
7
- background-color: infobackground;
8
  border: 1px solid black;
9
  border-radius: 4px 4px 4px 4px;
10
- color: infotext;
11
  font-family: monospace;
12
  font-size: 10pt;
13
  overflow: hidden;
4
  }
5
 
6
  .CodeMirror-lint-tooltip {
7
+ background-color: #ffd;
8
  border: 1px solid black;
9
  border-radius: 4px 4px 4px 4px;
10
+ color: black;
11
  font-family: monospace;
12
  font-size: 10pt;
13
  overflow: hidden;
lib/codemirror/addon/lint/lint.js CHANGED
@@ -186,9 +186,14 @@
186
  state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
187
  }
188
 
189
- function popupSpanTooltip(ann, e) {
190
  var target = e.target || e.srcElement;
191
- showTooltipFor(e, annotationTooltip(ann), target);
 
 
 
 
 
192
  }
193
 
194
  function onMouseOver(cm, e) {
@@ -196,10 +201,13 @@
196
  if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
197
  var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
198
  var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
 
 
199
  for (var i = 0; i < spans.length; ++i) {
200
  var ann = spans[i].__annotation;
201
- if (ann) return popupSpanTooltip(ann, e);
202
  }
 
203
  }
204
 
205
  CodeMirror.defineOption("lint", false, function(cm, val, old) {
@@ -218,7 +226,7 @@
218
  var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
219
  if (state.options.lintOnChange !== false)
220
  cm.on("change", onChange);
221
- if (state.options.tooltips != false)
222
  CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
223
 
224
  startLinting(cm);
186
  state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
187
  }
188
 
189
+ function popupTooltips(annotations, e) {
190
  var target = e.target || e.srcElement;
191
+ var tooltip = document.createDocumentFragment();
192
+ for (var i = 0; i < annotations.length; i++) {
193
+ var ann = annotations[i];
194
+ tooltip.appendChild(annotationTooltip(ann));
195
+ }
196
+ showTooltipFor(e, tooltip, target);
197
  }
198
 
199
  function onMouseOver(cm, e) {
201
  if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
202
  var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
203
  var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
204
+
205
+ var annotations = [];
206
  for (var i = 0; i < spans.length; ++i) {
207
  var ann = spans[i].__annotation;
208
+ if (ann) annotations.push(ann);
209
  }
210
+ if (annotations.length) popupTooltips(annotations, e);
211
  }
212
 
213
  CodeMirror.defineOption("lint", false, function(cm, val, old) {
226
  var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
227
  if (state.options.lintOnChange !== false)
228
  cm.on("change", onChange);
229
+ if (state.options.tooltips != false && state.options.tooltips != "gutter")
230
  CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
231
 
232
  startLinting(cm);
lib/codemirror/addon/lint/lint.min.js CHANGED
@@ -1 +1 @@
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),l&&(o(l),l=null)}var l=e(n,r),s=setInterval(function(){if(l)for(var t=i;;t=t.parentNode){if(t&&11==t.nodeType&&(t=t.host),t==document.body)return;if(!t){a();break}}if(!l)return clearInterval(s)},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)},this.waitingFor=0}function a(t,e){return e instanceof Function?{getAnnotations:e}:(e&&e!==!0||(e={}),e)}function l(t){var e=t.state.lint;e.hasGutter&&t.clearGutter(y);for(var n=0;n<e.marked.length;++n)e.marked[n].clear();e.marked.length=0}function s(e,n,o,i){var a=document.createElement("div"),l=a;return a.className="CodeMirror-lint-marker-"+n,o&&(l=a.appendChild(document.createElement("div")),l.className="CodeMirror-lint-marker-multiple"),0!=i&&t.on(l,"mouseover",function(t){r(t,e,l)}),a}function u(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(e,n,o){function r(){a=-1,e.off("change",r)}var i=e.state.lint,a=++i.waitingFor;e.on("change",r),n(e.getValue(),function(n,o){e.off("change",r),i.waitingFor==a&&(o&&n instanceof t&&(n=o),p(e,n))},o,e)}function d(e){var n=e.state.lint,o=n.options,r=o.options||o,i=o.getAnnotations||e.getHelper(t.Pos(0,0),"lint");i&&(o.async||i.async?m(e,i,r):p(e,i(e.getValue(),r,e)))}function p(t,e){l(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],h=v.severity;h||(h="error"),m=u(m,h),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-"+h,__annotation:v}))}n.hasGutter&&t.setGutterMarker(i,y,s(d,m,a.length>1,n.options.tooltips))}}o.onUpdateLinting&&o.onUpdateLinting(e,r,t)}function v(t){var e=t.state.lint;e&&(clearTimeout(e.timeout),e.timeout=setTimeout(function(){d(t)},e.options.delay||500))}function h(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")),l=0;l<a.length;++l){var s=a[l].__annotation;if(s)return h(s,e)}}var y="CodeMirror-lint-markers";t.defineOption("lint",!1,function(e,n,o){if(o&&o!=t.Init&&(l(e),e.state.lint.options.lintOnChange!==!1&&e.off("change",v),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"),s=!1,u=0;u<r.length;++u)r[u]==y&&(s=!0);var c=e.state.lint=new i(e,a(e,n),s);c.options.lintOnChange!==!1&&e.on("change",v),0!=c.options.tooltips&&t.on(e.getWrapperElement(),"mouseover",c.onMouseOver),d(e)}}),t.defineExtension("performLint",function(){this.state.lint&&d(this)})});
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),l&&(o(l),l=null)}var l=e(n,r),s=setInterval(function(){if(l)for(var t=i;;t=t.parentNode){if(t&&11==t.nodeType&&(t=t.host),t==document.body)return;if(!t){a();break}}if(!l)return clearInterval(s)},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)},this.waitingFor=0}function a(t,e){return e instanceof Function?{getAnnotations:e}:(e&&e!==!0||(e={}),e)}function l(t){var e=t.state.lint;e.hasGutter&&t.clearGutter(y);for(var n=0;n<e.marked.length;++n)e.marked[n].clear();e.marked.length=0}function s(e,n,o,i){var a=document.createElement("div"),l=a;return a.className="CodeMirror-lint-marker-"+n,o&&(l=a.appendChild(document.createElement("div")),l.className="CodeMirror-lint-marker-multiple"),0!=i&&t.on(l,"mouseover",function(t){r(t,e,l)}),a}function u(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(e,n,o){function r(){a=-1,e.off("change",r)}var i=e.state.lint,a=++i.waitingFor;e.on("change",r),n(e.getValue(),function(n,o){e.off("change",r),i.waitingFor==a&&(o&&n instanceof t&&(n=o),p(e,n))},o,e)}function d(e){var n=e.state.lint,o=n.options,r=o.options||o,i=o.getAnnotations||e.getHelper(t.Pos(0,0),"lint");i&&(o.async||i.async?m(e,i,r):p(e,i(e.getValue(),r,e)))}function p(t,e){l(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 h=a[p],v=h.severity;v||(v="error"),m=u(m,v),o.formatAnnotation&&(h=o.formatAnnotation(h)),n.hasGutter&&d.appendChild(f(h)),h.to&&n.marked.push(t.markText(h.from,h.to,{className:"CodeMirror-lint-mark-"+v,__annotation:h}))}n.hasGutter&&t.setGutterMarker(i,y,s(d,m,a.length>1,n.options.tooltips))}}o.onUpdateLinting&&o.onUpdateLinting(e,r,t)}function h(t){var e=t.state.lint;e&&(clearTimeout(e.timeout),e.timeout=setTimeout(function(){d(t)},e.options.delay||500))}function v(t,e){for(var n=e.target||e.srcElement,o=document.createDocumentFragment(),i=0;i<t.length;i++){var a=t[i];o.appendChild(f(a))}r(e,o,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")),l=[],s=0;s<a.length;++s){var u=a[s].__annotation;u&&l.push(u)}l.length&&v(l,e)}}var y="CodeMirror-lint-markers";t.defineOption("lint",!1,function(e,n,o){if(o&&o!=t.Init&&(l(e),e.state.lint.options.lintOnChange!==!1&&e.off("change",h),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"),s=!1,u=0;u<r.length;++u)r[u]==y&&(s=!0);var c=e.state.lint=new i(e,a(e,n),s);c.options.lintOnChange!==!1&&e.on("change",h),0!=c.options.tooltips&&"gutter"!=c.options.tooltips&&t.on(e.getWrapperElement(),"mouseover",c.onMouseOver),d(e)}}),t.defineExtension("performLint",function(){this.state.lint&&d(this)})});
lib/codemirror/addon/merge/merge.css CHANGED
@@ -60,6 +60,7 @@
60
  position: absolute;
61
  cursor: pointer;
62
  color: #44c;
 
63
  }
64
 
65
  .CodeMirror-merge-copy-reverse {
60
  position: absolute;
61
  cursor: pointer;
62
  color: #44c;
63
+ z-index: 3;
64
  }
65
 
66
  .CodeMirror-merge-copy-reverse {
lib/codemirror/addon/merge/merge.js CHANGED
@@ -40,12 +40,17 @@
40
  (this.edit.state.diffViews || (this.edit.state.diffViews = [])).push(this);
41
  this.orig = CodeMirror(pane, copyObj({value: orig, readOnly: !this.mv.options.allowEditingOriginals}, copyObj(options)));
42
  this.orig.state.diffViews = [this];
 
 
 
43
 
44
  this.diff = getDiff(asString(orig), asString(options.value));
45
  this.chunks = getChunks(this.diff);
46
  this.diffOutOfDate = this.dealigned = false;
47
 
48
  this.showDifferences = options.showDifferences !== false;
 
 
49
  this.forceUpdate = registerUpdate(this);
50
  setScrollLock(this, true, false);
51
  registerScroll(this);
@@ -88,10 +93,11 @@
88
  updateMarks(dv.edit, dv.diff, edit, DIFF_INSERT, dv.classes);
89
  updateMarks(dv.orig, dv.diff, orig, DIFF_DELETE, dv.classes);
90
  }
91
- makeConnections(dv);
92
 
93
  if (dv.mv.options.connect == "align")
94
  alignChunks(dv);
 
 
95
  updating = false;
96
  }
97
  function setDealign(fast) {
@@ -113,8 +119,14 @@
113
  // Update faster when a line was added/removed
114
  setDealign(change.text.length - 1 != change.to.line - change.from.line);
115
  }
 
 
 
 
116
  dv.edit.on("change", change);
117
  dv.orig.on("change", change);
 
 
118
  dv.edit.on("markerAdded", setDealign);
119
  dv.edit.on("markerCleared", setDealign);
120
  dv.orig.on("markerAdded", setDealign);
@@ -191,16 +203,22 @@
191
 
192
  // Updating the marks for editor content
193
 
 
 
 
 
 
 
 
 
 
194
  function clearMarks(editor, arr, classes) {
195
  for (var i = 0; i < arr.length; ++i) {
196
  var mark = arr[i];
197
- if (mark instanceof CodeMirror.TextMarker) {
198
  mark.clear();
199
- } else if (mark.parent) {
200
- editor.removeLineClass(mark, "background", classes.chunk);
201
- editor.removeLineClass(mark, "background", classes.start);
202
- editor.removeLineClass(mark, "background", classes.end);
203
- }
204
  }
205
  arr.length = 0;
206
  }
@@ -226,24 +244,30 @@
226
  });
227
  }
228
 
 
 
 
 
 
 
 
 
 
 
229
  function markChanges(editor, diff, type, marks, from, to, classes) {
230
  var pos = Pos(0, 0);
231
  var top = Pos(from, 0), bot = editor.clipPos(Pos(to - 1));
232
  var cls = type == DIFF_DELETE ? classes.del : classes.insert;
233
  function markChunk(start, end) {
234
  var bfrom = Math.max(from, start), bto = Math.min(to, end);
235
- for (var i = bfrom; i < bto; ++i) {
236
- var line = editor.addLineClass(i, "background", classes.chunk);
237
- if (i == start) editor.addLineClass(line, "background", classes.start);
238
- if (i == end - 1) editor.addLineClass(line, "background", classes.end);
239
- marks.push(line);
240
- }
241
  // When the chunk is empty, make sure a horizontal line shows up
242
  if (start == end && bfrom == end && bto == end) {
243
  if (bfrom)
244
- marks.push(editor.addLineClass(bfrom - 1, "background", classes.end));
245
  else
246
- marks.push(editor.addLineClass(bfrom, "background", classes.start));
247
  }
248
  }
249
 
@@ -284,7 +308,9 @@
284
  if (dv.copyButtons) clear(dv.copyButtons);
285
 
286
  var vpEdit = dv.edit.getViewport(), vpOrig = dv.orig.getViewport();
287
- var sTopEdit = dv.edit.getScrollInfo().top, sTopOrig = dv.orig.getScrollInfo().top;
 
 
288
  for (var i = 0; i < dv.chunks.length; i++) {
289
  var ch = dv.chunks[i];
290
  if (ch.editFrom <= vpEdit.to && ch.editTo >= vpEdit.from &&
@@ -312,19 +338,14 @@
312
  linesToAlign.push([chunk.origTo, chunk.editTo, other ? getMatchingOrigLine(chunk.editTo, other.chunks) : null]);
313
  }
314
  if (other) {
315
- for (var i = 0; i < other.chunks.length; i++) {
316
  var chunk = other.chunks[i];
317
  for (var j = 0; j < linesToAlign.length; j++) {
318
- var align = linesToAlign[j];
319
- if (align[1] == chunk.editTo) {
320
- j = -1;
321
- break;
322
- } else if (align[1] > chunk.editTo) {
323
- break;
324
- }
325
  }
326
- if (j > -1)
327
- linesToAlign.splice(j - 1, 0, [getMatchingOrigLine(chunk.editTo, dv.chunks), chunk.editTo, chunk.origTo]);
328
  }
329
  }
330
  return linesToAlign;
@@ -390,13 +411,13 @@
390
 
391
  function drawConnectorsForChunk(dv, chunk, sTopOrig, sTopEdit, w) {
392
  var flip = dv.type == "left";
393
- var top = dv.orig.heightAtLine(chunk.origFrom, "local") - sTopOrig;
394
  if (dv.svg) {
395
  var topLpx = top;
396
- var topRpx = dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit;
397
  if (flip) { var tmp = topLpx; topLpx = topRpx; topRpx = tmp; }
398
- var botLpx = dv.orig.heightAtLine(chunk.origTo, "local") - sTopOrig;
399
- var botRpx = dv.edit.heightAtLine(chunk.editTo, "local") - sTopEdit;
400
  if (flip) { var tmp = botLpx; botLpx = botRpx; botRpx = tmp; }
401
  var curveTop = " C " + w/2 + " " + topRpx + " " + w/2 + " " + topLpx + " " + (w + 2) + " " + topLpx;
402
  var curveBot = " C " + w/2 + " " + botLpx + " " + w/2 + " " + botRpx + " -1 " + botRpx;
@@ -410,10 +431,10 @@
410
  var editOriginals = dv.mv.options.allowEditingOriginals;
411
  copy.title = editOriginals ? "Push to left" : "Revert chunk";
412
  copy.chunk = chunk;
413
- copy.style.top = top + "px";
414
 
415
  if (editOriginals) {
416
- var topReverse = dv.orig.heightAtLine(chunk.editFrom, "local") - sTopEdit;
417
  var copyReverse = dv.copyButtons.appendChild(elt("div", dv.type == "right" ? "\u21dd" : "\u21dc",
418
  "CodeMirror-merge-copy-reverse"));
419
  copyReverse.title = "Push to right";
@@ -427,8 +448,9 @@
427
 
428
  function copyChunk(dv, to, from, chunk) {
429
  if (dv.diffOutOfDate) return;
430
- to.replaceRange(from.getRange(Pos(chunk.origFrom, 0), Pos(chunk.origTo, 0)),
431
- Pos(chunk.editFrom, 0), Pos(chunk.editTo, 0));
 
432
  }
433
 
434
  // Merge view, containing 0, 1, or 2 diff views.
@@ -446,18 +468,18 @@
446
 
447
  if (hasLeft) {
448
  left = this.left = new DiffView(this, "left");
449
- var leftPane = elt("div", null, "CodeMirror-merge-pane");
450
  wrap.push(leftPane);
451
  wrap.push(buildGap(left));
452
  }
453
 
454
- var editPane = elt("div", null, "CodeMirror-merge-pane");
455
  wrap.push(editPane);
456
 
457
  if (hasRight) {
458
  right = this.right = new DiffView(this, "right");
459
  wrap.push(buildGap(right));
460
- var rightPane = elt("div", null, "CodeMirror-merge-pane");
461
  wrap.push(rightPane);
462
  }
463
 
@@ -470,7 +492,6 @@
470
 
471
  if (left) left.init(leftPane, origLeft, options);
472
  if (right) right.init(rightPane, origRight, options);
473
-
474
  if (options.collapseIdentical)
475
  this.editor().operation(function() {
476
  collapseIdenticalStretches(self, options.collapseIdentical);
@@ -479,6 +500,9 @@
479
  this.aligners = [];
480
  alignChunks(this.left || this.right, true);
481
  }
 
 
 
482
 
483
  var onResize = function() {
484
  if (left) makeConnections(left);
@@ -521,7 +545,7 @@
521
  }
522
 
523
  MergeView.prototype = {
524
- constuctor: MergeView,
525
  editor: function() { return this.edit; },
526
  rightOriginal: function() { return this.right && this.right.orig; },
527
  leftOriginal: function() { return this.left && this.left.orig; },
@@ -547,7 +571,6 @@
547
  var dmp = new diff_match_patch();
548
  function getDiff(a, b) {
549
  var diff = dmp.diff_main(a, b);
550
- dmp.diff_cleanupSemantic(diff);
551
  // The library sometimes leaves in empty parts, which confuse the algorithm
552
  for (var i = 0; i < diff.length; ++i) {
553
  var part = diff[i];
40
  (this.edit.state.diffViews || (this.edit.state.diffViews = [])).push(this);
41
  this.orig = CodeMirror(pane, copyObj({value: orig, readOnly: !this.mv.options.allowEditingOriginals}, copyObj(options)));
42
  this.orig.state.diffViews = [this];
43
+ var classLocation = options.chunkClassLocation || "background";
44
+ if (Object.prototype.toString.call(classLocation) != "[object Array]") classLocation = [classLocation]
45
+ this.classes.classLocation = classLocation
46
 
47
  this.diff = getDiff(asString(orig), asString(options.value));
48
  this.chunks = getChunks(this.diff);
49
  this.diffOutOfDate = this.dealigned = false;
50
 
51
  this.showDifferences = options.showDifferences !== false;
52
+ },
53
+ registerEvents: function() {
54
  this.forceUpdate = registerUpdate(this);
55
  setScrollLock(this, true, false);
56
  registerScroll(this);
93
  updateMarks(dv.edit, dv.diff, edit, DIFF_INSERT, dv.classes);
94
  updateMarks(dv.orig, dv.diff, orig, DIFF_DELETE, dv.classes);
95
  }
 
96
 
97
  if (dv.mv.options.connect == "align")
98
  alignChunks(dv);
99
+ makeConnections(dv);
100
+
101
  updating = false;
102
  }
103
  function setDealign(fast) {
119
  // Update faster when a line was added/removed
120
  setDealign(change.text.length - 1 != change.to.line - change.from.line);
121
  }
122
+ function swapDoc() {
123
+ dv.diffOutOfDate = true;
124
+ update("full");
125
+ }
126
  dv.edit.on("change", change);
127
  dv.orig.on("change", change);
128
+ dv.edit.on("swapDoc", swapDoc);
129
+ dv.orig.on("swapDoc", swapDoc);
130
  dv.edit.on("markerAdded", setDealign);
131
  dv.edit.on("markerCleared", setDealign);
132
  dv.orig.on("markerAdded", setDealign);
203
 
204
  // Updating the marks for editor content
205
 
206
+ function removeClass(editor, line, classes) {
207
+ var locs = classes.classLocation
208
+ for (var i = 0; i < locs.length; i++) {
209
+ editor.removeLineClass(line, locs[i], classes.chunk);
210
+ editor.removeLineClass(line, locs[i], classes.start);
211
+ editor.removeLineClass(line, locs[i], classes.end);
212
+ }
213
+ }
214
+
215
  function clearMarks(editor, arr, classes) {
216
  for (var i = 0; i < arr.length; ++i) {
217
  var mark = arr[i];
218
+ if (mark instanceof CodeMirror.TextMarker)
219
  mark.clear();
220
+ else if (mark.parent)
221
+ removeClass(editor, mark, classes);
 
 
 
222
  }
223
  arr.length = 0;
224
  }
244
  });
245
  }
246
 
247
+ function addClass(editor, lineNr, classes, main, start, end) {
248
+ var locs = classes.classLocation, line = editor.getLineHandle(lineNr);
249
+ for (var i = 0; i < locs.length; i++) {
250
+ if (main) editor.addLineClass(line, locs[i], classes.chunk);
251
+ if (start) editor.addLineClass(line, locs[i], classes.start);
252
+ if (end) editor.addLineClass(line, locs[i], classes.end);
253
+ }
254
+ return line;
255
+ }
256
+
257
  function markChanges(editor, diff, type, marks, from, to, classes) {
258
  var pos = Pos(0, 0);
259
  var top = Pos(from, 0), bot = editor.clipPos(Pos(to - 1));
260
  var cls = type == DIFF_DELETE ? classes.del : classes.insert;
261
  function markChunk(start, end) {
262
  var bfrom = Math.max(from, start), bto = Math.min(to, end);
263
+ for (var i = bfrom; i < bto; ++i)
264
+ marks.push(addClass(editor, i, classes, true, i == start, i == end - 1));
 
 
 
 
265
  // When the chunk is empty, make sure a horizontal line shows up
266
  if (start == end && bfrom == end && bto == end) {
267
  if (bfrom)
268
+ marks.push(addClass(editor, bfrom - 1, classes, false, false, true));
269
  else
270
+ marks.push(addClass(editor, bfrom, classes, false, true, false));
271
  }
272
  }
273
 
308
  if (dv.copyButtons) clear(dv.copyButtons);
309
 
310
  var vpEdit = dv.edit.getViewport(), vpOrig = dv.orig.getViewport();
311
+ var outerTop = dv.mv.wrap.getBoundingClientRect().top
312
+ var sTopEdit = outerTop - dv.edit.getScrollerElement().getBoundingClientRect().top + dv.edit.getScrollInfo().top
313
+ var sTopOrig = outerTop - dv.orig.getScrollerElement().getBoundingClientRect().top + dv.orig.getScrollInfo().top;
314
  for (var i = 0; i < dv.chunks.length; i++) {
315
  var ch = dv.chunks[i];
316
  if (ch.editFrom <= vpEdit.to && ch.editTo >= vpEdit.from &&
338
  linesToAlign.push([chunk.origTo, chunk.editTo, other ? getMatchingOrigLine(chunk.editTo, other.chunks) : null]);
339
  }
340
  if (other) {
341
+ chunkLoop: for (var i = 0; i < other.chunks.length; i++) {
342
  var chunk = other.chunks[i];
343
  for (var j = 0; j < linesToAlign.length; j++) {
344
+ var diff = linesToAlign[j][1] - chunk.editTo;
345
+ if (diff == 0) continue chunkLoop
346
+ if (diff > 0) break;
 
 
 
 
347
  }
348
+ linesToAlign.splice(j, 0, [getMatchingOrigLine(chunk.editTo, dv.chunks), chunk.editTo, chunk.origTo]);
 
349
  }
350
  }
351
  return linesToAlign;
411
 
412
  function drawConnectorsForChunk(dv, chunk, sTopOrig, sTopEdit, w) {
413
  var flip = dv.type == "left";
414
+ var top = dv.orig.heightAtLine(chunk.origFrom, "local", true) - sTopOrig;
415
  if (dv.svg) {
416
  var topLpx = top;
417
+ var topRpx = dv.edit.heightAtLine(chunk.editFrom, "local", true) - sTopEdit;
418
  if (flip) { var tmp = topLpx; topLpx = topRpx; topRpx = tmp; }
419
+ var botLpx = dv.orig.heightAtLine(chunk.origTo, "local", true) - sTopOrig;
420
+ var botRpx = dv.edit.heightAtLine(chunk.editTo, "local", true) - sTopEdit;
421
  if (flip) { var tmp = botLpx; botLpx = botRpx; botRpx = tmp; }
422
  var curveTop = " C " + w/2 + " " + topRpx + " " + w/2 + " " + topLpx + " " + (w + 2) + " " + topLpx;
423
  var curveBot = " C " + w/2 + " " + botLpx + " " + w/2 + " " + botRpx + " -1 " + botRpx;
431
  var editOriginals = dv.mv.options.allowEditingOriginals;
432
  copy.title = editOriginals ? "Push to left" : "Revert chunk";
433
  copy.chunk = chunk;
434
+ copy.style.top = (chunk.origTo > chunk.origFrom ? top : dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit) + "px";
435
 
436
  if (editOriginals) {
437
+ var topReverse = dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit;
438
  var copyReverse = dv.copyButtons.appendChild(elt("div", dv.type == "right" ? "\u21dd" : "\u21dc",
439
  "CodeMirror-merge-copy-reverse"));
440
  copyReverse.title = "Push to right";
448
 
449
  function copyChunk(dv, to, from, chunk) {
450
  if (dv.diffOutOfDate) return;
451
+ var editStart = chunk.editTo > to.lastLine() ? Pos(chunk.editFrom - 1) : Pos(chunk.editFrom, 0)
452
+ var origStart = chunk.origTo > from.lastLine() ? Pos(chunk.origFrom - 1) : Pos(chunk.origFrom, 0)
453
+ to.replaceRange(from.getRange(origStart, Pos(chunk.origTo, 0)), editStart, Pos(chunk.editTo, 0))
454
  }
455
 
456
  // Merge view, containing 0, 1, or 2 diff views.
468
 
469
  if (hasLeft) {
470
  left = this.left = new DiffView(this, "left");
471
+ var leftPane = elt("div", null, "CodeMirror-merge-pane CodeMirror-merge-left");
472
  wrap.push(leftPane);
473
  wrap.push(buildGap(left));
474
  }
475
 
476
+ var editPane = elt("div", null, "CodeMirror-merge-pane CodeMirror-merge-editor");
477
  wrap.push(editPane);
478
 
479
  if (hasRight) {
480
  right = this.right = new DiffView(this, "right");
481
  wrap.push(buildGap(right));
482
+ var rightPane = elt("div", null, "CodeMirror-merge-pane CodeMirror-merge-right");
483
  wrap.push(rightPane);
484
  }
485
 
492
 
493
  if (left) left.init(leftPane, origLeft, options);
494
  if (right) right.init(rightPane, origRight, options);
 
495
  if (options.collapseIdentical)
496
  this.editor().operation(function() {
497
  collapseIdenticalStretches(self, options.collapseIdentical);
500
  this.aligners = [];
501
  alignChunks(this.left || this.right, true);
502
  }
503
+ if (left) left.registerEvents()
504
+ if (right) right.registerEvents()
505
+
506
 
507
  var onResize = function() {
508
  if (left) makeConnections(left);
545
  }
546
 
547
  MergeView.prototype = {
548
+ constructor: MergeView,
549
  editor: function() { return this.edit; },
550
  rightOriginal: function() { return this.right && this.right.orig; },
551
  leftOriginal: function() { return this.left && this.left.orig; },
571
  var dmp = new diff_match_patch();
572
  function getDiff(a, b) {
573
  var diff = dmp.diff_main(a, b);
 
574
  // The library sometimes leaves in empty parts, which confuse the algorithm
575
  for (var i = 0; i < diff.length; ++i) {
576
  var part = diff[i];
lib/codemirror/addon/merge/merge.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","diff_match_patch"],e):e(CodeMirror)}(function(e){"use strict";function t(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 r(t){t.diffOutOfDate&&(t.diff=F(t.orig.getValue(),t.edit.getValue()),t.chunks=w(t.diff),t.diffOutOfDate=!1,e.signal(t.edit,"updateDiff",t.diff))}function i(e){function t(t){z=!0,d=!1,"full"==t&&(e.svg&&O(e.svg),e.copyButtons&&O(e.copyButtons),s(e.edit,a.marked,e.classes),s(e.orig,c.marked,e.classes),a.from=a.to=c.from=c.to=0),r(e),e.showDifferences&&(f(e.edit,e.diff,a,DIFF_INSERT,e.classes),f(e.orig,e.diff,c,DIFF_DELETE,e.classes)),h(e),"align"==e.mv.options.connect&&g(e),z=!1}function i(t){z||(e.dealigned=!0,o(t))}function o(e){z||d||(clearTimeout(l),e===!0&&(d=!0),l=setTimeout(t,e===!0?20:250))}function n(t,r){e.diffOutOfDate||(e.diffOutOfDate=!0,a.from=a.to=c.from=c.to=0),i(r.text.length-1!=r.to.line-r.from.line)}var l,a={from:0,to:0,marked:[]},c={from:0,to:0,marked:[]},d=!1;return e.edit.on("change",n),e.orig.on("change",n),e.edit.on("markerAdded",i),e.edit.on("markerCleared",i),e.orig.on("markerAdded",i),e.orig.on("markerCleared",i),e.edit.on("viewportChange",function(){o(!1)}),e.orig.on("viewportChange",function(){o(!1)}),t(),t}function o(e){e.edit.on("scroll",function(){n(e,DIFF_INSERT)&&h(e)}),e.orig.on("scroll",function(){n(e,DIFF_DELETE)&&h(e)})}function n(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 a,s,f=.5*n.clientHeight,c=n.top+f,h=r.lineAtHeight(c,"local"),d=M(e.chunks,h,t==DIFF_INSERT),u=l(r,t==DIFF_INSERT?d.edit:d.orig),g=l(i,t==DIFF_INSERT?d.orig:d.edit),v=(c-u.top)/(u.bot-u.top),m=g.top-f+v*(g.bot-g.top);if(m>n.top&&(s=n.top/f)<1)m=m*s+n.top*(1-s);else if((a=n.height-n.clientHeight-n.top)<f){var p=i.getScrollInfo(),k=p.height-p.clientHeight-m;k>a&&(s=a/f)<1&&(m=m*s+(p.height-p.clientHeight-a)*(1-s))}}return i.scrollTo(n.left,m),i.state.scrollSetAt=o,i.state.scrollSetBy=e,!0}function l(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 a(e,t,r){e.lockScroll=t,t&&0!=r&&n(e,DIFF_INSERT)&&h(e),e.lockButton.innerHTML=t?"⇛⇚":"⇛&nbsp;&nbsp;⇚"}function s(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?(s(e,r.marked,o),c(e,t,i,r.marked,n.from,n.to,o),r.from=n.from,r.to=n.to):(n.from<r.from&&(c(e,t,i,r.marked,n.from,r.from,o),r.from=n.from),n.to>r.to&&(c(e,t,i,r.marked,r.to,n.to,o),r.to=n.to))})}function c(e,t,r,i,o,n,l){function a(t,r){for(var a=Math.max(o,t),s=Math.min(n,r),f=a;f<s;++f){var c=e.addLineClass(f,"background",l.chunk);f==t&&e.addLineClass(c,"background",l.start),f==r-1&&e.addLineClass(c,"background",l.end),i.push(c)}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=U(0,0),f=U(o,0),c=e.clipPos(U(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+(D(t,u)?0:1);x(s,m);var k=s.line+(y(t,u)?1:0);k>p&&(u&&a(d,p),d=k)}else if(v==r){var C=x(s,m,!0),T=B(f,s),F=_(c,C);R(T,F)||i.push(e.markText(T,F,{className:h})),s=C}}d<=s.line&&a(d,s.line+1)}function h(e){if(e.showDifferences){if(e.svg){O(e.svg);var t=e.gap.offsetWidth;N(e.svg,"width",t,"height",e.gap.offsetHeight)}e.copyButtons&&O(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&&p(e,a,n,o,t)}}}function d(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 u(e,t){for(var r=[],i=0;i<e.chunks.length;i++){var o=e.chunks[i];r.push([o.origTo,o.editTo,t?d(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,[d(o.editTo,e.chunks),o.editTo,o.origTo])}return r}function g(e,t){if(e.dealigned||t){if(!e.orig.curOp)return e.orig.operation(function(){g(e,t)});e.dealigned=!1;var i=e.mv.left==e?e.mv.right:e.mv.left;i&&(r(i),i.dealigned=!1);for(var o=u(e,i),n=e.mv.aligners,l=0;l<n.length;l++)n[l].clear();n.length=0;var a=[e.orig,e.edit],s=[];i&&a.push(i.orig);for(var l=0;l<a.length;l++)s.push(a[l].getScrollInfo().top);for(var f=0;f<o.length;f++)v(a,o[f],n);for(var l=0;l<a.length;l++)a[l].scrollTo(null,s[l])}}function v(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(m(e[n],t[n],a))}}function m(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 p(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 f=a;a=s,s=f}var c=e.orig.heightAtLine(t.origTo,"local")-r,h=e.edit.heightAtLine(t.editTo,"local")-i;if(n){var f=c;c=h,h=f}var d=" C "+o/2+" "+s+" "+o/2+" "+a+" "+(o+2)+" "+a,u=" C "+o/2+" "+c+" "+o/2+" "+h+" -1 "+h;N(e.svg.appendChild(document.createElementNS(W,"path")),"d","M -1 "+s+d+" L "+(o+2)+" "+c+u+" z","class",e.classes.connect)}if(e.copyButtons){var g=e.copyButtons.appendChild(S("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(S("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 k(e,t,r,i){e.diffOutOfDate||t.replaceRange(r.getRange(U(i.origFrom,0),U(i.origTo,0)),U(i.editFrom,0),U(i.editTo,0))}function C(t){var r=t.lockButton=S("div",null,"CodeMirror-merge-scrolllock");r.title="Toggle locked scrolling";var i=S("div",[r],"CodeMirror-merge-scrolllock-wrap");e.on(r,"click",function(){a(t,!t.lockScroll)});var o=[i];if(t.mv.options.revertButtons!==!1&&(t.copyButtons=S("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 k(t,t.orig,t.edit,r.chunk):void k(t,t.edit,t.orig,r.chunk)}),o.unshift(t.copyButtons)),"align"!=t.mv.options.connect){var n=document.createElementNS&&document.createElementNS(W,"svg");n&&!n.createSVGRect&&(n=null),t.svg=n,n&&o.push(n)}return t.gap=S("div",o,"CodeMirror-merge-gap")}function T(e){return"string"==typeof e?e:e.getValue()}function F(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 w(e){for(var t=[],r=0,i=0,o=U(0,0),n=U(0,0),l=0;l<e.length;++l){var a=e[l],s=a[0];if(s==DIFF_EQUAL){var f=D(e,l)?0:1,c=o.line+f,h=n.line+f;x(o,a[1],null,n);var d=y(e,l)?1:0,u=o.line+d,g=n.line+d;u>c&&(l&&t.push({origFrom:i,origTo:h,editFrom:r,editTo:c}),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 y(e,t){if(t==e.length-1)return!0;var r=e[t+1][1];return 1!=r.length&&10==r.charCodeAt(0)&&(t==e.length-2||(r=e[t+2][1],r.length>1&&10==r.charCodeAt(0)))}function D(e,t){if(0==t)return!0;var r=e[t-1][1];return 10==r.charCodeAt(r.length-1)&&(1==t||(r=e[t-2][1],10==r.charCodeAt(r.length-1)))}function M(e,t,r){for(var i,o,n,l,a=0;a<e.length;a++){var s=e[a],f=r?s.editFrom:s.origFrom,c=r?s.editTo:s.origTo;null==o&&(f>t?(o=s.editFrom,l=s.origFrom):c>t&&(o=s.editTo,l=s.origTo)),c<=t?(i=s.editTo,n=s.origTo):f<=t&&(i=s.editFrom,n=s.origFrom)}return{edit:{before:i,after:o},orig:{before:n,after:l}}}function L(t,r,i){function o(){l.clear(),t.removeLineClass(r,"wrap","CodeMirror-merge-collapsed-line")}t.addLineClass(r,"wrap","CodeMirror-merge-collapsed-line");var n=document.createElement("span");n.className="CodeMirror-merge-collapsed-widget",n.title="Identical text collapsed. Click to expand.";var l=t.markText(U(r,0),U(i-1),{inclusiveLeft:!0,inclusiveRight:!0,replacedWith:n,clearOnEnter:!0});return e.on(n,"click",o),{mark:l,clear:o}}function I(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=L(n.cm,n.line,n.line+e);i.push(l),l.mark.on("clear",r)}return i[0].mark}function b(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 E(e,t){"number"!=typeof t&&(t=2);for(var r=[],i=e.editor(),o=i.firstLine(),n=o,l=i.lastLine();n<=l;n++)r.push(!0);e.left&&b(e.left,t,o,r),e.right&&b(e.right,t,o,r);for(var a=0;a<r.length;a++)if(r[a]){for(var s=a+o,f=1;a<r.length-1&&r[a+1];a++,f++);if(f>t){var c=[{line:s,cm:i}];e.left&&c.push({line:d(s,e.left.chunks),cm:e.left.orig}),e.right&&c.push({line:d(s,e.right.chunks),cm:e.right.orig});var h=I(f,c);e.options.onCollapse&&e.options.onCollapse(e,s,f,h)}}}function S(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 O(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild)}function N(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?U(e.line,e.ch):e,n=0;;){var l=t.indexOf("\n",n);if(l==-1)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 _(e,t){return(e.line-t.line||e.ch-t.ch)<0?e:t}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}function V(e,t,r){for(var i=e.length-1;i>=0;i--){var o=e[i],n=(r?o.origTo:o.editTo)-1;if(n<t)return n}}function H(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 P(t,i){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],f=t==s.orig;r(s);var c=i<0?V(s.chunks,l,f):H(s.chunks,l,f);null==c||null!=o&&!(i<0?c>o:c<o)||(o=c)}return null==o?e.Pass:void t.setCursor(o,0)}var U=e.Pos,W="http://www.w3.org/2000/svg";t.prototype={constructor:t,init:function(t,r,n){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(n))),this.orig.state.diffViews=[this],this.diff=F(T(r),T(n.value)),this.chunks=w(this.diff),this.diffOutOfDate=this.dealigned=!1,this.showDifferences=n.showDifferences!==!1,this.forceUpdate=i(this),a(this,!0,!1),o(this)},setShowDifferences:function(e){e=e!==!1,e!=this.showDifferences&&(this.showDifferences=e,this.forceUpdate("full"))}};var z=!1,j=e.MergeView=function(r,i){if(!(this instanceof j))return new j(r,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),f=[],c=this.left=null,d=this.right=null,u=this;if(l){c=this.left=new t(this,"left");var v=S("div",null,"CodeMirror-merge-pane");f.push(v),f.push(C(c))}var m=S("div",null,"CodeMirror-merge-pane");if(f.push(m),a){d=this.right=new t(this,"right"),f.push(C(d));var p=S("div",null,"CodeMirror-merge-pane");f.push(p)}(a?p:m).className+=" CodeMirror-merge-pane-rightmost",f.push(S("div",null,null,"height: 0; clear: both;"));var k=this.wrap=r.appendChild(S("div",f,"CodeMirror-merge CodeMirror-merge-"+s+"pane"));this.edit=e(m,A(i)),c&&c.init(v,o,i),d&&d.init(p,n,i),i.collapseIdentical&&this.editor().operation(function(){E(u,i.collapseIdentical)}),"align"==i.connect&&(this.aligners=[],g(this.left||this.right,!0));var T=function(){c&&h(c),d&&h(d)};e.on(window,"resize",T);var F=setInterval(function(){for(var t=k.parentNode;t&&t!=document.body;t=t.parentNode);t||(clearInterval(F),e.off(window,"resize",T))},5e3)};j.prototype={constuctor:j,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(){if(this.right)return r(this.right),this.right.chunks},leftChunks:function(){if(this.left)return r(this.left),this.left.chunks}};var Q=new diff_match_patch;e.commands.goNextDiff=function(e){return P(e,1)},e.commands.goPrevDiff=function(e){return P(e,-1)}});
1
+ !function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","diff_match_patch"],e):e(CodeMirror)}(function(e){"use strict";function t(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 r(t){t.diffOutOfDate&&(t.diff=y(t.orig.getValue(),t.edit.getValue()),t.chunks=D(t.diff),t.diffOutOfDate=!1,e.signal(t.edit,"updateDiff",t.diff))}function i(e){function t(t){Q=!0,g=!1,"full"==t&&(e.svg&&N(e.svg),e.copyButtons&&N(e.copyButtons),c(e.edit,s.marked,e.classes),c(e.orig,h.marked,e.classes),s.from=s.to=h.from=h.to=0),r(e),e.showDifferences&&(f(e.edit,e.diff,s,DIFF_INSERT,e.classes),f(e.orig,e.diff,h,DIFF_DELETE,e.classes)),"align"==e.mv.options.connect&&v(e),d(e),Q=!1}function i(t){Q||(e.dealigned=!0,o(t))}function o(e){Q||g||(clearTimeout(a),e===!0&&(g=!0),a=setTimeout(t,e===!0?20:250))}function n(t,r){e.diffOutOfDate||(e.diffOutOfDate=!0,s.from=s.to=h.from=h.to=0),i(r.text.length-1!=r.to.line-r.from.line)}function l(){e.diffOutOfDate=!0,t("full")}var a,s={from:0,to:0,marked:[]},h={from:0,to:0,marked:[]},g=!1;return e.edit.on("change",n),e.orig.on("change",n),e.edit.on("swapDoc",l),e.orig.on("swapDoc",l),e.edit.on("markerAdded",i),e.edit.on("markerCleared",i),e.orig.on("markerAdded",i),e.orig.on("markerCleared",i),e.edit.on("viewportChange",function(){o(!1)}),e.orig.on("viewportChange",function(){o(!1)}),t(),t}function o(e){e.edit.on("scroll",function(){n(e,DIFF_INSERT)&&d(e)}),e.orig.on("scroll",function(){n(e,DIFF_DELETE)&&d(e)})}function n(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)v=n.top;else{var a,s,c=.5*n.clientHeight,f=n.top+c,h=r.lineAtHeight(f,"local"),g=E(e.chunks,h,t==DIFF_INSERT),d=l(r,t==DIFF_INSERT?g.edit:g.orig),u=l(i,t==DIFF_INSERT?g.orig:g.edit),m=(f-d.top)/(d.bot-d.top),v=u.top-c+m*(u.bot-u.top);if(v>n.top&&(s=n.top/c)<1)v=v*s+n.top*(1-s);else if((a=n.height-n.clientHeight-n.top)<c){var p=i.getScrollInfo(),k=p.height-p.clientHeight-v;k>a&&(s=a/c)<1&&(v=v*s+(p.height-p.clientHeight-a)*(1-s))}}return i.scrollTo(n.left,v),i.state.scrollSetAt=o,i.state.scrollSetBy=e,!0}function l(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 a(e,t,r){e.lockScroll=t,t&&0!=r&&n(e,DIFF_INSERT)&&d(e),e.lockButton.innerHTML=t?"⇛⇚":"⇛&nbsp;&nbsp;⇚"}function s(e,t,r){for(var i=r.classLocation,o=0;o<i.length;o++)e.removeLineClass(t,i[o],r.chunk),e.removeLineClass(t,i[o],r.start),e.removeLineClass(t,i[o],r.end)}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&&s(t,n,i)}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),g(e,t,i,r.marked,n.from,n.to,o),r.from=n.from,r.to=n.to):(n.from<r.from&&(g(e,t,i,r.marked,n.from,r.from,o),r.from=n.from),n.to>r.to&&(g(e,t,i,r.marked,r.to,n.to,o),r.to=n.to))})}function h(e,t,r,i,o,n){for(var l=r.classLocation,a=e.getLineHandle(t),s=0;s<l.length;s++)i&&e.addLineClass(a,l[s],r.chunk),o&&e.addLineClass(a,l[s],r.start),n&&e.addLineClass(a,l[s],r.end);return a}function g(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;c<s;++c)i.push(h(e,c,l,!0,c==t,c==r-1));t==r&&a==r&&s==r&&(a?i.push(h(e,a-1,l,!1,!1,!0)):i.push(h(e,a,l,!1,!0,!1)))}for(var s=W(0,0),c=W(o,0),f=e.clipPos(W(n-1)),g=r==DIFF_DELETE?l.del:l.insert,d=0,u=0;u<t.length;++u){var m=t[u],v=m[0],p=m[1];if(v==DIFF_EQUAL){var k=s.line+(L(t,u)?0:1);R(s,p);var C=s.line+(M(t,u)?1:0);C>k&&(u&&a(d,k),d=C)}else if(v==r){var T=R(s,p,!0),F=V(c,s),w=_(f,T);H(F,w)||i.push(e.markText(F,w,{className:g})),s=T}}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;x(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.mv.wrap.getBoundingClientRect().top,n=o-e.edit.getScrollerElement().getBoundingClientRect().top+e.edit.getScrollInfo().top,l=o-e.orig.getScrollerElement().getBoundingClientRect().top+e.orig.getScrollInfo().top,a=0;a<e.chunks.length;a++){var s=e.chunks[a];s.editFrom<=r.to&&s.editTo>=r.from&&s.origFrom<=i.to&&s.origTo>=i.from&&C(e,s,l,n,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 m(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)e: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][1]-o.editTo;if(0==l)continue e;if(l>0)break}r.splice(n,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 i=e.mv.left==e?e.mv.right:e.mv.left;i&&(r(i),i.dealigned=!1);for(var o=m(e,i),n=e.mv.aligners,l=0;l<n.length;l++)n[l].clear();n.length=0;var a=[e.orig,e.edit],s=[];i&&a.push(i.orig);for(var l=0;l<a.length;l++)s.push(a[l].getScrollInfo().top);for(var c=0;c<o.length;c++)p(a,o[c],n);for(var l=0;l<a.length;l++)a[l].scrollTo(null,s[l])}}function p(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(k(e[n],t[n],a))}}function k(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 C(e,t,r,i,o){var n="left"==e.type,l=e.orig.heightAtLine(t.origFrom,"local",!0)-r;if(e.svg){var a=l,s=e.edit.heightAtLine(t.editFrom,"local",!0)-i;if(n){var c=a;a=s,s=c}var f=e.orig.heightAtLine(t.origTo,"local",!0)-r,h=e.edit.heightAtLine(t.editTo,"local",!0)-i;if(n){var c=f;f=h,h=c}var g=" C "+o/2+" "+s+" "+o/2+" "+a+" "+(o+2)+" "+a,d=" C "+o/2+" "+f+" "+o/2+" "+h+" -1 "+h;x(e.svg.appendChild(document.createElementNS(z,"path")),"d","M -1 "+s+g+" L "+(o+2)+" "+f+d+" z","class",e.classes.connect)}if(e.copyButtons){var u=e.copyButtons.appendChild(A("div","left"==e.type?"⇝":"⇜","CodeMirror-merge-copy")),m=e.mv.options.allowEditingOriginals;if(u.title=m?"Push to left":"Revert chunk",u.chunk=t,u.style.top=(t.origTo>t.origFrom?l:e.edit.heightAtLine(t.editFrom,"local")-i)+"px",m){var v=e.edit.heightAtLine(t.editFrom,"local")-i,p=e.copyButtons.appendChild(A("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=v+"px","right"==e.type?p.style.left="2px":p.style.right="2px"}}}function T(e,t,r,i){if(!e.diffOutOfDate){var o=i.editTo>t.lastLine()?W(i.editFrom-1):W(i.editFrom,0),n=i.origTo>r.lastLine()?W(i.origFrom-1):W(i.origFrom,0);t.replaceRange(r.getRange(n,W(i.origTo,0)),o,W(i.editTo,0))}}function F(t){var r=t.lockButton=A("div",null,"CodeMirror-merge-scrolllock");r.title="Toggle locked scrolling";var i=A("div",[r],"CodeMirror-merge-scrolllock-wrap");e.on(r,"click",function(){a(t,!t.lockScroll)});var o=[i];if(t.mv.options.revertButtons!==!1&&(t.copyButtons=A("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 T(t,t.orig,t.edit,r.chunk):void T(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=A("div",o,"CodeMirror-merge-gap")}function w(e){return"string"==typeof e?e:e.getValue()}function y(e,t){for(var r=G.diff_main(e,t),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 D(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=L(e,l)?0:1,f=o.line+c,h=n.line+c;R(o,a[1],null,n);var g=M(e,l)?1:0,d=o.line+g,u=n.line+g;d>f&&(l&&t.push({origFrom:i,origTo:h,editFrom:r,editTo:f}),r=d,i=u)}else R(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 M(e,t){if(t==e.length-1)return!0;var r=e[t+1][1];return 1!=r.length&&10==r.charCodeAt(0)&&(t==e.length-2||(r=e[t+2][1],r.length>1&&10==r.charCodeAt(0)))}function L(e,t){if(0==t)return!0;var r=e[t-1][1];return 10==r.charCodeAt(r.length-1)&&(1==t||(r=e[t-2][1],10==r.charCodeAt(r.length-1)))}function E(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)),f<=t?(i=s.editTo,n=s.origTo):c<=t&&(i=s.editFrom,n=s.origFrom)}return{edit:{before:i,after:o},orig:{before:n,after:l}}}function I(t,r,i){function o(){l.clear(),t.removeLineClass(r,"wrap","CodeMirror-merge-collapsed-line")}t.addLineClass(r,"wrap","CodeMirror-merge-collapsed-line");var n=document.createElement("span");n.className="CodeMirror-merge-collapsed-widget",n.title="Identical text collapsed. Click to expand.";var l=t.markText(W(r,0),W(i-1),{inclusiveLeft:!0,inclusiveRight:!0,replacedWith:n,clearOnEnter:!0});return e.on(n,"click",o),{mark:l,clear:o}}function S(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 O(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 b(e,t){"number"!=typeof t&&(t=2);for(var r=[],i=e.editor(),o=i.firstLine(),n=o,l=i.lastLine();n<=l;n++)r.push(!0);e.left&&O(e.left,t,o,r),e.right&&O(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=S(c,f);e.options.onCollapse&&e.options.onCollapse(e,s,c,h)}}}function A(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 x(e){for(var t=1;t<arguments.length;t+=2)e.setAttribute(arguments[t],arguments[t+1])}function B(e,t){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function R(e,t,r,i){for(var o=r?W(e.line,e.ch):e,n=0;;){var l=t.indexOf("\n",n);if(l==-1)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 _(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)>0?e:t}function H(e,t){return e.line==t.line&&e.ch==t.ch}function P(e,t,r){for(var i=e.length-1;i>=0;i--){var o=e[i],n=(r?o.origTo:o.editTo)-1;if(n<t)return n}}function j(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,i){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;r(s);var f=i<0?P(s.chunks,l,c):j(s.chunks,l,c);null==f||null!=o&&!(i<0?f>o:f<o)||(o=f)}return null==o?e.Pass:void t.setCursor(o,0)}var W=e.Pos,z="http://www.w3.org/2000/svg";t.prototype={constructor:t,init:function(t,r,i){this.edit=this.mv.edit,(this.edit.state.diffViews||(this.edit.state.diffViews=[])).push(this),this.orig=e(t,B({value:r,readOnly:!this.mv.options.allowEditingOriginals},B(i))),this.orig.state.diffViews=[this];var o=i.chunkClassLocation||"background";"[object Array]"!=Object.prototype.toString.call(o)&&(o=[o]),this.classes.classLocation=o,this.diff=y(w(r),w(i.value)),this.chunks=D(this.diff),this.diffOutOfDate=this.dealigned=!1,this.showDifferences=i.showDifferences!==!1},registerEvents:function(){this.forceUpdate=i(this),a(this,!0,!1),o(this)},setShowDifferences:function(e){e=e!==!1,e!=this.showDifferences&&(this.showDifferences=e,this.forceUpdate("full"))}};var Q=!1,q=e.MergeView=function(r,i){if(!(this instanceof q))return new q(r,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,g=this;if(l){f=this.left=new t(this,"left");var u=A("div",null,"CodeMirror-merge-pane CodeMirror-merge-left");c.push(u),c.push(F(f))}var m=A("div",null,"CodeMirror-merge-pane CodeMirror-merge-editor");if(c.push(m),a){h=this.right=new t(this,"right"),c.push(F(h));var p=A("div",null,"CodeMirror-merge-pane CodeMirror-merge-right");c.push(p)}(a?p:m).className+=" CodeMirror-merge-pane-rightmost",c.push(A("div",null,null,"height: 0; clear: both;"));var k=this.wrap=r.appendChild(A("div",c,"CodeMirror-merge CodeMirror-merge-"+s+"pane"));this.edit=e(m,B(i)),f&&f.init(u,o,i),h&&h.init(p,n,i),i.collapseIdentical&&this.editor().operation(function(){b(g,i.collapseIdentical)}),"align"==i.connect&&(this.aligners=[],v(this.left||this.right,!0)),f&&f.registerEvents(),h&&h.registerEvents();var C=function(){f&&d(f),h&&d(h)};e.on(window,"resize",C);var T=setInterval(function(){for(var t=k.parentNode;t&&t!=document.body;t=t.parentNode);t||(clearInterval(T),e.off(window,"resize",C))},5e3)};q.prototype={constructor: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(){if(this.right)return r(this.right),this.right.chunks},leftChunks:function(){if(this.left)return r(this.left),this.left.chunks}};var G=new diff_match_patch;e.commands.goNextDiff=function(e){return U(e,1)},e.commands.goPrevDiff=function(e){return U(e,-1)}});
lib/codemirror/lib/codemirror.css CHANGED
@@ -52,7 +52,7 @@
52
  }
53
  .cm-fat-cursor .CodeMirror-cursor {
54
  width: auto;
55
- border: 0;
56
  background: #7e7;
57
  }
58
  .cm-fat-cursor div.CodeMirror-cursors {
@@ -88,8 +88,14 @@
88
 
89
  .cm-tab { display: inline-block; text-decoration: inherit; }
90
 
 
 
 
 
 
91
  .CodeMirror-ruler {
92
  border-left: 1px solid #ccc;
 
93
  position: absolute;
94
  }
95
 
@@ -191,16 +197,15 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
191
 
192
  .CodeMirror-gutters {
193
  position: absolute; left: 0; top: 0;
 
194
  z-index: 3;
195
  }
196
  .CodeMirror-gutter {
197
  white-space: normal;
198
  height: 100%;
199
  display: inline-block;
 
200
  margin-bottom: -30px;
201
- /* Hack to make IE7 behave */
202
- *zoom:1;
203
- *display:inline;
204
  }
205
  .CodeMirror-gutter-wrapper {
206
  position: absolute;
@@ -244,6 +249,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
244
  position: relative;
245
  overflow: visible;
246
  -webkit-tap-highlight-color: transparent;
 
 
247
  }
248
  .CodeMirror-wrap pre {
249
  word-wrap: break-word;
@@ -287,7 +294,10 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
287
  visibility: hidden;
288
  }
289
 
290
- .CodeMirror-cursor { position: absolute; }
 
 
 
291
  .CodeMirror-measure pre { position: static; }
292
 
293
  div.CodeMirror-cursors {
@@ -314,9 +324,6 @@ div.CodeMirror-dragcursors {
314
  background: rgba(255, 255, 0, .4);
315
  }
316
 
317
- /* IE7 hack to prevent it from returning funny offsetTops on the spans */
318
- .CodeMirror span { *vertical-align: text-bottom; }
319
-
320
  /* Used to force a border model for a node */
321
  .cm-force-border { padding-right: .1px; }
322
 
52
  }
53
  .cm-fat-cursor .CodeMirror-cursor {
54
  width: auto;
55
+ border: 0 !important;
56
  background: #7e7;
57
  }
58
  .cm-fat-cursor div.CodeMirror-cursors {
88
 
89
  .cm-tab { display: inline-block; text-decoration: inherit; }
90
 
91
+ .CodeMirror-rulers {
92
+ position: absolute;
93
+ left: 0; right: 0; top: -50px; bottom: -20px;
94
+ overflow: hidden;
95
+ }
96
  .CodeMirror-ruler {
97
  border-left: 1px solid #ccc;
98
+ top: 0; bottom: 0;
99
  position: absolute;
100
  }
101
 
197
 
198
  .CodeMirror-gutters {
199
  position: absolute; left: 0; top: 0;
200
+ min-height: 100%;
201
  z-index: 3;
202
  }
203
  .CodeMirror-gutter {
204
  white-space: normal;
205
  height: 100%;
206
  display: inline-block;
207
+ vertical-align: top;
208
  margin-bottom: -30px;
 
 
 
209
  }
210
  .CodeMirror-gutter-wrapper {
211
  position: absolute;
249
  position: relative;
250
  overflow: visible;
251
  -webkit-tap-highlight-color: transparent;
252
+ -webkit-font-variant-ligatures: contextual;
253
+ font-variant-ligatures: contextual;
254
  }
255
  .CodeMirror-wrap pre {
256
  word-wrap: break-word;
294
  visibility: hidden;
295
  }
296
 
297
+ .CodeMirror-cursor {
298
+ position: absolute;
299
+ pointer-events: none;
300
+ }
301
  .CodeMirror-measure pre { position: static; }
302
 
303
  div.CodeMirror-cursors {
324
  background: rgba(255, 255, 0, .4);
325
  }
326
 
 
 
 
327
  /* Used to force a border model for a node */
328
  .cm-force-border { padding-right: .1px; }
329
 
lib/codemirror/lib/codemirror.js CHANGED
@@ -7,8881 +7,9107 @@
7
  // You can find some technical background for some of the code below
8
  // at http://marijnhaverbeke.nl/blog/#cm-internals .
9
 
10
- (function(mod) {
11
- if (typeof exports == "object" && typeof module == "object") // CommonJS
12
- module.exports = mod();
13
- else if (typeof define == "function" && define.amd) // AMD
14
- return define([], mod);
15
- else // Plain browser env
16
- (this || window).CodeMirror = mod();
17
- })(function() {
18
- "use strict";
19
-
20
- // BROWSER SNIFFING
21
-
22
- // Kludges for bugs and behavior differences that can't be feature
23
- // detected are enabled based on userAgent etc sniffing.
24
- var userAgent = navigator.userAgent;
25
- var platform = navigator.platform;
26
-
27
- var gecko = /gecko\/\d/i.test(userAgent);
28
- var ie_upto10 = /MSIE \d/.test(userAgent);
29
- var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
30
- var ie = ie_upto10 || ie_11up;
31
- var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
32
- var webkit = /WebKit\//.test(userAgent);
33
- var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
34
- var chrome = /Chrome\//.test(userAgent);
35
- var presto = /Opera\//.test(userAgent);
36
- var safari = /Apple Computer/.test(navigator.vendor);
37
- var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
38
- var phantom = /PhantomJS/.test(userAgent);
39
-
40
- var ios = /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
41
- // This is woefully incomplete. Suggestions for alternative methods welcome.
42
- var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
43
- var mac = ios || /Mac/.test(platform);
44
- var windows = /win/i.test(platform);
45
-
46
- var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
47
- if (presto_version) presto_version = Number(presto_version[1]);
48
- if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
49
- // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
50
- var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
51
- var captureRightClick = gecko || (ie && ie_version >= 9);
52
-
53
- // Optimize some code when these features are not used.
54
- var sawReadOnlySpans = false, sawCollapsedSpans = false;
55
-
56
- // EDITOR CONSTRUCTOR
57
-
58
- // A CodeMirror instance represents an editor. This is the object
59
- // that user code is usually dealing with.
60
-
61
- function CodeMirror(place, options) {
62
- if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
63
-
64
- this.options = options = options ? copyObj(options) : {};
65
- // Determine effective options based on given values and defaults.
66
- copyObj(defaults, options, false);
67
- setGuttersForLineNumbers(options);
68
-
69
- var doc = options.value;
70
- if (typeof doc == "string") doc = new Doc(doc, options.mode, null, options.lineSeparator);
71
- this.doc = doc;
72
-
73
- var input = new CodeMirror.inputStyles[options.inputStyle](this);
74
- var display = this.display = new Display(place, doc, input);
75
- display.wrapper.CodeMirror = this;
76
- updateGutters(this);
77
- themeChanged(this);
78
- if (options.lineWrapping)
79
- this.display.wrapper.className += " CodeMirror-wrap";
80
- if (options.autofocus && !mobile) display.input.focus();
81
- initScrollbars(this);
82
-
83
- this.state = {
84
- keyMaps: [], // stores maps added by addKeyMap
85
- overlays: [], // highlighting overlays, as added by addOverlay
86
- modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
87
- overwrite: false,
88
- delayingBlurEvent: false,
89
- focused: false,
90
- suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
91
- pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
92
- selectingText: false,
93
- draggingText: false,
94
- highlight: new Delayed(), // stores highlight worker timeout
95
- keySeq: null, // Unfinished key sequence
96
- specialChars: null
97
- };
98
-
99
- var cm = this;
100
-
101
- // Override magic textarea content restore that IE sometimes does
102
- // on our hidden textarea on reload
103
- if (ie && ie_version < 11) setTimeout(function() { cm.display.input.reset(true); }, 20);
104
-
105
- registerEventHandlers(this);
106
- ensureGlobalHandlers();
107
-
108
- startOperation(this);
109
- this.curOp.forceUpdate = true;
110
- attachDoc(this, doc);
111
-
112
- if ((options.autofocus && !mobile) || cm.hasFocus())
113
- setTimeout(bind(onFocus, this), 20);
114
- else
115
- onBlur(this);
116
-
117
- for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
118
- optionHandlers[opt](this, options[opt], Init);
119
- maybeUpdateLineNumberWidth(this);
120
- if (options.finishInit) options.finishInit(this);
121
- for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
122
- endOperation(this);
123
- // Suppress optimizelegibility in Webkit, since it breaks text
124
- // measuring on line wrapping boundaries.
125
- if (webkit && options.lineWrapping &&
126
- getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
127
- display.lineDiv.style.textRendering = "auto";
128
- }
129
-
130
- // DISPLAY CONSTRUCTOR
131
-
132
- // The display handles the DOM integration, both for input reading
133
- // and content drawing. It holds references to DOM nodes and
134
- // display-related state.
135
-
136
- function Display(place, doc, input) {
137
- var d = this;
138
- this.input = input;
139
-
140
- // Covers bottom-right square when both scrollbars are present.
141
- d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
142
- d.scrollbarFiller.setAttribute("cm-not-content", "true");
143
- // Covers bottom of gutter when coverGutterNextToScrollbar is on
144
- // and h scrollbar is present.
145
- d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
146
- d.gutterFiller.setAttribute("cm-not-content", "true");
147
- // Will contain the actual code, positioned to cover the viewport.
148
- d.lineDiv = elt("div", null, "CodeMirror-code");
149
- // Elements are added to these to represent selection and cursors.
150
- d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
151
- d.cursorDiv = elt("div", null, "CodeMirror-cursors");
152
- // A visibility: hidden element used to find the size of things.
153
- d.measure = elt("div", null, "CodeMirror-measure");
154
- // When lines outside of the viewport are measured, they are drawn in this.
155
- d.lineMeasure = elt("div", null, "CodeMirror-measure");
156
- // Wraps everything that needs to exist inside the vertically-padded coordinate system
157
- d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
158
- null, "position: relative; outline: none");
159
- // Moved around its parent to cover visible view.
160
- d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
161
- // Set to the height of the document, allowing scrolling.
162
- d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
163
- d.sizerWidth = null;
164
- // Behavior of elts with overflow: auto and padding is
165
- // inconsistent across browsers. This is used to ensure the
166
- // scrollable area is big enough.
167
- d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
168
- // Will contain the gutters, if any.
169
- d.gutters = elt("div", null, "CodeMirror-gutters");
170
- d.lineGutter = null;
171
- // Actual scrollable element.
172
- d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
173
- d.scroller.setAttribute("tabIndex", "-1");
174
- // The element in which the editor lives.
175
- d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
176
-
177
- // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
178
- if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
179
- if (!webkit && !(gecko && mobile)) d.scroller.draggable = true;
180
-
181
- if (place) {
182
- if (place.appendChild) place.appendChild(d.wrapper);
183
- else place(d.wrapper);
184
- }
185
-
186
- // Current rendered range (may be bigger than the view window).
187
- d.viewFrom = d.viewTo = doc.first;
188
- d.reportedViewFrom = d.reportedViewTo = doc.first;
189
- // Information about the rendered lines.
190
- d.view = [];
191
- d.renderedView = null;
192
- // Holds info about a single rendered line when it was rendered
193
- // for measurement, while not in view.
194
- d.externalMeasured = null;
195
- // Empty space (in pixels) above the view
196
- d.viewOffset = 0;
197
- d.lastWrapHeight = d.lastWrapWidth = 0;
198
- d.updateLineNumbers = null;
199
-
200
- d.nativeBarWidth = d.barHeight = d.barWidth = 0;
201
- d.scrollbarsClipped = false;
202
-
203
- // Used to only resize the line number gutter when necessary (when
204
- // the amount of lines crosses a boundary that makes its width change)
205
- d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
206
- // Set to true when a non-horizontal-scrolling line widget is
207
- // added. As an optimization, line widget aligning is skipped when
208
- // this is false.
209
- d.alignWidgets = false;
210
-
211
- d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
212
-
213
- // Tracks the maximum line length so that the horizontal scrollbar
214
- // can be kept static when scrolling.
215
- d.maxLine = null;
216
- d.maxLineLength = 0;
217
- d.maxLineChanged = false;
218
-
219
- // Used for measuring wheel scrolling granularity
220
- d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
221
-
222
- // True when shift is held down.
223
- d.shift = false;
224
-
225
- // Used to track whether anything happened since the context menu
226
- // was opened.
227
- d.selForContextMenu = null;
228
-
229
- d.activeTouch = null;
230
-
231
- input.init(d);
232
- }
233
-
234
- // STATE UPDATES
235
-
236
- // Used to get the editor into a consistent state again when options change.
237
-
238
- function loadMode(cm) {
239
- cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption);
240
- resetModeState(cm);
241
- }
242
-
243
- function resetModeState(cm) {
244
- cm.doc.iter(function(line) {
245
- if (line.stateAfter) line.stateAfter = null;
246
- if (line.styles) line.styles = null;
247
- });
248
- cm.doc.frontier = cm.doc.first;
249
- startWorker(cm, 100);
250
- cm.state.modeGen++;
251
- if (cm.curOp) regChange(cm);
252
- }
253
-
254
- function wrappingChanged(cm) {
255
- if (cm.options.lineWrapping) {
256
- addClass(cm.display.wrapper, "CodeMirror-wrap");
257
- cm.display.sizer.style.minWidth = "";
258
- cm.display.sizerWidth = null;