SiteOrigin CSS - Version 1.0.5

Version Description

  • 21 January 2016=
  • Updated to latest version of Code Mirror.
Download this release

Release Info

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

Code changes from version 1.0.4 to 1.0.5

js/editor.js CHANGED
@@ -113,6 +113,7 @@
113
  // Setup the Codemirror instance
114
  this.codeMirror = CodeMirror.fromTextArea(this.$('textarea.css-editor').get(0), {
115
  tabSize: 2,
 
116
  mode: 'css',
117
  theme: 'neat',
118
  gutters: [
113
  // Setup the Codemirror instance
114
  this.codeMirror = CodeMirror.fromTextArea(this.$('textarea.css-editor').get(0), {
115
  tabSize: 2,
116
+ lineNumbers: true,
117
  mode: 'css',
118
  theme: 'neat',
119
  gutters: [
js/editor.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,t,i){var s={model:{},collection:{},view:{},fn:{}};window.socss=s,s.view.toolbar=Backbone.View.extend({button:t.template('<li><a href="#" class="toolbar-button socss-button"><%= text %></a></li>'),editor:null,initialize:function(t){this.editor=t.editor;var i=this;this.$(".editor-expand").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_expand")}),this.$(".editor-visual").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_visual")})},addButton:function(t,i){var s=this,n=e(this.button({text:t})).appendTo(this.$(".toolbar-function-buttons .toolbar-buttons")).click(function(t){t.preventDefault(),e(this).blur(),s.trigger("click_"+i)});return n}}),s.view.editor=Backbone.View.extend({codeMirror:null,snippets:null,toolbar:null,visualProperties:null,inspector:null,cssSelectors:[],initialize:function(e){this.setupEditor()},render:function(){var t=this;this.toolbar=new s.view.toolbar({editor:this,el:this.$(".custom-css-toolbar")}),this.toolbar.editor=this,this.toolbar.render(),this.visualProperties=new s.view.properties({editor:this,el:e("#so-custom-css-properties")}),this.visualProperties.render(),this.toolbar.on("click_expand",function(){t.toggleExpand()}),this.toolbar.on("click_visual",function(){t.visualProperties.loadCSS(t.codeMirror.getValue()),t.visualProperties.show()}),this.preview=new s.view.preview({editor:this,el:this.$(".custom-css-preview")}),this.preview.render()},setupEditor:function(){var t=this;this.registerCodeMirrorAutocomplete(),this.codeMirror=CodeMirror.fromTextArea(this.$("textarea.css-editor").get(0),{tabSize:2,mode:"css",theme:"neat",gutters:["CodeMirror-lint-markers"],lint:!0});var s=this.$("textarea.css-editor").val();this.$el.on("submit",function(){s=t.codeMirror.getValue()}),e(window).bind("beforeunload",function(){return t.codeMirror.getValue()!==s?i.loc.leave:void 0}),this.$el.find(".custom-css-container").css("overflow","visible"),this.scaleEditor(),e(window).resize(function(){t.scaleEditor()}),this.setupCodeMirrorExtensions()},registerCodeMirrorAutocomplete:function(){var e=this,t={link:1,visited:1,active:1,hover:1,focus:1,"first-letter":1,"first-line":1,"first-child":1,before:1,after:1,lang:1};CodeMirror.registerHelper("hint","css",function(i){function s(e){for(var t in e)c&&0!==t.lastIndexOf(c,0)||p.push(t)}var n=i.getCursor(),r=i.getTokenAt(n),o=CodeMirror.innerMode(i.getMode(),r.state);if("css"===o.mode.name){if("keyword"===r.type&&0==="!important".indexOf(r.string))return{list:["!important"],from:CodeMirror.Pos(n.line,r.start),to:CodeMirror.Pos(n.line,r.end)};var a=r.start,l=n.ch,c=r.string.slice(0,l-a);/[^\w$_-]/.test(c)&&(c="",a=l=n.ch);var d=CodeMirror.resolveMode("text/css"),p=[],h=o.state.state;if("top"===h){for(var u=i.getLine(n.line).trim(),v=e.cssSelectors,f=0;f<v.length;f++)-1!==v[f].selector.indexOf(u)&&p.push(v[f].selector);if(p.length)return{list:p,from:CodeMirror.Pos(n.line,0),to:CodeMirror.Pos(n.line,l)}}else if("pseudo"===h||"variable-3"===r.type?s(t):"block"===h||"maybeprop"===h?s(d.propertyKeywords):"prop"===h||"parens"===h||"at"===h||"params"===h?(s(d.valueKeywords),s(d.colorKeywords)):("media"===h||"media_parens"===h)&&(s(d.mediaTypes),s(d.mediaFeatures)),p.length)return{list:p,from:CodeMirror.Pos(n.line,a),to:CodeMirror.Pos(n.line,l)}}})},setupCodeMirrorExtensions:function(){var e=this;this.codeMirror.on("cursorActivity",function(t){var i=t.getCursor(),s=t.getTokenAt(i);CodeMirror.innerMode(t.getMode(),s.state);if("qualifier"===s.type||"tag"===s.type||"builtin"===s.type){var n=t.getLine(i.line),r=n.substring(0,s.end);e.preview.highlight(r)}else e.preview.clearHighlight()}),this.codeMirror.on("keyup",function(e,t){(t.keyCode>=65&&t.keyCode<=90||189===t.keyCode&&!t.shiftKey||190===t.keyCode&&!t.shiftKey||51===t.keyCode&&t.shiftKey||189===t.keyCode&&t.shiftKey)&&e.showHint(t)})},scaleEditor:function(){this.$el.hasClass("expanded")?this.codeMirror.setSize("100%",e(window).outerHeight()-this.$(".custom-css-toolbar").outerHeight()):this.codeMirror.setSize("100%","auto")},isExpanded:function(){return this.$el.hasClass("expanded")},toggleExpand:function(){this.$el.toggleClass("expanded"),this.scaleEditor()},setExpand:function(e){e?this.$el.addClass("expanded"):this.$el.removeClass("expanded"),this.scaleEditor()},setSnippets:function(e){if(!t.isEmpty(e)){var i=this;this.snippets=new s.view.snippets({snippets:e}),this.snippets.editor=this,this.snippets.render(),this.toolbar.addButton("Snippets","snippets"),this.toolbar.on("click_snippets",function(){i.snippets.show()})}},addCode:function(e){var t=this.codeMirror,i="";i=1===t.doc.lineCount()&&0===t.doc.getLine(t.doc.lastLine()).length?"":0===t.doc.getLine(t.doc.lastLine()).length?"\n":"\n\n",t.doc.setCursor(t.doc.lastLine(),t.doc.getLine(t.doc.lastLine()).length),t.doc.replaceSelection(i+e)},addEmptySelector:function(e){this.addCode(e+" {\n \n}")},setInspector:function(e){var t=this;this.inspector=e,this.cssSelectors=e.pageSelectors,e.on("click_selector",function(e){t.visualProperties.isVisible()?t.visualProperties.addSelector(e):t.addEmptySelector(e)}),e.on("click_property",function(e){t.visualProperties.isVisible()||t.codeMirror.replaceSelection(e+";\n ")}),e.on("set_active_element",function(e,i){t.visualProperties.isVisible()&&i.length&&t.visualProperties.addSelector(i[0].selector)})}}),s.view.preview=Backbone.View.extend({template:t.template('<iframe class="preview-iframe" seamless="seamless"></iframe>'),editor:null,initialize:function(e){this.editor=e.editor;var t=this;this.editor.codeMirror.on("change",function(e,i){t.updatePreviewCss()})},render:function(){var t=this;this.$el.html(this.template()),this.$(".preview-iframe").attr("src",i.homeURL).load(function(){var i=e(this);i.contents().find("a").each(function(){var t=e(this).attr("href");if(void 0===t)return!0;var i=-1===t.indexOf("?")?"?":"&";e(this).attr("href",t+i+"so_css_preview=1")}),t.updatePreviewCss()}).mouseleave(function(){t.clearHighlight()})},updatePreviewCss:function(){var e=this.$(".preview-iframe");if(0!==e.length){var t=e.contents().find("head");0===t.find("style.siteorigin-custom-css").length&&t.append('<style class="siteorigin-custom-css" type="text/css"></style>');var i=t.find("style.siteorigin-custom-css"),s=this.editor.codeMirror.getValue();i.html(s)}},highlight:function(e){try{this.editor.inspector.hl.highlight(e)}catch(t){console.log("No inspector to highlight with")}},clearHighlight:function(){try{this.editor.inspector.hl.clear()}catch(e){console.log("No inspector to highlight with")}}}),s.view.snippets=Backbone.View.extend({template:t.template(e("#template-snippet-browser").html()),snippet:t.template('<li class="snippet"><%- name %></li>'),className:"css-editor-snippet-browser",snippets:null,editor:null,events:{"click .close":"hide","click .buttons .insert-snippet":"insertSnippet"},currentSnippet:null,initialize:function(e){this.snippets=e.snippets},render:function(){var t=this,i=function(i){i.preventDefault();var s=e(this);t.$(".snippets li.snippet").removeClass("active"),e(this).addClass("active"),t.viewSnippet({name:s.html(),description:s.data("description"),css:s.data("css")})};this.$el.html(this.template());for(var s=0;s<this.snippets.length;s++)e(this.snippet({name:this.snippets[s].Name})).data({description:this.snippets[s].Description,css:this.snippets[s].css}).appendTo(this.$("ul.snippets")).click(i);return t.$(".snippets li.snippet").eq(0).click(),this.attach(),this},viewSnippet:function(e){var t=this.$(".main .snippet-view");t.find(".snippet-title").html(e.name),t.find(".snippet-description").html(e.description),t.find(".snippet-code").html(e.css),this.currentSnippet=e},insertSnippet:function(){var e=this.editor.codeMirror,t=this.currentSnippet.css,i="";i=1===e.doc.lineCount()&&0===e.doc.getLine(e.doc.lastLine()).length?"":0===e.doc.getLine(e.doc.lastLine()).length?"\n":"\n\n",e.doc.setCursor(e.doc.lastLine(),e.doc.getLine(e.doc.lastLine()).length),e.doc.replaceSelection(i+t),this.hide()},attach:function(){this.$el.appendTo("body")},show:function(){this.$el.show()},hide:function(){this.$el.hide()}}),s.view.properties=Backbone.View.extend({model:s.model.cssRules,tabTemplate:t.template('<li data-section="<%- id %>"><span class="fa fa-<%- icon %>"></span> <%- title %></li>'),sectionTemplate:t.template('<div class="section" data-section="<%- id %>"><table class="fields-table"><tbody></tbody></table></div>'),controllerTemplate:t.template('<tr><th scope="row"><%- title %></th><td></td></tr>'),propertyControllers:[],editor:null,css:"",parsed:{},activeSelector:"",editorExpandedBefore:!1,events:{"click .close":"hide"},initialize:function(e){this.parser=new cssjs,this.editor=e.editor},render:function(){var n=this,r=i.propertyControllers;for(var o in r){var a=(e(this.tabTemplate({id:o,icon:r[o].icon,title:r[o].title})).appendTo(this.$(".section-tabs")),e(this.sectionTemplate({id:o})).appendTo(this.$(".sections")));if(!t.isEmpty(r[o].controllers))for(var l=0;l<r[o].controllers.length;l++){var c,d=e(n.controllerTemplate({title:r[o].controllers[l].title})).appendTo(a.find("tbody")),p=r[o].controllers[l];c="undefined"==typeof s.view.properties.controllers[p.type]?new s.view.propertyController({el:d.find("td"),propertiesView:n,args:"undefined"==typeof p.args?{}:p.args}):new s.view.properties.controllers[p.type]({el:d.find("td"),propertiesView:n,args:"undefined"==typeof p.args?{}:p.args}),n.propertyControllers.push(c),c.render(),c.initChangeEvents()}}this.$(".section-tabs li").click(function(){var t=e(this),i=n.$('.sections .section[data-section="'+t.data("section")+'"]');n.$(".sections .section").not(i).hide().removeClass("active"),i.show().addClass("active"),n.$(".section-tabs li").not(t).removeClass("active"),t.addClass("active")}).eq(0).click(),this.$(".toolbar select").change(function(){n.setActivateSelector(e(this).find(":selected").data("selector"))})},setRuleValue:function(e,t){if("undefined"!=typeof this.activeSelector&&"undefined"!=typeof this.activeSelector.rules){for(var i=!0,s=0;s<this.activeSelector.rules.length;s++)if(this.activeSelector.rules[s].directive===e){this.activeSelector.rules[s].value=t,i=!1;break}i&&this.activeSelector.rules.push({directive:e,value:t}),this.updateMainEditor(!1)}},getRuleValue:function(e){if("undefined"==typeof this.activeSelector||"undefined"==typeof this.activeSelector.rules)return"";for(var t=0;t<this.activeSelector.rules.length;t++)if(this.activeSelector.rules[t].directive===e)return this.activeSelector.rules[t].value;return""},updateMainEditor:function(e){var t;"undefined"==typeof e||e===!0?(t=this.parser.compressCSS(this.parsed),t=t.filter(function(e){return"undefined"!=typeof e.type||e.rules.length>0})):t=this.parsed,this.editor.codeMirror.setValue(this.parser.getCSSForEditor(t).trim())},show:function(){this.editorExpandedBefore=this.editor.isExpanded(),this.editor.setExpand(!0),this.$el.show().animate({left:0},"fast")},hide:function(){this.editor.setExpand(this.editorExpandedBefore),this.$el.animate({left:-338},"fast",function(){e(this).hide()}),this.updateMainEditor(!0)},isVisible:function(){return this.$el.is(":visible")},loadCSS:function(t,i){this.css=t,this.parsed=this.parser.compressCSS(this.parser.parseCSS(t));for(var s=this.$(".toolbar select").empty(),n=0;n<this.parsed.length;n++){var r=this.parsed[n];if("undefined"!=typeof r.subStyles)for(var o=0;o<r.subStyles.length;o++){var a=r.subStyles[o];s.append(e("<option>").html(r.selector+": "+a.selector).attr("val",r.selector+": "+a.selector).data("selector",a))}else s.append(e("<option>").html(r.selector).attr("val",r.selector).data("selector",r))}"undefined"==typeof i&&(i=s.find("option").eq(0).attr("val")),s.val(i).change()},setActivateSelector:function(e){this.activeSelector=e;for(var t=0;t<this.propertyControllers.length;t++)this.propertyControllers[t].refreshFromRule()},addSelector:function(e){var t=this.$(".toolbar select");t.val(e),t.val()===e?t.change():(this.editor.addEmptySelector(e),this.loadCSS(this.editor.codeMirror.getValue(),e)),t.addClass("highlighted"),setTimeout(function(){t.removeClass("highlighted")},2e3)}}),s.view.propertyController=Backbone.View.extend({template:t.template('<input type="text" value="" />'),activeRule:null,args:null,propertiesView:null,initialize:function(e){this.args=e.args,this.propertiesView=e.propertiesView,this.on("set_value",this.updateRule,this),this.on("change",this.updateRule,this)},render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input")},initChangeEvents:function(){var t=this;this.field.on("change keyup",function(){t.trigger("change",e(this).val())})},updateRule:function(){this.propertiesView.setRuleValue(this.args.property,this.getValue())},refreshFromRule:function(){var e=this.propertiesView.getRuleValue(this.args.property);this.setValue(e,{silent:!0})},getValue:function(){return this.field.val()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),i.silent||this.trigger("set_value",e)},reset:function(e){e=t.extend({silent:!1},e),this.setValue("",e)}}),s.view.properties.controllers={},s.view.properties.controllers.color=s.view.propertyController.extend({template:t.template('<input type="text" value="" />'),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),this.field.minicolors({})},initChangeEvents:function(){var e=this;this.field.on("change keyup",function(){e.trigger("change",e.field.minicolors("value"))})},getValue:function(){return this.field.minicolors("value")},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.minicolors("value",e),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.select=s.view.propertyController.extend({template:t.template("<select></select>"),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("select"),this.field.append(e('<option value=""></option>').html(""));for(var t in this.args.options)this.field.append(e("<option></option>").attr("value",t).html(this.args.options[t]));"undefined"!=typeof this.args.option_icons&&this.setupVisualSelect()},setupVisualSelect:function(){var t=this;this.field.hide();var i=e('<div class="select-tabs"></div>').appendTo(this.$el);e('<div class="select-tab" data-value=""><span class="fa fa-circle-o"></span></div>').appendTo(i);for(var s in this.args.option_icons)e('<div class="select-tab"></div>').appendTo(i).append(e('<span class="fa"></span>').addClass("fa-"+this.args.option_icons[s])).attr("data-value",s);i.find(".select-tab").css("width",100/i.find(">div").length+"%").click(function(){var s=e(this);i.find(".select-tab").removeClass("active"),s.addClass("active"),t.field.val(s.data("value")).change()})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),this.$(".select-tabs .select-tab").removeClass("active").filter('[data-value="'+e+'"]').addClass("active"),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.image=s.view.propertyController.extend({template:t.template('<input type="text" value="" /> <span class="select socss-button"><span class="fa fa-upload"></span></span>'),render:function(){var t=this;this.media=wp.media({title:i.loc.select_image,library:{type:"image"},button:{text:i.loc.select,close:!1}}),this.$el.append(e(this.template({select:i.loc.select}))),this.field=this.$el.find("input"),this.$(".select").click(function(){t.media.open()}),this.media.on("select",function(){var e=this.state().get("selection").first().attributes,i=t.args.value.replace("{{url}}",e.url);t.field.val(i).change(),t.media.close()},this.media)}}),s.view.properties.controllers.measurement=s.view.propertyController.extend({wrapperClass:"socss-field-measurement",render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupMeasurementField(this.field,{})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e).trigger("measurement_refresh"),i.silent||this.trigger("set_value",e)},units:["px","%","em","cm","mm","in","pt","pc","ex","ch","rem","vw","vh","vmin","vmax"],parseUnits:function(e){var t=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},i=this.units.map(t),s=new RegExp("([0-9\\.\\-]+)("+i.join("|")+")?","i"),n=s.exec(e);return null===n?{value:"",unit:""}:{value:n[1],unit:void 0===n[2]?"":n[2]}},setupMeasurementField:function(i,s){var n=this,r=i.parent();s=t.extend({defaultUnit:"px"},s),i.hide(),r.addClass(this.wrapperClass).data("unit",s.defaultUnit);for(var o=e('<input type="text" class="socss-field-input"/>').appendTo(r),a=e('<span class="dashicons dashicons-arrow-down"></span>').appendTo(r),l=e('<ul class="dropdown"></ul>').appendTo(r),c=e('<span class="units"></span>').html(s.defaultUnit).appendTo(r),d=0;d<n.units.length;d++){var p=e("<li></li>").html(n.units[d]).data("unit",n.units[d]);n.units[d]===s.defaultUnit&&p.addClass("active"),l.append(p)}var h=function(){var e=n.parseUnits(o.val());""!==e.unit&&e.unit!==r.data("unit")&&(o.val(e.value),u(e.unit)),""===e.value?i.val(""):i.val(e.value+r.data("unit"))},u=function(e){c.html(e),r.data("unit",e),o.trigger("keydown")};a.click(function(){l.toggle()}),l.find("li").click(function(){l.toggle(),u(e(this).data("unit")),h(),i.trigger("change")}),o.on("keyup keydown",function(t){var i=(e(this),"");"keydown"===t.type&&(t.keyCode>=48&&t.keyCode<=57?i=String.fromCharCode(t.keyCode):189===t.keyCode?i="-":190===t.keyCode&&(i="."));var s=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(o.val()+i).appendTo("body"),n=s.width();n=Math.min(n,63),s.remove(),c.css("left",n+12)}),o.on("keyup",function(e){h(),i.trigger("change")}),i.on("measurement_refresh",function(){var t=n.parseUnits(i.val());o.val(t.value);var a=""===t.unit?s.defaultUnit:t.unit;r.data("unit",a),c.html(a);var l=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(t.value).appendTo("body"),d=l.width();d=Math.min(d,63),l.remove(),c.css("left",d+12)});var v=e('<div class="socss-diw"></div>').appendTo(r),f=e('<div class="dec-button socss-button"><span class="fa fa-minus"></span></div>').appendTo(v),g=e('<div class="inc-button socss-button"><span class="fa fa-plus"></span></div>').appendTo(v);g.click(function(){var e=n.parseUnits(i.val());if(""===e.value)return!0;var t=Math.ceil(1.05*e.value);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")}),f.click(function(){var e=n.parseUnits(i.val());if(""===e.value)return!0;var t=Math.floor(e.value/1.05);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")})}}),s.view.properties.controllers.number=s.view.propertyController.extend({render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupNumberField(this.field,this.args)},setupNumberField:function(i,s){s=t.extend({change:null,"default":0,increment:1,decrement:-1,max:null,min:null},s);var n=i.parent();n.addClass("socss-field-number");var r=e('<div class="socss-diw"></div>').appendTo(n),o=e('<div class="dec-button socss-button">-</div>').appendTo(r);e('<div class="inc-button socss-button">+</div>').appendTo(r);return r.find("> div").click(function(t){t.preventDefault();var n=s["default"];""!==i.val()&&(n=Number(i.val())),n+=e(this).is(o)?s.decrement:s.increment,n=Math.round(100*n)/100,null!==s.max&&(n=Math.min(s.max,n)),null!==s.min&&(n=Math.max(s.min,n)),i.val(n),i.trigger("change")}),this}}),s.view.properties.controllers.sides=s.view.propertyController.extend({template:t.template(e("#template-sides-field").html().trim()),controllers:[],render:function(){var i=this;this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),i.args.hasAll||(this.$(".select-tab").eq(0).remove(),this.$(".select-tab").css("width","25%")),this.$(".select-tab").each(function(){for(var n=e(this).data("direction"),r=e('<li class="side">').appendTo(i.$(".sides")).hide(),o=0;o<i.args.controllers.length;o++){var a=i.args.controllers[o],l="";l="all"===n?a.args.propertyAll:a.args.property.replace("{dir}",n);var c=t.extend({},a.args,{property:l}),d=new s.view.properties.controllers[a.type]({el:e("<div>").appendTo(r),propertiesView:i.propertiesView,args:c});d.render(),d.initChangeEvents(),i.propertiesView.propertyControllers.push(d)}e(this).on("click",function(){i.$(".select-tab").removeClass("active"),e(this).addClass("active"),i.$(".sides .side").hide(),r.show()})}),this.$(".select-tab").eq(0).click()}})}(jQuery,_,socssOptions),jQuery(function(e){var t=window.socss,i=new t.view.editor({el:e("#so-custom-css-form").get(0)});i.render(),i.setSnippets(socssOptions.snippets),window.socss.mainEditor=i,e("#so-custom-css-getting-started a.hide").click(function(t){t.preventDefault(),e("#so-custom-css-getting-started").slideUp(),e.get(e(this).attr("href"))})});
1
+ !function(e,t,i){var s={model:{},collection:{},view:{},fn:{}};window.socss=s,s.view.toolbar=Backbone.View.extend({button:t.template('<li><a href="#" class="toolbar-button socss-button"><%= text %></a></li>'),editor:null,initialize:function(t){this.editor=t.editor;var i=this;this.$(".editor-expand").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_expand")}),this.$(".editor-visual").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_visual")})},addButton:function(t,i){var s=this,n=e(this.button({text:t})).appendTo(this.$(".toolbar-function-buttons .toolbar-buttons")).click(function(t){t.preventDefault(),e(this).blur(),s.trigger("click_"+i)});return n}}),s.view.editor=Backbone.View.extend({codeMirror:null,snippets:null,toolbar:null,visualProperties:null,inspector:null,cssSelectors:[],initialize:function(e){this.setupEditor()},render:function(){var t=this;this.toolbar=new s.view.toolbar({editor:this,el:this.$(".custom-css-toolbar")}),this.toolbar.editor=this,this.toolbar.render(),this.visualProperties=new s.view.properties({editor:this,el:e("#so-custom-css-properties")}),this.visualProperties.render(),this.toolbar.on("click_expand",function(){t.toggleExpand()}),this.toolbar.on("click_visual",function(){t.visualProperties.loadCSS(t.codeMirror.getValue()),t.visualProperties.show()}),this.preview=new s.view.preview({editor:this,el:this.$(".custom-css-preview")}),this.preview.render()},setupEditor:function(){var t=this;this.registerCodeMirrorAutocomplete(),this.codeMirror=CodeMirror.fromTextArea(this.$("textarea.css-editor").get(0),{tabSize:2,lineNumbers:!0,mode:"css",theme:"neat",gutters:["CodeMirror-lint-markers"],lint:!0});var s=this.$("textarea.css-editor").val();this.$el.on("submit",function(){s=t.codeMirror.getValue()}),e(window).bind("beforeunload",function(){return t.codeMirror.getValue()!==s?i.loc.leave:void 0}),this.$el.find(".custom-css-container").css("overflow","visible"),this.scaleEditor(),e(window).resize(function(){t.scaleEditor()}),this.setupCodeMirrorExtensions()},registerCodeMirrorAutocomplete:function(){var e=this,t={link:1,visited:1,active:1,hover:1,focus:1,"first-letter":1,"first-line":1,"first-child":1,before:1,after:1,lang:1};CodeMirror.registerHelper("hint","css",function(i){function s(e){for(var t in e)c&&0!==t.lastIndexOf(c,0)||p.push(t)}var n=i.getCursor(),r=i.getTokenAt(n),o=CodeMirror.innerMode(i.getMode(),r.state);if("css"===o.mode.name){if("keyword"===r.type&&0==="!important".indexOf(r.string))return{list:["!important"],from:CodeMirror.Pos(n.line,r.start),to:CodeMirror.Pos(n.line,r.end)};var a=r.start,l=n.ch,c=r.string.slice(0,l-a);/[^\w$_-]/.test(c)&&(c="",a=l=n.ch);var d=CodeMirror.resolveMode("text/css"),p=[],h=o.state.state;if("top"===h){for(var u=i.getLine(n.line).trim(),v=e.cssSelectors,f=0;f<v.length;f++)-1!==v[f].selector.indexOf(u)&&p.push(v[f].selector);if(p.length)return{list:p,from:CodeMirror.Pos(n.line,0),to:CodeMirror.Pos(n.line,l)}}else if("pseudo"===h||"variable-3"===r.type?s(t):"block"===h||"maybeprop"===h?s(d.propertyKeywords):"prop"===h||"parens"===h||"at"===h||"params"===h?(s(d.valueKeywords),s(d.colorKeywords)):("media"===h||"media_parens"===h)&&(s(d.mediaTypes),s(d.mediaFeatures)),p.length)return{list:p,from:CodeMirror.Pos(n.line,a),to:CodeMirror.Pos(n.line,l)}}})},setupCodeMirrorExtensions:function(){var e=this;this.codeMirror.on("cursorActivity",function(t){var i=t.getCursor(),s=t.getTokenAt(i);CodeMirror.innerMode(t.getMode(),s.state);if("qualifier"===s.type||"tag"===s.type||"builtin"===s.type){var n=t.getLine(i.line),r=n.substring(0,s.end);e.preview.highlight(r)}else e.preview.clearHighlight()}),this.codeMirror.on("keyup",function(e,t){(t.keyCode>=65&&t.keyCode<=90||189===t.keyCode&&!t.shiftKey||190===t.keyCode&&!t.shiftKey||51===t.keyCode&&t.shiftKey||189===t.keyCode&&t.shiftKey)&&e.showHint(t)})},scaleEditor:function(){this.$el.hasClass("expanded")?this.codeMirror.setSize("100%",e(window).outerHeight()-this.$(".custom-css-toolbar").outerHeight()):this.codeMirror.setSize("100%","auto")},isExpanded:function(){return this.$el.hasClass("expanded")},toggleExpand:function(){this.$el.toggleClass("expanded"),this.scaleEditor()},setExpand:function(e){e?this.$el.addClass("expanded"):this.$el.removeClass("expanded"),this.scaleEditor()},setSnippets:function(e){if(!t.isEmpty(e)){var i=this;this.snippets=new s.view.snippets({snippets:e}),this.snippets.editor=this,this.snippets.render(),this.toolbar.addButton("Snippets","snippets"),this.toolbar.on("click_snippets",function(){i.snippets.show()})}},addCode:function(e){var t=this.codeMirror,i="";i=1===t.doc.lineCount()&&0===t.doc.getLine(t.doc.lastLine()).length?"":0===t.doc.getLine(t.doc.lastLine()).length?"\n":"\n\n",t.doc.setCursor(t.doc.lastLine(),t.doc.getLine(t.doc.lastLine()).length),t.doc.replaceSelection(i+e)},addEmptySelector:function(e){this.addCode(e+" {\n \n}")},setInspector:function(e){var t=this;this.inspector=e,this.cssSelectors=e.pageSelectors,e.on("click_selector",function(e){t.visualProperties.isVisible()?t.visualProperties.addSelector(e):t.addEmptySelector(e)}),e.on("click_property",function(e){t.visualProperties.isVisible()||t.codeMirror.replaceSelection(e+";\n ")}),e.on("set_active_element",function(e,i){t.visualProperties.isVisible()&&i.length&&t.visualProperties.addSelector(i[0].selector)})}}),s.view.preview=Backbone.View.extend({template:t.template('<iframe class="preview-iframe" seamless="seamless"></iframe>'),editor:null,initialize:function(e){this.editor=e.editor;var t=this;this.editor.codeMirror.on("change",function(e,i){t.updatePreviewCss()})},render:function(){var t=this;this.$el.html(this.template()),this.$(".preview-iframe").attr("src",i.homeURL).load(function(){var i=e(this);i.contents().find("a").each(function(){var t=e(this).attr("href");if(void 0===t)return!0;var i=-1===t.indexOf("?")?"?":"&";e(this).attr("href",t+i+"so_css_preview=1")}),t.updatePreviewCss()}).mouseleave(function(){t.clearHighlight()})},updatePreviewCss:function(){var e=this.$(".preview-iframe");if(0!==e.length){var t=e.contents().find("head");0===t.find("style.siteorigin-custom-css").length&&t.append('<style class="siteorigin-custom-css" type="text/css"></style>');var i=t.find("style.siteorigin-custom-css"),s=this.editor.codeMirror.getValue();i.html(s)}},highlight:function(e){try{this.editor.inspector.hl.highlight(e)}catch(t){console.log("No inspector to highlight with")}},clearHighlight:function(){try{this.editor.inspector.hl.clear()}catch(e){console.log("No inspector to highlight with")}}}),s.view.snippets=Backbone.View.extend({template:t.template(e("#template-snippet-browser").html()),snippet:t.template('<li class="snippet"><%- name %></li>'),className:"css-editor-snippet-browser",snippets:null,editor:null,events:{"click .close":"hide","click .buttons .insert-snippet":"insertSnippet"},currentSnippet:null,initialize:function(e){this.snippets=e.snippets},render:function(){var t=this,i=function(i){i.preventDefault();var s=e(this);t.$(".snippets li.snippet").removeClass("active"),e(this).addClass("active"),t.viewSnippet({name:s.html(),description:s.data("description"),css:s.data("css")})};this.$el.html(this.template());for(var s=0;s<this.snippets.length;s++)e(this.snippet({name:this.snippets[s].Name})).data({description:this.snippets[s].Description,css:this.snippets[s].css}).appendTo(this.$("ul.snippets")).click(i);return t.$(".snippets li.snippet").eq(0).click(),this.attach(),this},viewSnippet:function(e){var t=this.$(".main .snippet-view");t.find(".snippet-title").html(e.name),t.find(".snippet-description").html(e.description),t.find(".snippet-code").html(e.css),this.currentSnippet=e},insertSnippet:function(){var e=this.editor.codeMirror,t=this.currentSnippet.css,i="";i=1===e.doc.lineCount()&&0===e.doc.getLine(e.doc.lastLine()).length?"":0===e.doc.getLine(e.doc.lastLine()).length?"\n":"\n\n",e.doc.setCursor(e.doc.lastLine(),e.doc.getLine(e.doc.lastLine()).length),e.doc.replaceSelection(i+t),this.hide()},attach:function(){this.$el.appendTo("body")},show:function(){this.$el.show()},hide:function(){this.$el.hide()}}),s.view.properties=Backbone.View.extend({model:s.model.cssRules,tabTemplate:t.template('<li data-section="<%- id %>"><span class="fa fa-<%- icon %>"></span> <%- title %></li>'),sectionTemplate:t.template('<div class="section" data-section="<%- id %>"><table class="fields-table"><tbody></tbody></table></div>'),controllerTemplate:t.template('<tr><th scope="row"><%- title %></th><td></td></tr>'),propertyControllers:[],editor:null,css:"",parsed:{},activeSelector:"",editorExpandedBefore:!1,events:{"click .close":"hide"},initialize:function(e){this.parser=new cssjs,this.editor=e.editor},render:function(){var n=this,r=i.propertyControllers;for(var o in r){var a=(e(this.tabTemplate({id:o,icon:r[o].icon,title:r[o].title})).appendTo(this.$(".section-tabs")),e(this.sectionTemplate({id:o})).appendTo(this.$(".sections")));if(!t.isEmpty(r[o].controllers))for(var l=0;l<r[o].controllers.length;l++){var c,d=e(n.controllerTemplate({title:r[o].controllers[l].title})).appendTo(a.find("tbody")),p=r[o].controllers[l];c="undefined"==typeof s.view.properties.controllers[p.type]?new s.view.propertyController({el:d.find("td"),propertiesView:n,args:"undefined"==typeof p.args?{}:p.args}):new s.view.properties.controllers[p.type]({el:d.find("td"),propertiesView:n,args:"undefined"==typeof p.args?{}:p.args}),n.propertyControllers.push(c),c.render(),c.initChangeEvents()}}this.$(".section-tabs li").click(function(){var t=e(this),i=n.$('.sections .section[data-section="'+t.data("section")+'"]');n.$(".sections .section").not(i).hide().removeClass("active"),i.show().addClass("active"),n.$(".section-tabs li").not(t).removeClass("active"),t.addClass("active")}).eq(0).click(),this.$(".toolbar select").change(function(){n.setActivateSelector(e(this).find(":selected").data("selector"))})},setRuleValue:function(e,t){if("undefined"!=typeof this.activeSelector&&"undefined"!=typeof this.activeSelector.rules){for(var i=!0,s=0;s<this.activeSelector.rules.length;s++)if(this.activeSelector.rules[s].directive===e){this.activeSelector.rules[s].value=t,i=!1;break}i&&this.activeSelector.rules.push({directive:e,value:t}),this.updateMainEditor(!1)}},getRuleValue:function(e){if("undefined"==typeof this.activeSelector||"undefined"==typeof this.activeSelector.rules)return"";for(var t=0;t<this.activeSelector.rules.length;t++)if(this.activeSelector.rules[t].directive===e)return this.activeSelector.rules[t].value;return""},updateMainEditor:function(e){var t;"undefined"==typeof e||e===!0?(t=this.parser.compressCSS(this.parsed),t=t.filter(function(e){return"undefined"!=typeof e.type||e.rules.length>0})):t=this.parsed,this.editor.codeMirror.setValue(this.parser.getCSSForEditor(t).trim())},show:function(){this.editorExpandedBefore=this.editor.isExpanded(),this.editor.setExpand(!0),this.$el.show().animate({left:0},"fast")},hide:function(){this.editor.setExpand(this.editorExpandedBefore),this.$el.animate({left:-338},"fast",function(){e(this).hide()}),this.updateMainEditor(!0)},isVisible:function(){return this.$el.is(":visible")},loadCSS:function(t,i){this.css=t,this.parsed=this.parser.compressCSS(this.parser.parseCSS(t));for(var s=this.$(".toolbar select").empty(),n=0;n<this.parsed.length;n++){var r=this.parsed[n];if("undefined"!=typeof r.subStyles)for(var o=0;o<r.subStyles.length;o++){var a=r.subStyles[o];s.append(e("<option>").html(r.selector+": "+a.selector).attr("val",r.selector+": "+a.selector).data("selector",a))}else s.append(e("<option>").html(r.selector).attr("val",r.selector).data("selector",r))}"undefined"==typeof i&&(i=s.find("option").eq(0).attr("val")),s.val(i).change()},setActivateSelector:function(e){this.activeSelector=e;for(var t=0;t<this.propertyControllers.length;t++)this.propertyControllers[t].refreshFromRule()},addSelector:function(e){var t=this.$(".toolbar select");t.val(e),t.val()===e?t.change():(this.editor.addEmptySelector(e),this.loadCSS(this.editor.codeMirror.getValue(),e)),t.addClass("highlighted"),setTimeout(function(){t.removeClass("highlighted")},2e3)}}),s.view.propertyController=Backbone.View.extend({template:t.template('<input type="text" value="" />'),activeRule:null,args:null,propertiesView:null,initialize:function(e){this.args=e.args,this.propertiesView=e.propertiesView,this.on("set_value",this.updateRule,this),this.on("change",this.updateRule,this)},render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input")},initChangeEvents:function(){var t=this;this.field.on("change keyup",function(){t.trigger("change",e(this).val())})},updateRule:function(){this.propertiesView.setRuleValue(this.args.property,this.getValue())},refreshFromRule:function(){var e=this.propertiesView.getRuleValue(this.args.property);this.setValue(e,{silent:!0})},getValue:function(){return this.field.val()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),i.silent||this.trigger("set_value",e)},reset:function(e){e=t.extend({silent:!1},e),this.setValue("",e)}}),s.view.properties.controllers={},s.view.properties.controllers.color=s.view.propertyController.extend({template:t.template('<input type="text" value="" />'),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),this.field.minicolors({})},initChangeEvents:function(){var e=this;this.field.on("change keyup",function(){e.trigger("change",e.field.minicolors("value"))})},getValue:function(){return this.field.minicolors("value")},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.minicolors("value",e),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.select=s.view.propertyController.extend({template:t.template("<select></select>"),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("select"),this.field.append(e('<option value=""></option>').html(""));for(var t in this.args.options)this.field.append(e("<option></option>").attr("value",t).html(this.args.options[t]));"undefined"!=typeof this.args.option_icons&&this.setupVisualSelect()},setupVisualSelect:function(){var t=this;this.field.hide();var i=e('<div class="select-tabs"></div>').appendTo(this.$el);e('<div class="select-tab" data-value=""><span class="fa fa-circle-o"></span></div>').appendTo(i);for(var s in this.args.option_icons)e('<div class="select-tab"></div>').appendTo(i).append(e('<span class="fa"></span>').addClass("fa-"+this.args.option_icons[s])).attr("data-value",s);i.find(".select-tab").css("width",100/i.find(">div").length+"%").click(function(){var s=e(this);i.find(".select-tab").removeClass("active"),s.addClass("active"),t.field.val(s.data("value")).change()})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),this.$(".select-tabs .select-tab").removeClass("active").filter('[data-value="'+e+'"]').addClass("active"),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.image=s.view.propertyController.extend({template:t.template('<input type="text" value="" /> <span class="select socss-button"><span class="fa fa-upload"></span></span>'),render:function(){var t=this;this.media=wp.media({title:i.loc.select_image,library:{type:"image"},button:{text:i.loc.select,close:!1}}),this.$el.append(e(this.template({select:i.loc.select}))),this.field=this.$el.find("input"),this.$(".select").click(function(){t.media.open()}),this.media.on("select",function(){var e=this.state().get("selection").first().attributes,i=t.args.value.replace("{{url}}",e.url);t.field.val(i).change(),t.media.close()},this.media)}}),s.view.properties.controllers.measurement=s.view.propertyController.extend({wrapperClass:"socss-field-measurement",render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupMeasurementField(this.field,{})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e).trigger("measurement_refresh"),i.silent||this.trigger("set_value",e)},units:["px","%","em","cm","mm","in","pt","pc","ex","ch","rem","vw","vh","vmin","vmax"],parseUnits:function(e){var t=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},i=this.units.map(t),s=new RegExp("([0-9\\.\\-]+)("+i.join("|")+")?","i"),n=s.exec(e);return null===n?{value:"",unit:""}:{value:n[1],unit:void 0===n[2]?"":n[2]}},setupMeasurementField:function(i,s){var n=this,r=i.parent();s=t.extend({defaultUnit:"px"},s),i.hide(),r.addClass(this.wrapperClass).data("unit",s.defaultUnit);for(var o=e('<input type="text" class="socss-field-input"/>').appendTo(r),a=e('<span class="dashicons dashicons-arrow-down"></span>').appendTo(r),l=e('<ul class="dropdown"></ul>').appendTo(r),c=e('<span class="units"></span>').html(s.defaultUnit).appendTo(r),d=0;d<n.units.length;d++){var p=e("<li></li>").html(n.units[d]).data("unit",n.units[d]);n.units[d]===s.defaultUnit&&p.addClass("active"),l.append(p)}var h=function(){var e=n.parseUnits(o.val());""!==e.unit&&e.unit!==r.data("unit")&&(o.val(e.value),u(e.unit)),""===e.value?i.val(""):i.val(e.value+r.data("unit"))},u=function(e){c.html(e),r.data("unit",e),o.trigger("keydown")};a.click(function(){l.toggle()}),l.find("li").click(function(){l.toggle(),u(e(this).data("unit")),h(),i.trigger("change")}),o.on("keyup keydown",function(t){var i=(e(this),"");"keydown"===t.type&&(t.keyCode>=48&&t.keyCode<=57?i=String.fromCharCode(t.keyCode):189===t.keyCode?i="-":190===t.keyCode&&(i="."));var s=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(o.val()+i).appendTo("body"),n=s.width();n=Math.min(n,63),s.remove(),c.css("left",n+12)}),o.on("keyup",function(e){h(),i.trigger("change")}),i.on("measurement_refresh",function(){var t=n.parseUnits(i.val());o.val(t.value);var a=""===t.unit?s.defaultUnit:t.unit;r.data("unit",a),c.html(a);var l=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(t.value).appendTo("body"),d=l.width();d=Math.min(d,63),l.remove(),c.css("left",d+12)});var v=e('<div class="socss-diw"></div>').appendTo(r),f=e('<div class="dec-button socss-button"><span class="fa fa-minus"></span></div>').appendTo(v),m=e('<div class="inc-button socss-button"><span class="fa fa-plus"></span></div>').appendTo(v);m.click(function(){var e=n.parseUnits(i.val());if(""===e.value)return!0;var t=Math.ceil(1.05*e.value);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")}),f.click(function(){var e=n.parseUnits(i.val());if(""===e.value)return!0;var t=Math.floor(e.value/1.05);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")})}}),s.view.properties.controllers.number=s.view.propertyController.extend({render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupNumberField(this.field,this.args)},setupNumberField:function(i,s){s=t.extend({change:null,"default":0,increment:1,decrement:-1,max:null,min:null},s);var n=i.parent();n.addClass("socss-field-number");var r=e('<div class="socss-diw"></div>').appendTo(n),o=e('<div class="dec-button socss-button">-</div>').appendTo(r);e('<div class="inc-button socss-button">+</div>').appendTo(r);return r.find("> div").click(function(t){t.preventDefault();var n=s["default"];""!==i.val()&&(n=Number(i.val())),n+=e(this).is(o)?s.decrement:s.increment,n=Math.round(100*n)/100,null!==s.max&&(n=Math.min(s.max,n)),null!==s.min&&(n=Math.max(s.min,n)),i.val(n),i.trigger("change")}),this}}),s.view.properties.controllers.sides=s.view.propertyController.extend({template:t.template(e("#template-sides-field").html().trim()),controllers:[],render:function(){var i=this;this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),i.args.hasAll||(this.$(".select-tab").eq(0).remove(),this.$(".select-tab").css("width","25%")),this.$(".select-tab").each(function(){for(var n=e(this).data("direction"),r=e('<li class="side">').appendTo(i.$(".sides")).hide(),o=0;o<i.args.controllers.length;o++){var a=i.args.controllers[o],l="";l="all"===n?a.args.propertyAll:a.args.property.replace("{dir}",n);var c=t.extend({},a.args,{property:l}),d=new s.view.properties.controllers[a.type]({el:e("<div>").appendTo(r),propertiesView:i.propertiesView,args:c});d.render(),d.initChangeEvents(),i.propertiesView.propertyControllers.push(d)}e(this).on("click",function(){i.$(".select-tab").removeClass("active"),e(this).addClass("active"),i.$(".sides .side").hide(),r.show()})}),this.$(".select-tab").eq(0).click()}})}(jQuery,_,socssOptions),jQuery(function(e){var t=window.socss,i=new t.view.editor({el:e("#so-custom-css-form").get(0)});i.render(),i.setSnippets(socssOptions.snippets),window.socss.mainEditor=i,e("#so-custom-css-getting-started a.hide").click(function(t){t.preventDefault(),e("#so-custom-css-getting-started").slideUp(),e.get(e(this).attr("href"))})});
lib/codemirror/addon/fold/comment-fold.js CHANGED
@@ -28,7 +28,9 @@ CodeMirror.registerGlobalHelper("fold", "comment", function(mode) {
28
  continue;
29
  }
30
  if (pass == 1 && found < start.ch) return;
31
- if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1)))) {
 
 
32
  startCh = found + startToken.length;
33
  break;
34
  }
28
  continue;
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;
36
  }
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=0>=m?-1:c.lastIndexOf(r,m-1);if(-1!=d){if(1==a&&d<n.ch)return;if(/comment/.test(t.getTokenTypeAt(e.Pos(l,d+1)))){f=d+r.length;break}m=d-1}else{if(1==a)return;a=1,m=c.length}}var u,b,s=1,g=t.lastLine();e:for(var h=l;g>=h;++h)for(var k=t.getLine(h),v=h==l?f:0;;){var p=k.indexOf(r,v),C=k.indexOf(i,v);if(0>p&&(p=k.length),0>C&&(C=k.length),v=Math.min(p,C),v==k.length)break;if(v==p)++s;else if(!--s){u=h,b=v;break e}++v}if(null!=u&&(l!=u||b!=f))return{from:e.Pos(l,f),to:e.Pos(u,b)}}})});
1
+ !function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerGlobalHelper("fold","comment",function(e){return e.blockCommentStart&&e.blockCommentEnd},function(t,n){var o=t.getModeAt(n),r=o.blockCommentStart,i=o.blockCommentEnd;if(r&&i){for(var f,l=n.line,c=t.getLine(l),m=n.ch,a=0;;){var d=0>=m?-1:c.lastIndexOf(r,m-1);if(-1!=d){if(1==a&&d<n.ch)return;if(/comment/.test(t.getTokenTypeAt(e.Pos(l,d+1)))&&(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;g>=h;++h)for(var k=t.getLine(h),p=h==l?f:0;;){var v=k.indexOf(r,p),y=k.indexOf(i,p);if(0>v&&(v=k.length),0>y&&(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/markdown-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","markdown",function(n,t){function r(t){var r=n.getTokenTypeAt(e.Pos(t,0));return r&&/\bheader\b/.test(r)}function i(e,n,t){var i=n&&n.match(/^#+/);return i&&r(e)?i[0].length:(i=t&&t.match(/^[=\-]+\s*$/),i&&r(e+1)?"="==t[0]?1:2:o)}var o=100,f=n.getLine(t.line),l=n.getLine(t.line+1),c=i(t.line,f,l);if(c===o)return void 0;for(var u=n.lastLine(),d=t.line,a=n.getLine(d+2);u>d&&!(i(d+1,l,a)<=c);)++d,l=a,a=n.getLine(d+2);return{from:e.Pos(t.line,f.length),to:e.Pos(d,n.getLine(d).length)}})});
1
+ !function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("fold","markdown",function(n,t){function r(t){var r=n.getTokenTypeAt(e.Pos(t,0));return r&&/\bheader\b/.test(r)}function i(e,n,t){var i=n&&n.match(/^#+/);return i&&r(e)?i[0].length:(i=t&&t.match(/^[=\-]+\s*$/),i&&r(e+1)?"="==t[0]?1:2:o)}var o=100,f=n.getLine(t.line),l=n.getLine(t.line+1),c=i(t.line,f,l);if(c!==o){for(var u=n.lastLine(),d=t.line,a=n.getLine(d+2);u>d&&!(i(d+1,l,a)<=c);)++d,l=a,a=n.getLine(d+2);return{from:e.Pos(t.line,f.length),to:e.Pos(d,n.getLine(d).length)}}})});
lib/codemirror/addon/hint/anyword-hint.js CHANGED
@@ -21,7 +21,7 @@
21
  while (start && word.test(curLine.charAt(start - 1))) --start;
22
  var curWord = start != end && curLine.slice(start, end);
23
 
24
- var list = [], seen = {};
25
  var re = new RegExp(word.source, "g");
26
  for (var dir = -1; dir <= 1; dir += 2) {
27
  var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir;
21
  while (start && word.test(curLine.charAt(start - 1))) --start;
22
  var curWord = start != end && curLine.slice(start, end);
23
 
24
+ var list = options && options.list || [], seen = {};
25
  var re = new RegExp(word.source, "g");
26
  for (var dir = -1; dir <= 1; dir += 2) {
27
  var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir;
lib/codemirror/addon/hint/anyword-hint.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";var r=/[\w$]+/,o=500;e.registerHelper("hint","anyword",function(t,i){for(var n=i&&i.word||r,f=i&&i.range||o,a=t.getCursor(),c=t.getLine(a.line),s=a.ch,l=s;l&&n.test(c.charAt(l-1));)--l;for(var d=l!=s&&c.slice(l,s),u=[],p={},g=new RegExp(n.source,"g"),h=-1;1>=h;h+=2)for(var m=a.line,y=Math.min(Math.max(m+h*f,t.firstLine()),t.lastLine())+h;m!=y;m+=h)for(var b,v=t.getLine(m);b=g.exec(v);)(m!=a.line||b[0]!==d)&&(d&&0!=b[0].lastIndexOf(d,0)||Object.prototype.hasOwnProperty.call(p,b[0])||(p[b[0]]=!0,u.push(b[0])));return{list:u,from:e.Pos(a.line,l),to:e.Pos(a.line,s)}})});
1
+ !function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";var r=/[\w$]+/,t=500;e.registerHelper("hint","anyword",function(o,i){for(var n=i&&i.word||r,f=i&&i.range||t,s=o.getCursor(),a=o.getLine(s.line),c=s.ch,l=c;l&&n.test(a.charAt(l-1));)--l;for(var d=l!=c&&a.slice(l,c),u=i&&i.list||[],p={},g=new RegExp(n.source,"g"),h=-1;1>=h;h+=2)for(var m=s.line,y=Math.min(Math.max(m+h*f,o.firstLine()),o.lastLine())+h;m!=y;m+=h)for(var b,v=o.getLine(m);b=g.exec(v);)(m!=s.line||b[0]!==d)&&(d&&0!=b[0].lastIndexOf(d,0)||Object.prototype.hasOwnProperty.call(p,b[0])||(p[b[0]]=!0,u.push(b[0])));return{list:u,from:e.Pos(s.line,l),to:e.Pos(s.line,c)}})});
lib/codemirror/addon/hint/show-hint.js CHANGED
@@ -25,25 +25,35 @@
25
  };
26
 
27
  CodeMirror.defineExtension("showHint", function(options) {
28
- // We want a single cursor position.
29
- if (this.listSelections().length > 1 || this.somethingSelected()) return;
 
 
 
 
 
 
 
 
 
 
30
 
31
  if (this.state.completionActive) this.state.completionActive.close();
32
  var completion = this.state.completionActive = new Completion(this, options);
33
  if (!completion.options.hint) return;
34
 
35
  CodeMirror.signal(this, "startCompletion", this);
36
- completion.update();
37
  });
38
 
39
  function Completion(cm, options) {
40
  this.cm = cm;
41
- this.options = this.buildOptions(options);
42
  this.widget = null;
43
  this.debounce = 0;
44
  this.tick = 0;
45
- this.startPos = this.cm.getCursor();
46
- this.startLen = this.cm.getLine(this.startPos.line).length;
47
 
48
  var self = this;
49
  cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); });
@@ -61,6 +71,7 @@
61
  this.tick = null;
62
  this.cm.off("cursorActivity", this.activityFunc);
63
 
 
64
  if (this.widget) this.widget.close();
65
  CodeMirror.signal(this.cm, "endCompletion", this.cm);
66
  },
@@ -78,15 +89,6 @@
78
  this.close();
79
  },
80
 
81
- showHints: function(data) {
82
- if (!data || !data.list.length || !this.active()) return this.close();
83
-
84
- if (this.options.completeSingle && data.list.length == 1)
85
- this.pick(data, 0);
86
- else
87
- this.showWidget(data);
88
- },
89
-
90
  cursorActivity: function() {
91
  if (this.debounce) {
92
  cancelAnimationFrame(this.debounce);
@@ -105,47 +107,48 @@
105
  }
106
  },
107
 
108
- update: function() {
109
  if (this.tick == null) return;
110
- if (this.data) CodeMirror.signal(this.data, "update");
111
  if (!this.options.hint.async) {
112
- this.finishUpdate(this.options.hint(this.cm, this.options), myTick);
113
  } else {
114
  var myTick = ++this.tick, self = this;
115
  this.options.hint(this.cm, function(data) {
116
- if (self.tick == myTick) self.finishUpdate(data);
117
  }, this.options);
118
  }
119
  },
120
 
121
- finishUpdate: function(data) {
 
 
122
  this.data = data;
123
- var picked = this.widget && this.widget.picked;
 
124
  if (this.widget) this.widget.close();
125
  if (data && data.list.length) {
126
- if (picked && data.list.length == 1) this.pick(data, 0);
127
- else this.widget = new Widget(this, data);
 
 
 
 
128
  }
129
- },
130
-
131
- showWidget: function(data) {
132
- this.data = data;
133
- this.widget = new Widget(this, data);
134
- CodeMirror.signal(data, "shown");
135
- },
136
-
137
- buildOptions: function(options) {
138
- var editor = this.cm.options.hintOptions;
139
- var out = {};
140
- for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
141
- if (editor) for (var prop in editor)
142
- if (editor[prop] !== undefined) out[prop] = editor[prop];
143
- if (options) for (var prop in options)
144
- if (options[prop] !== undefined) out[prop] = options[prop];
145
- return out;
146
  }
147
  };
148
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  function getText(completion) {
150
  if (typeof completion == "string") return completion;
151
  else return completion.text;
@@ -344,34 +347,79 @@
344
  }
345
  };
346
 
347
- CodeMirror.registerHelper("hint", "auto", function(cm, options) {
348
- var helpers = cm.getHelpers(cm.getCursor(), "hint"), words;
 
 
 
 
 
 
 
 
349
  if (helpers.length) {
350
- for (var i = 0; i < helpers.length; i++) {
351
- var cur = helpers[i](cm, options);
352
- if (cur && cur.list.length) return cur;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
  }
 
 
354
  } else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
355
- if (words) return CodeMirror.hint.fromList(cm, {words: words});
356
  } else if (CodeMirror.hint.anyword) {
357
- return CodeMirror.hint.anyword(cm, options);
 
 
358
  }
 
 
 
 
359
  });
360
 
361
  CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
362
  var cur = cm.getCursor(), token = cm.getTokenAt(cur);
 
 
 
 
 
 
363
  var found = [];
364
  for (var i = 0; i < options.words.length; i++) {
365
  var word = options.words[i];
366
- if (word.slice(0, token.string.length) == token.string)
367
  found.push(word);
368
  }
369
 
370
- if (found.length) return {
371
- list: found,
372
- from: CodeMirror.Pos(cur.line, token.start),
373
- to: CodeMirror.Pos(cur.line, token.end)
374
- };
375
  });
376
 
377
  CodeMirror.commands.autocomplete = CodeMirror.showHint;
@@ -382,7 +430,7 @@
382
  alignWithWord: true,
383
  closeCharacters: /[\s()\[\]{};:>,]/,
384
  closeOnUnfocus: true,
385
- completeOnSingleClick: false,
386
  container: null,
387
  customKeys: null,
388
  extraKeys: null
25
  };
26
 
27
  CodeMirror.defineExtension("showHint", function(options) {
28
+ options = parseOptions(this, this.getCursor("start"), options);
29
+ var selections = this.listSelections()
30
+ if (selections.length > 1) return;
31
+ // By default, don't allow completion when something is selected.
32
+ // A hint function can have a `supportsSelection` property to
33
+ // indicate that it can handle selections.
34
+ if (this.somethingSelected()) {
35
+ if (!options.hint.supportsSelection) return;
36
+ // Don't try with cross-line selections
37
+ for (var i = 0; i < selections.length; i++)
38
+ if (selections[i].head.line != selections[i].anchor.line) return;
39
+ }
40
 
41
  if (this.state.completionActive) this.state.completionActive.close();
42
  var completion = this.state.completionActive = new Completion(this, options);
43
  if (!completion.options.hint) return;
44
 
45
  CodeMirror.signal(this, "startCompletion", this);
46
+ completion.update(true);
47
  });
48
 
49
  function Completion(cm, options) {
50
  this.cm = cm;
51
+ this.options = options;
52
  this.widget = null;
53
  this.debounce = 0;
54
  this.tick = 0;
55
+ this.startPos = this.cm.getCursor("start");
56
+ this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length;
57
 
58
  var self = this;
59
  cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); });
71
  this.tick = null;
72
  this.cm.off("cursorActivity", this.activityFunc);
73
 
74
+ if (this.widget && this.data) CodeMirror.signal(this.data, "close");
75
  if (this.widget) this.widget.close();
76
  CodeMirror.signal(this.cm, "endCompletion", this.cm);
77
  },
89
  this.close();
90
  },
91
 
 
 
 
 
 
 
 
 
 
92
  cursorActivity: function() {
93
  if (this.debounce) {
94
  cancelAnimationFrame(this.debounce);
107
  }
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);
132
+ } else {
133
+ this.widget = new Widget(this, data);
134
+ CodeMirror.signal(data, "shown");
135
+ }
136
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  }
138
  };
139
 
140
+ function parseOptions(cm, pos, options) {
141
+ var editor = cm.options.hintOptions;
142
+ var out = {};
143
+ for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
144
+ if (editor) for (var prop in editor)
145
+ if (editor[prop] !== undefined) out[prop] = editor[prop];
146
+ if (options) for (var prop in options)
147
+ if (options[prop] !== undefined) out[prop] = options[prop];
148
+ if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos)
149
+ return out;
150
+ }
151
+
152
  function getText(completion) {
153
  if (typeof completion == "string") return completion;
154
  else return completion.text;
347
  }
348
  };
349
 
350
+ function applicableHelpers(cm, helpers) {
351
+ if (!cm.somethingSelected()) return helpers
352
+ var result = []
353
+ for (var i = 0; i < helpers.length; i++)
354
+ if (helpers[i].supportsSelection) result.push(helpers[i])
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")) {
395
+ return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) }
396
  } else if (CodeMirror.hint.anyword) {
397
+ return function(cm, options) { return CodeMirror.hint.anyword(cm, options) }
398
+ } else {
399
+ return function() {}
400
  }
401
+ }
402
+
403
+ CodeMirror.registerHelper("hint", "auto", {
404
+ resolve: resolveAutoHints
405
  });
406
 
407
  CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
408
  var cur = cm.getCursor(), token = cm.getTokenAt(cur);
409
+ var to = CodeMirror.Pos(cur.line, token.end);
410
+ if (token.string && /\w/.test(token.string[token.string.length - 1])) {
411
+ var term = token.string, from = CodeMirror.Pos(cur.line, token.start);
412
+ } else {
413
+ var term = "", from = to;
414
+ }
415
  var found = [];
416
  for (var i = 0; i < options.words.length; i++) {
417
  var word = options.words[i];
418
+ if (word.slice(0, term.length) == term)
419
  found.push(word);
420
  }
421
 
422
+ if (found.length) return {list: found, from: from, to: to};
 
 
 
 
423
  });
424
 
425
  CodeMirror.commands.autocomplete = CodeMirror.showHint;
430
  alignWithWord: true,
431
  closeCharacters: /[\s()\[\]{};:>,]/,
432
  closeOnUnfocus: true,
433
+ completeOnSingleClick: true,
434
  container: null,
435
  customKeys: null,
436
  extraKeys: null
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=this.buildOptions(i),this.widget=null,this.debounce=0,this.tick=0,this.startPos=this.cm.getCursor(),this.startLen=this.cm.getLine(this.startPos.line).length;var e=this;t.on("cursorActivity",this.activityFunc=function(){e.cursorActivity()})}function e(t){return"string"==typeof t?t:t.text}function n(t,i){function e(t,e){var o;o="string"!=typeof e?function(t){return e(t,i)}:n.hasOwnProperty(e)?n[e]:e,s[t]=o}var n={Up:function(){i.moveFocus(-1)},Down:function(){i.moveFocus(1)},PageUp:function(){i.moveFocus(-i.menuSize()+1,!0)},PageDown:function(){i.moveFocus(i.menuSize()-1,!0)},Home:function(){i.setFocus(0)},End:function(){i.setFocus(i.length-1)},Enter:i.pick,Tab:i.pick,Esc:i.close},o=t.options.customKeys,s=o?{}:n;if(o)for(var c in o)o.hasOwnProperty(c)&&e(c,o[c]);var h=t.options.extraKeys;if(h)for(var c in h)h.hasOwnProperty(c)&&e(c,h[c]);return s}function o(t,i){for(;i&&i!=t;){if("LI"===i.nodeName.toUpperCase()&&i.parentNode==t)return i;i=i.parentNode}}function s(i,s){this.completion=i,this.data=s,this.picked=!1;var r=this,l=i.cm,a=this.hints=document.createElement("ul");a.className="CodeMirror-hints",this.selectedHint=s.selectedHint||0;for(var u=s.list,f=0;f<u.length;++f){var d=a.appendChild(document.createElement("li")),p=u[f],m=c+(f!=this.selectedHint?"":" "+h);null!=p.className&&(m=p.className+" "+m),d.className=m,p.render?p.render(d,s,p):d.appendChild(document.createTextNode(p.displayText||e(p))),d.hintId=f}var g=l.cursorCoords(i.options.alignWithWord?s.from:null),v=g.left,y=g.bottom,w=!0;a.style.left=v+"px",a.style.top=y+"px";var k=window.innerWidth||Math.max(document.body.offsetWidth,document.documentElement.offsetWidth),H=window.innerHeight||Math.max(document.body.offsetHeight,document.documentElement.offsetHeight);(i.options.container||document.body).appendChild(a);var C=a.getBoundingClientRect(),b=C.bottom-H;if(b>0){var A=C.bottom-C.top,x=g.top-(g.bottom-C.top);if(x-A>0)a.style.top=(y=g.top-A)+"px",w=!1;else if(A>H){a.style.height=H-5+"px",a.style.top=(y=g.bottom-C.top)+"px";var T=l.getCursor();s.from.ch!=T.ch&&(g=l.cursorCoords(T),a.style.left=(v=g.left)+"px",C=a.getBoundingClientRect())}}var M=C.right-k;if(M>0&&(C.right-C.left>k&&(a.style.width=k-5+"px",M-=C.right-C.left-k),a.style.left=(v=g.left-M)+"px"),l.addKeyMap(this.keyMap=n(i,{moveFocus:function(t,i){r.changeActive(r.selectedHint+t,i)},setFocus:function(t){r.changeActive(t)},menuSize:function(){return r.screenAmount()},length:u.length,close:function(){i.close()},pick:function(){r.pick()},data:s})),i.options.closeOnUnfocus){var F;l.on("blur",this.onBlur=function(){F=setTimeout(function(){i.close()},100)}),l.on("focus",this.onFocus=function(){clearTimeout(F)})}var N=l.getScrollInfo();return l.on("scroll",this.onScroll=function(){var t=l.getScrollInfo(),e=l.getWrapperElement().getBoundingClientRect(),n=y+N.top-t.top,o=n-(window.pageYOffset||(document.documentElement||document.body).scrollTop);return w||(o+=a.offsetHeight),o<=e.top||o>=e.bottom?i.close():(a.style.top=n+"px",void(a.style.left=v+N.left-t.left+"px"))}),t.on(a,"dblclick",function(t){var i=o(a,t.target||t.srcElement);i&&null!=i.hintId&&(r.changeActive(i.hintId),r.pick())}),t.on(a,"click",function(t){var e=o(a,t.target||t.srcElement);e&&null!=e.hintId&&(r.changeActive(e.hintId),i.options.completeOnSingleClick&&r.pick())}),t.on(a,"mousedown",function(){setTimeout(function(){l.focus()},20)}),t.signal(s,"select",u[0],a.firstChild),!0}var c="CodeMirror-hint",h="CodeMirror-hint-active";t.showHint=function(t,i,e){if(!i)return t.showHint(e);e&&e.async&&(i.async=!0);var n={hint:i};if(e)for(var o in e)n[o]=e[o];return t.showHint(n)},t.defineExtension("showHint",function(e){if(!(this.listSelections().length>1||this.somethingSelected())){this.state.completionActive&&this.state.completionActive.close();var n=this.state.completionActive=new i(this,e);n.options.hint&&(t.signal(this,"startCompletion",this),n.update())}});var r=window.requestAnimationFrame||function(t){return setTimeout(t,1e3/60)},l=window.cancelAnimationFrame||clearTimeout;i.prototype={close:function(){this.active()&&(this.cm.state.completionActive=null,this.tick=null,this.cm.off("cursorActivity",this.activityFunc),this.widget&&this.widget.close(),t.signal(this.cm,"endCompletion",this.cm))},active:function(){return this.cm.state.completionActive==this},pick:function(i,n){var o=i.list[n];o.hint?o.hint(this.cm,i,o):this.cm.replaceRange(e(o),o.from||i.from,o.to||i.to,"complete"),t.signal(i,"pick",o),this.close()},showHints:function(t){return t&&t.list.length&&this.active()?void(this.options.completeSingle&&1==t.list.length?this.pick(t,0):this.showWidget(t)):this.close()},cursorActivity:function(){this.debounce&&(l(this.debounce),this.debounce=0);var t=this.cm.getCursor(),i=this.cm.getLine(t.line);if(t.line!=this.startPos.line||i.length-t.ch!=this.startLen-this.startPos.ch||t.ch<this.startPos.ch||this.cm.somethingSelected()||t.ch&&this.options.closeCharacters.test(i.charAt(t.ch-1)))this.close();else{var e=this;this.debounce=r(function(){e.update()}),this.widget&&this.widget.disable()}},update:function(){if(null!=this.tick)if(this.data&&t.signal(this.data,"update"),this.options.hint.async){var i=++this.tick,e=this;this.options.hint(this.cm,function(t){e.tick==i&&e.finishUpdate(t)},this.options)}else this.finishUpdate(this.options.hint(this.cm,this.options),i)},finishUpdate:function(t){this.data=t;var i=this.widget&&this.widget.picked;this.widget&&this.widget.close(),t&&t.list.length&&(i&&1==t.list.length?this.pick(t,0):this.widget=new s(this,t))},showWidget:function(i){this.data=i,this.widget=new s(this,i),t.signal(i,"shown")},buildOptions:function(t){var i=this.cm.options.hintOptions,e={};for(var n in a)e[n]=a[n];if(i)for(var n in i)void 0!==i[n]&&(e[n]=i[n]);if(t)for(var n in t)void 0!==t[n]&&(e[n]=t[n]);return e}},s.prototype={close:function(){if(this.completion.widget==this){this.completion.widget=null,this.hints.parentNode.removeChild(this.hints),this.completion.cm.removeKeyMap(this.keyMap);var t=this.completion.cm;this.completion.options.closeOnUnfocus&&(t.off("blur",this.onBlur),t.off("focus",this.onFocus)),t.off("scroll",this.onScroll)}},disable:function(){this.completion.cm.removeKeyMap(this.keyMap);var t=this;this.keyMap={Enter:function(){t.picked=!0}},this.completion.cm.addKeyMap(this.keyMap)},pick:function(){this.completion.pick(this.data,this.selectedHint)},changeActive:function(i,e){if(i>=this.data.list.length?i=e?this.data.list.length-1:0:0>i&&(i=e?0:this.data.list.length-1),this.selectedHint!=i){var n=this.hints.childNodes[this.selectedHint];n.className=n.className.replace(" "+h,""),n=this.hints.childNodes[this.selectedHint=i],n.className+=" "+h,n.offsetTop<this.hints.scrollTop?this.hints.scrollTop=n.offsetTop-3:n.offsetTop+n.offsetHeight>this.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=n.offsetTop+n.offsetHeight-this.hints.clientHeight+3),t.signal(this.data,"select",this.data.list[this.selectedHint],n)}},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}},t.registerHelper("hint","auto",function(i,e){var n,o=i.getHelpers(i.getCursor(),"hint");if(o.length)for(var s=0;s<o.length;s++){var c=o[s](i,e);if(c&&c.list.length)return c}else if(n=i.getHelper(i.getCursor(),"hintWords")){if(n)return t.hint.fromList(i,{words:n})}else if(t.hint.anyword)return t.hint.anyword(i,e)}),t.registerHelper("hint","fromList",function(i,e){for(var n=i.getCursor(),o=i.getTokenAt(n),s=[],c=0;c<e.words.length;c++){var h=e.words[c];h.slice(0,o.string.length)==o.string&&s.push(h)}return s.length?{list:s,from:t.Pos(n.line,o.start),to:t.Pos(n.line,o.end)}:void 0}),t.commands.autocomplete=t.showHint;var a={hint:t.hint.auto,completeSingle:!0,alignWithWord:!0,closeCharacters:/[\s()\[\]{};:>,]/,closeOnUnfocus:!0,completeOnSingleClick:!1,container:null,customKeys:null,extraKeys:null};t.defineOption("hintOptions",null)});
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:0>i&&(i=e?0:this.data.list.length-1),this.selectedHint!=i){var n=this.hints.childNodes[this.selectedHint];n.className=n.className.replace(" "+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)}return h.length?{list:h,from:r,to:s}:void 0}),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)});
lib/codemirror/addon/hint/sql-hint.js CHANGED
@@ -112,9 +112,14 @@
112
  string = nameParts.pop();
113
  var table = nameParts.join(".");
114
 
 
 
115
  // Check if table is available. If not, find table by Alias
116
- if (!getItem(tables, table))
 
117
  table = findTableByAlias(table, editor);
 
 
118
 
119
  var columns = getItem(tables, table);
120
  if (columns && columns.columns)
@@ -122,11 +127,13 @@
122
 
123
  if (columns) {
124
  addMatches(result, string, columns, function(w) {
 
 
125
  if (typeof w == "string") {
126
- w = table + "." + w;
127
  } else {
128
  w = shallowClone(w);
129
- w.text = table + "." + w.text;
130
  }
131
  return useBacktick ? insertBackticks(w) : w;
132
  });
@@ -205,6 +212,7 @@
205
  CodeMirror.registerHelper("hint", "sql", function(editor, options) {
206
  tables = (options && options.tables) || {};
207
  var defaultTableName = options && options.defaultTable;
 
208
  defaultTable = defaultTableName && getItem(tables, defaultTableName);
209
  keywords = keywords || getKeywords(editor);
210
 
@@ -237,7 +245,8 @@
237
  } else {
238
  addMatches(result, search, tables, function(w) {return w;});
239
  addMatches(result, search, defaultTable, function(w) {return w;});
240
- addMatches(result, search, keywords, function(w) {return w.toUpperCase();});
 
241
  }
242
 
243
  return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)};
112
  string = nameParts.pop();
113
  var table = nameParts.join(".");
114
 
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)
127
 
128
  if (columns) {
129
  addMatches(result, string, columns, function(w) {
130
+ var tableInsert = table;
131
+ if (alias == true) tableInsert = aliasTable;
132
  if (typeof w == "string") {
133
+ w = tableInsert + "." + w;
134
  } else {
135
  w = shallowClone(w);
136
+ w.text = tableInsert + "." + w.text;
137
  }
138
  return useBacktick ? insertBackticks(w) : w;
139
  });
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
 
245
  } else {
246
  addMatches(result, search, tables, function(w) {return w;});
247
  addMatches(result, search, defaultTable, function(w) {return w;});
248
+ if (!disableKeywords)
249
+ addMatches(result, search, keywords, function(w) {return w.toUpperCase();});
250
  }
251
 
252
  return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)};
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,h,function(t){return f?u(t):t}),s(n,v,d,function(t){return f?u(t):t}),v=c.pop();var m=c.join(".");e(h,m)||(m=g(m,i));var x=e(h,m);return x&&x.columns&&(x=x.columns),x&&s(n,v,x,function(t){return"string"==typeof t?t=m+"."+t:(t=o(t),t.text=m+"."+t.text),f?u(t):t}),l}function c(t,r){if(t)for(var n=/[,;]/g,e=t.split(" "),o=0;o<e.length;o++)r(e[o]?e[o].replace(n,""):"")}function l(t){return t.line+t.ch/Math.pow(10,6)}function p(t){return A(Math.floor(t),+t.toString().split(".").pop())}function g(t,r){for(var n=r.doc,o=n.getValue(),i=t.toUpperCase(),s="",a="",u=[],f={start:A(0,0),end:A(r.lastLine(),r.getLineHandle(r.lastLine()).length)},g=o.indexOf(m.QUERY_DIV);-1!=g;)u.push(n.posFromIndex(g)),g=o.indexOf(m.QUERY_DIV,g+1);u.unshift(A(0,0)),u.push(A(r.lastLine(),r.getLineHandle(r.lastLine()).text.length));for(var d=0,v=l(r.getCursor()),x=0;x<u.length;x++){var b=l(u[x]);if(v>d&&b>=v){f={start:p(d),end:p(b)};break}d=b}for(var q=n.getRange(f.start,f.end,!1),x=0;x<q.length;x++){var y=q[x];if(c(y,function(t){var r=t.toUpperCase();r===i&&e(h,s)&&(a=s),r!==m.ALIAS_KEYWORD&&(s=t)}),a)break}return a}var h,d,v,m={QUERY_DIV:";",ALIAS_KEYWORD:"AS"},A=t.Pos;t.registerHelper("hint","sql",function(t,n){h=n&&n.tables||{};var o=n&&n.defaultTable;d=o&&e(h,o),v=v||r(t),o&&!d&&(d=g(o,t)),d=d||[],d.columns&&(d=d.columns);var i,a,u,c=t.getCursor(),l=[],p=t.getTokenAt(c);return p.end>c.ch&&(p.end=c.ch,p.string=p.string.slice(0,c.ch-p.start)),p.string.match(/^[.`\w@]\w*$/)?(u=p.string,i=p.start,a=p.end):(i=a=c.ch,u=""),"."==u.charAt(0)||"`"==u.charAt(0)?i=f(c,p,l,t):(s(l,u,h,function(t){return t}),s(l,u,d,function(t){return t}),s(l,u,v,function(t){return t.toUpperCase()})),{list:l,from:A(c.line,i),to:A(c.line,a)}})});
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);-1!=g;)u.push(n.posFromIndex(g)),g=o.indexOf(m.QUERY_DIV,g+1);u.unshift(A(0,0)),u.push(A(r.lastLine(),r.getLineHandle(r.lastLine()).text.length));for(var h=0,v=l(r.getCursor()),b=0;b<u.length;b++){var x=l(u[b]);if(v>h&&x>=v){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)}})});
lib/codemirror/addon/lint/css-lint.js CHANGED
@@ -18,15 +18,7 @@
18
  CodeMirror.registerHelper("lint", "css", function(text) {
19
  var found = [];
20
  if (!window.CSSLint) return found;
21
- // This has been modified to only display certain errors
22
- var results = CSSLint.verify(text, {
23
- "box-model": 1,
24
- "display-property-grouping": 1,
25
- "duplicate-properties": 1,
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;
18
  CodeMirror.registerHelper("lint", "css", function(text) {
19
  var found = [];
20
  if (!window.CSSLint) return found;
21
+ var results = CSSLint.verify(text), messages = results.messages, message = null;
 
 
 
 
 
 
 
 
22
  for ( var i = 0; i < messages.length; i++) {
23
  message = messages[i];
24
  var startLine = message.line -1, endLine = message.line -1, startCol = message.col -1, endCol = message.col;
lib/codemirror/addon/lint/css-lint.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("lint","css",function(r){var o=[];if(!window.CSSLint)return o;for(var i=CSSLint.verify(r,{"box-model":1,"display-property-grouping":1,"duplicate-properties":1,"empty-rules":1,"known-properties":1}),t=i.messages,n=null,s=0;s<t.length;s++){n=t[s];var p=n.line-1,l=n.line-1,f=n.col-1,u=n.col;o.push({from:e.Pos(p,f),to:e.Pos(l,u),message:n.message,severity:n.type})}return o})});
1
+ !function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("lint","css",function(r){var o=[];if(!window.CSSLint)return o;for(var i=CSSLint.verify(r),t=i.messages,n=null,s=0;s<t.length;s++){n=t[s];var f=n.line-1,c=n.line-1,l=n.col-1,u=n.col;o.push({from:e.Pos(f,l),to:e.Pos(c,u),message:n.message,severity:n.type})}return o})});
lib/codemirror/addon/lint/html-lint.js ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ // Depends on htmlhint.js from http://htmlhint.com/js/htmlhint.js
5
+
6
+ // declare global: HTMLHint
7
+
8
+ (function(mod) {
9
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
10
+ mod(require("../../lib/codemirror"), require("htmlhint"));
11
+ else if (typeof define == "function" && define.amd) // AMD
12
+ define(["../../lib/codemirror", "htmlhint"], mod);
13
+ else // Plain browser env
14
+ mod(CodeMirror);
15
+ })(function(CodeMirror) {
16
+ "use strict";
17
+
18
+ var defaultRules = {
19
+ "tagname-lowercase": true,
20
+ "attr-lowercase": true,
21
+ "attr-value-double-quotes": true,
22
+ "doctype-first": false,
23
+ "tag-pair": true,
24
+ "spec-char-escape": true,
25
+ "id-unique": true,
26
+ "src-not-empty": true,
27
+ "attr-no-duplication": true
28
+ };
29
+
30
+ CodeMirror.registerHelper("lint", "html", function(text, options) {
31
+ var found = [];
32
+ if (!window.HTMLHint) return found;
33
+ var messages = HTMLHint.verify(text, options && options.rules || defaultRules);
34
+ for (var i = 0; i < messages.length; i++) {
35
+ var message = messages[i];
36
+ var startLine = message.line - 1, endLine = message.line - 1, startCol = message.col - 1, endCol = message.col;
37
+ found.push({
38
+ from: CodeMirror.Pos(startLine, startCol),
39
+ to: CodeMirror.Pos(endLine, endCol),
40
+ message: message.message,
41
+ severity : message.type
42
+ });
43
+ }
44
+ return found;
45
+ });
46
+ });
lib/codemirror/addon/lint/html-lint.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("htmlhint")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","htmlhint"],e):e(CodeMirror)}(function(e){"use strict";var t={"tagname-lowercase":!0,"attr-lowercase":!0,"attr-value-double-quotes":!0,"doctype-first":!1,"tag-pair":!0,"spec-char-escape":!0,"id-unique":!0,"src-not-empty":!0,"attr-no-duplication":!0};e.registerHelper("lint","html",function(r,i){var o=[];if(!window.HTMLHint)return o;for(var n=HTMLHint.verify(r,i&&i.rules||t),a=0;a<n.length;a++){var s=n[a],c=s.line-1,l=s.line-1,u=s.col-1,f=s.col;o.push({from:e.Pos(c,u),to:e.Pos(l,f),message:s.message,severity:s.type})}return o})});
lib/codemirror/addon/lint/lint.js CHANGED
@@ -61,13 +61,12 @@
61
  this.timeout = null;
62
  this.hasGutter = hasGutter;
63
  this.onMouseOver = function(e) { onMouseOver(cm, e); };
 
64
  }
65
 
66
- function parseOptions(cm, options) {
67
  if (options instanceof Function) return {getAnnotations: options};
68
  if (!options || options === true) options = {};
69
- if (!options.getAnnotations) options.getAnnotations = cm.getHelper(CodeMirror.Pos(0, 0), "lint");
70
- if (!options.getAnnotations) throw new Error("Required option 'getAnnotations' missing (lint addon)");
71
  return options;
72
  }
73
 
@@ -117,13 +116,32 @@
117
  return tip;
118
  }
119
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  function startLinting(cm) {
121
  var state = cm.state.lint, options = state.options;
122
  var passOptions = options.options || options; // Support deprecated passing of `options` property in options
123
- if (options.async || options.getAnnotations.async)
124
- options.getAnnotations(cm.getValue(), updateLinting, passOptions, cm);
125
- else
126
- updateLinting(cm, options.getAnnotations(cm.getValue(), passOptions, cm));
 
 
 
127
  }
128
 
129
  function updateLinting(cm, annotationsNotSorted) {
@@ -187,7 +205,8 @@
187
  CodeMirror.defineOption("lint", false, function(cm, val, old) {
188
  if (old && old != CodeMirror.Init) {
189
  clearMarks(cm);
190
- cm.off("change", onChange);
 
191
  CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
192
  clearTimeout(cm.state.lint.timeout);
193
  delete cm.state.lint;
@@ -197,11 +216,16 @@
197
  var gutters = cm.getOption("gutters"), hasLintGutter = false;
198
  for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
199
  var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
200
- cm.on("change", onChange);
 
201
  if (state.options.tooltips != false)
202
  CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
203
 
204
  startLinting(cm);
205
  }
206
  });
 
 
 
 
207
  });
61
  this.timeout = null;
62
  this.hasGutter = hasGutter;
63
  this.onMouseOver = function(e) { onMouseOver(cm, e); };
64
+ this.waitingFor = 0
65
  }
66
 
67
+ function parseOptions(_cm, options) {
68
  if (options instanceof Function) return {getAnnotations: options};
69
  if (!options || options === true) options = {};
 
 
70
  return options;
71
  }
72
 
116
  return tip;
117
  }
118
 
119
+ function lintAsync(cm, getAnnotations, passOptions) {
120
+ var state = cm.state.lint
121
+ var id = ++state.waitingFor
122
+ function abort() {
123
+ id = -1
124
+ cm.off("change", abort)
125
+ }
126
+ cm.on("change", abort)
127
+ getAnnotations(cm.getValue(), function(annotations, arg2) {
128
+ cm.off("change", abort)
129
+ if (state.waitingFor != id) return
130
+ if (arg2 && annotations instanceof CodeMirror) annotations = arg2
131
+ updateLinting(cm, annotations)
132
+ }, passOptions, cm);
133
+ }
134
+
135
  function startLinting(cm) {
136
  var state = cm.state.lint, options = state.options;
137
  var passOptions = options.options || options; // Support deprecated passing of `options` property in options
138
+ var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint");
139
+ if (!getAnnotations) return;
140
+ if (options.async || getAnnotations.async) {
141
+ lintAsync(cm, getAnnotations, passOptions)
142
+ } else {
143
+ updateLinting(cm, getAnnotations(cm.getValue(), passOptions, cm));
144
+ }
145
  }
146
 
147
  function updateLinting(cm, annotationsNotSorted) {
205
  CodeMirror.defineOption("lint", false, function(cm, val, old) {
206
  if (old && old != CodeMirror.Init) {
207
  clearMarks(cm);
208
+ if (cm.state.lint.options.lintOnChange !== false)
209
+ cm.off("change", onChange);
210
  CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
211
  clearTimeout(cm.state.lint.timeout);
212
  delete cm.state.lint;
216
  var gutters = cm.getOption("gutters"), hasLintGutter = false;
217
  for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
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);
225
  }
226
  });
227
+
228
+ CodeMirror.defineExtension("performLint", function() {
229
+ if (this.state.lint) startLinting(this);
230
+ });
231
  });
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),s&&(o(s),s=null)}var s=e(n,r),u=setInterval(function(){if(s)for(var t=i;;t=t.parentNode){if(t&&11==t.nodeType&&(t=t.host),t==document.body)return;if(!t){a();break}}return s?void 0:clearInterval(u)},400);t.on(i,"mouseout",a)}function i(t,e,n){this.marked=[],this.options=e,this.timeout=null,this.hasGutter=n,this.onMouseOver=function(e){g(t,e)}}function a(e,n){if(n instanceof Function)return{getAnnotations:n};if(n&&n!==!0||(n={}),n.getAnnotations||(n.getAnnotations=e.getHelper(t.Pos(0,0),"lint")),!n.getAnnotations)throw new Error("Required option 'getAnnotations' missing (lint addon)");return n}function s(t){var e=t.state.lint;e.hasGutter&&t.clearGutter(h);for(var n=0;n<e.marked.length;++n)e.marked[n].clear();e.marked.length=0}function u(e,n,o,i){var a=document.createElement("div"),s=a;return a.className="CodeMirror-lint-marker-"+n,o&&(s=a.appendChild(document.createElement("div")),s.className="CodeMirror-lint-marker-multiple"),0!=i&&t.on(s,"mouseover",function(t){r(t,e,s)}),a}function l(t,e){return"error"==t?t:e}function c(t){for(var e=[],n=0;n<t.length;++n){var o=t[n],r=o.from.line;(e[r]||(e[r]=[])).push(o)}return e}function f(t){var e=t.severity;e||(e="error");var n=document.createElement("div");return n.className="CodeMirror-lint-message-"+e,n.appendChild(document.createTextNode(t.message)),n}function m(t){var e=t.state.lint,n=e.options,o=n.options||n;n.async||n.getAnnotations.async?n.getAnnotations(t.getValue(),d,o,t):d(t,n.getAnnotations(t.getValue(),o,t))}function d(t,e){s(t);for(var n=t.state.lint,o=n.options,r=c(e),i=0;i<r.length;++i){var a=r[i];if(a){for(var m=null,d=n.hasGutter&&document.createDocumentFragment(),p=0;p<a.length;++p){var v=a[p],g=v.severity;g||(g="error"),m=l(m,g),o.formatAnnotation&&(v=o.formatAnnotation(v)),n.hasGutter&&d.appendChild(f(v)),v.to&&n.marked.push(t.markText(v.from,v.to,{className:"CodeMirror-lint-mark-"+g,__annotation:v}))}n.hasGutter&&t.setGutterMarker(i,h,u(d,m,a.length>1,n.options.tooltips))}}o.onUpdateLinting&&o.onUpdateLinting(e,r,t)}function p(t){var e=t.state.lint;e&&(clearTimeout(e.timeout),e.timeout=setTimeout(function(){m(t)},e.options.delay||500))}function v(t,e){var n=e.target||e.srcElement;r(e,f(t),n)}function g(t,e){var n=e.target||e.srcElement;if(/\bCodeMirror-lint-mark-/.test(n.className))for(var o=n.getBoundingClientRect(),r=(o.left+o.right)/2,i=(o.top+o.bottom)/2,a=t.findMarksAt(t.coordsChar({left:r,top:i},"client")),s=0;s<a.length;++s){var u=a[s].__annotation;if(u)return v(u,e)}}var h="CodeMirror-lint-markers";t.defineOption("lint",!1,function(e,n,o){if(o&&o!=t.Init&&(s(e),e.off("change",p),t.off(e.getWrapperElement(),"mouseover",e.state.lint.onMouseOver),clearTimeout(e.state.lint.timeout),delete e.state.lint),n){for(var r=e.getOption("gutters"),u=!1,l=0;l<r.length;++l)r[l]==h&&(u=!0);var c=e.state.lint=new i(e,a(e,n),u);e.on("change",p),0!=c.options.tooltips&&t.on(e.getWrapperElement(),"mouseover",c.onMouseOver),m(e)}})});
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}}return l?void 0: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)})});
lib/codemirror/addon/merge/merge.js CHANGED
@@ -5,12 +5,12 @@
5
 
6
  (function(mod) {
7
  if (typeof exports == "object" && typeof module == "object") // CommonJS
8
- mod(require("../../lib/codemirror"), require("diff_match_patch"));
9
  else if (typeof define == "function" && define.amd) // AMD
10
  define(["../../lib/codemirror", "diff_match_patch"], mod);
11
  else // Plain browser env
12
- mod(CodeMirror, diff_match_patch);
13
- })(function(CodeMirror, diff_match_patch) {
14
  "use strict";
15
  var Pos = CodeMirror.Pos;
16
  var svgNS = "http://www.w3.org/2000/svg";
@@ -471,13 +471,10 @@
471
  if (left) left.init(leftPane, origLeft, options);
472
  if (right) right.init(rightPane, origRight, options);
473
 
474
- if (options.collapseIdentical) {
475
- updating = true;
476
  this.editor().operation(function() {
477
  collapseIdenticalStretches(self, options.collapseIdentical);
478
  });
479
- updating = false;
480
- }
481
  if (options.connect == "align") {
482
  this.aligners = [];
483
  alignChunks(this.left || this.right, true);
@@ -640,7 +637,7 @@
640
  mark.clear();
641
  cm.removeLineClass(from, "wrap", "CodeMirror-merge-collapsed-line");
642
  }
643
- widget.addEventListener("click", clear);
644
  return {mark: mark, clear: clear};
645
  }
646
 
5
 
6
  (function(mod) {
7
  if (typeof exports == "object" && typeof module == "object") // CommonJS
8
+ mod(require("../../lib/codemirror")); // Note non-packaged dependency diff_match_patch
9
  else if (typeof define == "function" && define.amd) // AMD
10
  define(["../../lib/codemirror", "diff_match_patch"], mod);
11
  else // Plain browser env
12
+ mod(CodeMirror);
13
+ })(function(CodeMirror) {
14
  "use strict";
15
  var Pos = CodeMirror.Pos;
16
  var svgNS = "http://www.w3.org/2000/svg";
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);
477
  });
 
 
478
  if (options.connect == "align") {
479
  this.aligners = [];
480
  alignChunks(this.left || this.right, true);
637
  mark.clear();
638
  cm.removeLineClass(from, "wrap", "CodeMirror-merge-collapsed-line");
639
  }
640
+ CodeMirror.on(widget, "click", clear);
641
  return {mark: mark, clear: clear};
642
  }
643
 
lib/codemirror/addon/merge/merge.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("diff_match_patch")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","diff_match_patch"],e):e(CodeMirror,diff_match_patch)}(function(e,t){"use strict";function r(e,t){this.mv=e,this.type=t,this.classes="left"==t?{chunk:"CodeMirror-merge-l-chunk",start:"CodeMirror-merge-l-chunk-start",end:"CodeMirror-merge-l-chunk-end",insert:"CodeMirror-merge-l-inserted",del:"CodeMirror-merge-l-deleted",connect:"CodeMirror-merge-l-connect"}:{chunk:"CodeMirror-merge-r-chunk",start:"CodeMirror-merge-r-chunk-start",end:"CodeMirror-merge-r-chunk-end",insert:"CodeMirror-merge-r-inserted",del:"CodeMirror-merge-r-deleted",connect:"CodeMirror-merge-r-connect"}}function i(t){t.diffOutOfDate&&(t.diff=w(t.orig.getValue(),t.edit.getValue()),t.chunks=y(t.diff),t.diffOutOfDate=!1,e.signal(t.edit,"updateDiff",t.diff))}function o(e){function t(t){j=!0,h=!1,"full"==t&&(e.svg&&N(e.svg),e.copyButtons&&N(e.copyButtons),c(e.edit,a.marked,e.classes),c(e.orig,s.marked,e.classes),a.from=a.to=s.from=s.to=0),i(e),e.showDifferences&&(f(e.edit,e.diff,a,DIFF_INSERT,e.classes),f(e.orig,e.diff,s,DIFF_DELETE,e.classes)),d(e),"align"==e.mv.options.connect&&v(e),j=!1}function r(t){j||(e.dealigned=!0,o(t))}function o(e){j||h||(clearTimeout(l),e===!0&&(h=!0),l=setTimeout(t,e===!0?20:250))}function n(t,i){e.diffOutOfDate||(e.diffOutOfDate=!0,a.from=a.to=s.from=s.to=0),r(i.text.length-1!=i.to.line-i.from.line)}var l,a={from:0,to:0,marked:[]},s={from:0,to:0,marked:[]},h=!1;return e.edit.on("change",n),e.orig.on("change",n),e.edit.on("markerAdded",r),e.edit.on("markerCleared",r),e.orig.on("markerAdded",r),e.orig.on("markerCleared",r),e.edit.on("viewportChange",function(){o(!1)}),e.orig.on("viewportChange",function(){o(!1)}),t(),t}function n(e){e.edit.on("scroll",function(){l(e,DIFF_INSERT)&&d(e)}),e.orig.on("scroll",function(){l(e,DIFF_DELETE)&&d(e)})}function l(e,t){if(e.diffOutOfDate)return!1;if(!e.lockScroll)return!0;var r,i,o=+new Date;if(t==DIFF_INSERT?(r=e.edit,i=e.orig):(r=e.orig,i=e.edit),r.state.scrollSetBy==e&&(r.state.scrollSetAt||0)+50>o)return!1;var n=r.getScrollInfo();if("align"==e.mv.options.connect)m=n.top;else{var l,s,c=.5*n.clientHeight,f=n.top+c,h=r.lineAtHeight(f,"local"),d=L(e.chunks,h,t==DIFF_INSERT),u=a(r,t==DIFF_INSERT?d.edit:d.orig),g=a(i,t==DIFF_INSERT?d.orig:d.edit),v=(f-u.top)/(u.bot-u.top),m=g.top-c+v*(g.bot-g.top);if(m>n.top&&(s=n.top/c)<1)m=m*s+n.top*(1-s);else if((l=n.height-n.clientHeight-n.top)<c){var p=i.getScrollInfo(),k=p.height-p.clientHeight-m;k>l&&(s=l/c)<1&&(m=m*s+(p.height-p.clientHeight-l)*(1-s))}}return i.scrollTo(n.left,m),i.state.scrollSetAt=o,i.state.scrollSetBy=e,!0}function a(e,t){var r=t.after;return null==r&&(r=e.lastLine()+1),{top:e.heightAtLine(t.before||0,"local"),bot:e.heightAtLine(r,"local")}}function s(e,t,r){e.lockScroll=t,t&&0!=r&&l(e,DIFF_INSERT)&&d(e),e.lockButton.innerHTML=t?"⇛⇚":"⇛&nbsp;&nbsp;⇚"}function c(t,r,i){for(var o=0;o<r.length;++o){var n=r[o];n instanceof e.TextMarker?n.clear():n.parent&&(t.removeLineClass(n,"background",i.chunk),t.removeLineClass(n,"background",i.start),t.removeLineClass(n,"background",i.end))}r.length=0}function f(e,t,r,i,o){var n=e.getViewport();e.operation(function(){r.from==r.to||n.from-r.to>20||r.from-n.to>20?(c(e,r.marked,o),h(e,t,i,r.marked,n.from,n.to,o),r.from=n.from,r.to=n.to):(n.from<r.from&&(h(e,t,i,r.marked,n.from,r.from,o),r.from=n.from),n.to>r.to&&(h(e,t,i,r.marked,r.to,n.to,o),r.to=n.to))})}function h(e,t,r,i,o,n,l){function a(t,r){for(var a=Math.max(o,t),s=Math.min(n,r),c=a;s>c;++c){var f=e.addLineClass(c,"background",l.chunk);c==t&&e.addLineClass(f,"background",l.start),c==r-1&&e.addLineClass(f,"background",l.end),i.push(f)}t==r&&a==r&&s==r&&(a?i.push(e.addLineClass(a-1,"background",l.end)):i.push(e.addLineClass(a,"background",l.start)))}for(var s=W(0,0),c=W(o,0),f=e.clipPos(W(n-1)),h=r==DIFF_DELETE?l.del:l.insert,d=0,u=0;u<t.length;++u){var g=t[u],v=g[0],m=g[1];if(v==DIFF_EQUAL){var p=s.line+(M(t,u)?0:1);x(s,m);var k=s.line+(D(t,u)?1:0);k>p&&(u&&a(d,p),d=k)}else if(v==r){var C=x(s,m,!0),T=R(c,s),F=B(f,C);V(T,F)||i.push(e.markText(T,F,{className:h})),s=C}}d<=s.line&&a(d,s.line+1)}function d(e){if(e.showDifferences){if(e.svg){N(e.svg);var t=e.gap.offsetWidth;_(e.svg,"width",t,"height",e.gap.offsetHeight)}e.copyButtons&&N(e.copyButtons);for(var r=e.edit.getViewport(),i=e.orig.getViewport(),o=e.edit.getScrollInfo().top,n=e.orig.getScrollInfo().top,l=0;l<e.chunks.length;l++){var a=e.chunks[l];a.editFrom<=r.to&&a.editTo>=r.from&&a.origFrom<=i.to&&a.origTo>=i.from&&k(e,a,n,o,t)}}}function u(e,t){for(var r=0,i=0,o=0;o<t.length;o++){var n=t[o];if(n.editTo>e&&n.editFrom<=e)return null;if(n.editFrom>e)break;r=n.editTo,i=n.origTo}return i+(e-r)}function g(e,t){for(var r=[],i=0;i<e.chunks.length;i++){var o=e.chunks[i];r.push([o.origTo,o.editTo,t?u(o.editTo,t.chunks):null])}if(t)for(var i=0;i<t.chunks.length;i++){for(var o=t.chunks[i],n=0;n<r.length;n++){var l=r[n];if(l[1]==o.editTo){n=-1;break}if(l[1]>o.editTo)break}n>-1&&r.splice(n-1,0,[u(o.editTo,e.chunks),o.editTo,o.origTo])}return r}function v(e,t){if(e.dealigned||t){if(!e.orig.curOp)return e.orig.operation(function(){v(e,t)});e.dealigned=!1;var r=e.mv.left==e?e.mv.right:e.mv.left;r&&(i(r),r.dealigned=!1);for(var o=g(e,r),n=e.mv.aligners,l=0;l<n.length;l++)n[l].clear();n.length=0;var a=[e.orig,e.edit],s=[];r&&a.push(r.orig);for(var l=0;l<a.length;l++)s.push(a[l].getScrollInfo().top);for(var c=0;c<o.length;c++)m(a,o[c],n);for(var l=0;l<a.length;l++)a[l].scrollTo(null,s[l])}}function m(e,t,r){for(var i=0,o=[],n=0;n<e.length;n++)if(null!=t[n]){var l=e[n].heightAtLine(t[n],"local");o[n]=l,i=Math.max(i,l)}for(var n=0;n<e.length;n++)if(null!=t[n]){var a=i-o[n];a>1&&r.push(p(e[n],t[n],a))}}function p(e,t,r){var i=!0;t>e.lastLine()&&(t--,i=!1);var o=document.createElement("div");return o.className="CodeMirror-merge-spacer",o.style.height=r+"px",o.style.minWidth="1px",e.addLineWidget(t,o,{height:r,above:i})}function k(e,t,r,i,o){var n="left"==e.type,l=e.orig.heightAtLine(t.origFrom,"local")-r;if(e.svg){var a=l,s=e.edit.heightAtLine(t.editFrom,"local")-i;if(n){var c=a;a=s,s=c}var f=e.orig.heightAtLine(t.origTo,"local")-r,h=e.edit.heightAtLine(t.editTo,"local")-i;if(n){var c=f;f=h,h=c}var d=" C "+o/2+" "+s+" "+o/2+" "+a+" "+(o+2)+" "+a,u=" C "+o/2+" "+f+" "+o/2+" "+h+" -1 "+h;_(e.svg.appendChild(document.createElementNS(z,"path")),"d","M -1 "+s+d+" L "+(o+2)+" "+f+u+" z","class",e.classes.connect)}if(e.copyButtons){var g=e.copyButtons.appendChild(O("div","left"==e.type?"⇝":"⇜","CodeMirror-merge-copy")),v=e.mv.options.allowEditingOriginals;if(g.title=v?"Push to left":"Revert chunk",g.chunk=t,g.style.top=l+"px",v){var m=e.orig.heightAtLine(t.editFrom,"local")-i,p=e.copyButtons.appendChild(O("div","right"==e.type?"⇝":"⇜","CodeMirror-merge-copy-reverse"));p.title="Push to right",p.chunk={editFrom:t.origFrom,editTo:t.origTo,origFrom:t.editFrom,origTo:t.editTo},p.style.top=m+"px","right"==e.type?p.style.left="2px":p.style.right="2px"}}}function C(e,t,r,i){e.diffOutOfDate||t.replaceRange(r.getRange(W(i.origFrom,0),W(i.origTo,0)),W(i.editFrom,0),W(i.editTo,0))}function T(t){var r=t.lockButton=O("div",null,"CodeMirror-merge-scrolllock");r.title="Toggle locked scrolling";var i=O("div",[r],"CodeMirror-merge-scrolllock-wrap");e.on(r,"click",function(){s(t,!t.lockScroll)});var o=[i];if(t.mv.options.revertButtons!==!1&&(t.copyButtons=O("div",null,"CodeMirror-merge-copybuttons-"+t.type),e.on(t.copyButtons,"click",function(e){var r=e.target||e.srcElement;if(r.chunk)return"CodeMirror-merge-copy-reverse"==r.className?void C(t,t.orig,t.edit,r.chunk):void C(t,t.edit,t.orig,r.chunk)}),o.unshift(t.copyButtons)),"align"!=t.mv.options.connect){var n=document.createElementNS&&document.createElementNS(z,"svg");n&&!n.createSVGRect&&(n=null),t.svg=n,n&&o.push(n)}return t.gap=O("div",o,"CodeMirror-merge-gap")}function F(e){return"string"==typeof e?e:e.getValue()}function w(e,t){var r=Q.diff_main(e,t);Q.diff_cleanupSemantic(r);for(var i=0;i<r.length;++i){var o=r[i];o[1]?i&&r[i-1][0]==o[0]&&(r.splice(i--,1),r[i][1]+=o[1]):r.splice(i--,1)}return r}function y(e){for(var t=[],r=0,i=0,o=W(0,0),n=W(0,0),l=0;l<e.length;++l){var a=e[l],s=a[0];if(s==DIFF_EQUAL){var c=M(e,l)?0:1,f=o.line+c,h=n.line+c;x(o,a[1],null,n);var d=D(e,l)?1:0,u=o.line+d,g=n.line+d;u>f&&(l&&t.push({origFrom:i,origTo:h,editFrom:r,editTo:f}),r=u,i=g)}else x(s==DIFF_INSERT?o:n,a[1])}return(r<=o.line||i<=n.line)&&t.push({origFrom:i,origTo:n.line+1,editFrom:r,editTo:o.line+1}),t}function D(e,t){if(t==e.length-1)return!0;var r=e[t+1][1];return 1==r.length||10!=r.charCodeAt(0)?!1:t==e.length-2?!0:(r=e[t+2][1],r.length>1&&10==r.charCodeAt(0))}function M(e,t){if(0==t)return!0;var r=e[t-1][1];return 10!=r.charCodeAt(r.length-1)?!1:1==t?!0:(r=e[t-2][1],10==r.charCodeAt(r.length-1))}function L(e,t,r){for(var i,o,n,l,a=0;a<e.length;a++){var s=e[a],c=r?s.editFrom:s.origFrom,f=r?s.editTo:s.origTo;null==o&&(c>t?(o=s.editFrom,l=s.origFrom):f>t&&(o=s.editTo,l=s.origTo)),t>=f?(i=s.editTo,n=s.origTo):t>=c&&(i=s.editFrom,n=s.origFrom)}return{edit:{before:i,after:o},orig:{before:n,after:l}}}function I(e,t,r){function i(){n.clear(),e.removeLineClass(t,"wrap","CodeMirror-merge-collapsed-line")}e.addLineClass(t,"wrap","CodeMirror-merge-collapsed-line");var o=document.createElement("span");o.className="CodeMirror-merge-collapsed-widget",o.title="Identical text collapsed. Click to expand.";var n=e.markText(W(t,0),W(r-1),{inclusiveLeft:!0,inclusiveRight:!0,replacedWith:o,clearOnEnter:!0});return o.addEventListener("click",i),{mark:n,clear:i}}function b(e,t){function r(){for(var e=0;e<i.length;e++)i[e].clear()}for(var i=[],o=0;o<t.length;o++){var n=t[o],l=I(n.cm,n.line,n.line+e);i.push(l),l.mark.on("clear",r)}return i[0].mark}function E(e,t,r,i){for(var o=0;o<e.chunks.length;o++)for(var n=e.chunks[o],l=n.editFrom-t;l<n.editTo+t;l++){var a=l+r;a>=0&&a<i.length&&(i[a]=!1)}}function S(e,t){"number"!=typeof t&&(t=2);for(var r=[],i=e.editor(),o=i.firstLine(),n=o,l=i.lastLine();l>=n;n++)r.push(!0);e.left&&E(e.left,t,o,r),e.right&&E(e.right,t,o,r);for(var a=0;a<r.length;a++)if(r[a]){for(var s=a+o,c=1;a<r.length-1&&r[a+1];a++,c++);if(c>t){var f=[{line:s,cm:i}];e.left&&f.push({line:u(s,e.left.chunks),cm:e.left.orig}),e.right&&f.push({line:u(s,e.right.chunks),cm:e.right.orig});var h=b(c,f);e.options.onCollapse&&e.options.onCollapse(e,s,c,h)}}}function O(e,t,r,i){var o=document.createElement(e);if(r&&(o.className=r),i&&(o.style.cssText=i),"string"==typeof t)o.appendChild(document.createTextNode(t));else if(t)for(var n=0;n<t.length;++n)o.appendChild(t[n]);return o}function N(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild)}function _(e){for(var t=1;t<arguments.length;t+=2)e.setAttribute(arguments[t],arguments[t+1])}function A(e,t){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function x(e,t,r,i){for(var o=r?W(e.line,e.ch):e,n=0;;){var l=t.indexOf("\n",n);if(-1==l)break;++o.line,i&&++i.line,n=l+1}return o.ch=(n?0:o.ch)+(t.length-n),i&&(i.ch=(n?0:i.ch)+(t.length-n)),o}function B(e,t){return(e.line-t.line||e.ch-t.ch)<0?e:t}function R(e,t){return(e.line-t.line||e.ch-t.ch)>0?e:t}function V(e,t){return e.line==t.line&&e.ch==t.ch}function H(e,t,r){for(var i=e.length-1;i>=0;i--){var o=e[i],n=(r?o.origTo:o.editTo)-1;if(t>n)return n}}function P(e,t,r){for(var i=0;i<e.length;i++){var o=e[i],n=r?o.origFrom:o.editFrom;if(n>t)return n}}function U(t,r){var o=null,n=t.state.diffViews,l=t.getCursor().line;if(n)for(var a=0;a<n.length;a++){var s=n[a],c=t==s.orig;i(s);var f=0>r?H(s.chunks,l,c):P(s.chunks,l,c);null==f||null!=o&&!(0>r?f>o:o>f)||(o=f)}return null==o?e.Pass:void t.setCursor(o,0)}var W=e.Pos,z="http://www.w3.org/2000/svg";r.prototype={constructor:r,init:function(t,r,i){this.edit=this.mv.edit,(this.edit.state.diffViews||(this.edit.state.diffViews=[])).push(this),this.orig=e(t,A({value:r,readOnly:!this.mv.options.allowEditingOriginals},A(i))),this.orig.state.diffViews=[this],this.diff=w(F(r),F(i.value)),this.chunks=y(this.diff),this.diffOutOfDate=this.dealigned=!1,this.showDifferences=i.showDifferences!==!1,this.forceUpdate=o(this),s(this,!0,!1),n(this)},setShowDifferences:function(e){e=e!==!1,e!=this.showDifferences&&(this.showDifferences=e,this.forceUpdate("full"))}};var j=!1,q=e.MergeView=function(t,i){if(!(this instanceof q))return new q(t,i);this.options=i;var o=i.origLeft,n=null==i.origRight?i.orig:i.origRight,l=null!=o,a=null!=n,s=1+(l?1:0)+(a?1:0),c=[],f=this.left=null,h=this.right=null,u=this;if(l){f=this.left=new r(this,"left");var g=O("div",null,"CodeMirror-merge-pane");c.push(g),c.push(T(f))}var m=O("div",null,"CodeMirror-merge-pane");if(c.push(m),a){h=this.right=new r(this,"right"),c.push(T(h));var p=O("div",null,"CodeMirror-merge-pane");c.push(p)}(a?p:m).className+=" CodeMirror-merge-pane-rightmost",c.push(O("div",null,null,"height: 0; clear: both;"));var k=this.wrap=t.appendChild(O("div",c,"CodeMirror-merge CodeMirror-merge-"+s+"pane"));this.edit=e(m,A(i)),f&&f.init(g,o,i),h&&h.init(p,n,i),i.collapseIdentical&&(j=!0,this.editor().operation(function(){S(u,i.collapseIdentical)}),j=!1),"align"==i.connect&&(this.aligners=[],v(this.left||this.right,!0));var C=function(){f&&d(f),h&&d(h)};e.on(window,"resize",C);var F=setInterval(function(){for(var t=k.parentNode;t&&t!=document.body;t=t.parentNode);t||(clearInterval(F),e.off(window,"resize",C))},5e3)};q.prototype={constuctor:q,editor:function(){return this.edit},rightOriginal:function(){return this.right&&this.right.orig},leftOriginal:function(){return this.left&&this.left.orig},setShowDifferences:function(e){this.right&&this.right.setShowDifferences(e),this.left&&this.left.setShowDifferences(e)},rightChunks:function(){return this.right?(i(this.right),this.right.chunks):void 0},leftChunks:function(){return this.left?(i(this.left),this.left.chunks):void 0}};var Q=new t;e.commands.goNextDiff=function(e){return U(e,1)},e.commands.goPrevDiff=function(e){return U(e,-1)}});
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,f.marked,e.classes),a.from=a.to=f.from=f.to=0),r(e),e.showDifferences&&(c(e.edit,e.diff,a,DIFF_INSERT,e.classes),c(e.orig,e.diff,f,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=f.from=f.to=0),i(r.text.length-1!=r.to.line-r.from.line)}var l,a={from:0,to:0,marked:[]},f={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,c=.5*n.clientHeight,f=n.top+c,h=r.lineAtHeight(f,"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=(f-u.top)/(u.bot-u.top),m=g.top-c+v*(g.bot-g.top);if(m>n.top&&(s=n.top/c)<1)m=m*s+n.top*(1-s);else if((a=n.height-n.clientHeight-n.top)<c){var p=i.getScrollInfo(),k=p.height-p.clientHeight-m;k>a&&(s=a/c)<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 c(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),f(e,t,i,r.marked,n.from,n.to,o),r.from=n.from,r.to=n.to):(n.from<r.from&&(f(e,t,i,r.marked,n.from,r.from,o),r.from=n.from),n.to>r.to&&(f(e,t,i,r.marked,r.to,n.to,o),r.to=n.to))})}function f(e,t,r,i,o,n,l){function a(t,r){for(var a=Math.max(o,t),s=Math.min(n,r),c=a;s>c;++c){var f=e.addLineClass(c,"background",l.chunk);c==t&&e.addLineClass(f,"background",l.start),c==r-1&&e.addLineClass(f,"background",l.end),i.push(f)}t==r&&a==r&&s==r&&(a?i.push(e.addLineClass(a-1,"background",l.end)):i.push(e.addLineClass(a,"background",l.start)))}for(var s=U(0,0),c=U(o,0),f=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(c,s),F=_(f,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 c=0;c<o.length;c++)v(a,o[c],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 c=a;a=s,s=c}var f=e.orig.heightAtLine(t.origTo,"local")-r,h=e.edit.heightAtLine(t.editTo,"local")-i;if(n){var c=f;f=h,h=c}var d=" C "+o/2+" "+s+" "+o/2+" "+a+" "+(o+2)+" "+a,u=" C "+o/2+" "+f+" "+o/2+" "+h+" -1 "+h;N(e.svg.appendChild(document.createElementNS(W,"path")),"d","M -1 "+s+d+" L "+(o+2)+" "+f+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 c=D(e,l)?0:1,f=o.line+c,h=n.line+c;x(o,a[1],null,n);var d=y(e,l)?1:0,u=o.line+d,g=n.line+d;u>f&&(l&&t.push({origFrom:i,origTo:h,editFrom:r,editTo:f}),r=u,i=g)}else x(s==DIFF_INSERT?o:n,a[1])}return(r<=o.line||i<=n.line)&&t.push({origFrom:i,origTo:n.line+1,editFrom:r,editTo:o.line+1}),t}function y(e,t){if(t==e.length-1)return!0;var r=e[t+1][1];return 1==r.length||10!=r.charCodeAt(0)?!1:t==e.length-2?!0:(r=e[t+2][1],r.length>1&&10==r.charCodeAt(0))}function D(e,t){if(0==t)return!0;var r=e[t-1][1];return 10!=r.charCodeAt(r.length-1)?!1:1==t?!0:(r=e[t-2][1],10==r.charCodeAt(r.length-1))}function M(e,t,r){for(var i,o,n,l,a=0;a<e.length;a++){var s=e[a],c=r?s.editFrom:s.origFrom,f=r?s.editTo:s.origTo;null==o&&(c>t?(o=s.editFrom,l=s.origFrom):f>t&&(o=s.editTo,l=s.origTo)),t>=f?(i=s.editTo,n=s.origTo):t>=c&&(i=s.editFrom,n=s.origFrom)}return{edit:{before:i,after:o},orig:{before:n,after:l}}}function 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();l>=n;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,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:d(s,e.left.chunks),cm:e.left.orig}),e.right&&f.push({line:d(s,e.right.chunks),cm:e.right.orig});var h=I(c,f);e.options.onCollapse&&e.options.onCollapse(e,s,c,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(-1==l)break;++o.line,i&&++i.line,n=l+1}return o.ch=(n?0:o.ch)+(t.length-n),i&&(i.ch=(n?0:i.ch)+(t.length-n)),o}function _(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(t>n)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],c=t==s.orig;r(s);var f=0>i?V(s.chunks,l,c):H(s.chunks,l,c);null==f||null!=o&&!(0>i?f>o:o>f)||(o=f)}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),c=[],f=this.left=null,d=this.right=null,u=this;if(l){f=this.left=new t(this,"left");var v=S("div",null,"CodeMirror-merge-pane");c.push(v),c.push(C(f))}var m=S("div",null,"CodeMirror-merge-pane");if(c.push(m),a){d=this.right=new t(this,"right"),c.push(C(d));var p=S("div",null,"CodeMirror-merge-pane");c.push(p)}(a?p:m).className+=" CodeMirror-merge-pane-rightmost",c.push(S("div",null,null,"height: 0; clear: both;"));var k=this.wrap=r.appendChild(S("div",c,"CodeMirror-merge CodeMirror-merge-"+s+"pane"));this.edit=e(m,A(i)),f&&f.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(){f&&h(f),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(){return this.right?(r(this.right),this.right.chunks):void 0},leftChunks:function(){return this.left?(r(this.left),this.left.chunks):void 0}};var Q=new diff_match_patch;e.commands.goNextDiff=function(e){return P(e,1)},e.commands.goPrevDiff=function(e){return P(e,-1)}});
lib/codemirror/lib/codemirror.css CHANGED
@@ -41,19 +41,21 @@
41
 
42
  /* CURSOR */
43
 
44
- .CodeMirror div.CodeMirror-cursor {
45
  border-left: 1px solid black;
 
 
46
  }
47
  /* Shown when moving in bi-directional text */
48
  .CodeMirror div.CodeMirror-secondarycursor {
49
  border-left: 1px solid silver;
50
  }
51
- .CodeMirror.cm-fat-cursor div.CodeMirror-cursor {
52
  width: auto;
53
  border: 0;
54
  background: #7e7;
55
  }
56
- .CodeMirror.cm-fat-cursor div.CodeMirror-cursors {
57
  z-index: 1;
58
  }
59
 
@@ -63,25 +65,26 @@
63
  -webkit-animation: blink 1.06s steps(1) infinite;
64
  -moz-animation: blink 1.06s steps(1) infinite;
65
  animation: blink 1.06s steps(1) infinite;
 
66
  }
67
  @-moz-keyframes blink {
68
- 0% { background: #7e7; }
69
- 50% { background: none; }
70
- 100% { background: #7e7; }
71
  }
72
  @-webkit-keyframes blink {
73
- 0% { background: #7e7; }
74
- 50% { background: none; }
75
- 100% { background: #7e7; }
76
  }
77
  @keyframes blink {
78
- 0% { background: #7e7; }
79
- 50% { background: none; }
80
- 100% { background: #7e7; }
81
  }
82
 
83
  /* Can style cursor different in overwrite (non-insert) mode */
84
- div.CodeMirror-overwrite div.CodeMirror-cursor {}
85
 
86
  .cm-tab { display: inline-block; text-decoration: inherit; }
87
 
@@ -92,6 +95,15 @@ div.CodeMirror-overwrite div.CodeMirror-cursor {}
92
 
93
  /* DEFAULT THEME */
94
 
 
 
 
 
 
 
 
 
 
95
  .cm-s-default .cm-keyword {color: #708;}
96
  .cm-s-default .cm-atom {color: #219;}
97
  .cm-s-default .cm-number {color: #164;}
@@ -111,18 +123,9 @@ div.CodeMirror-overwrite div.CodeMirror-cursor {}
111
  .cm-s-default .cm-bracket {color: #997;}
112
  .cm-s-default .cm-tag {color: #170;}
113
  .cm-s-default .cm-attribute {color: #00c;}
114
- .cm-s-default .cm-header {color: blue;}
115
- .cm-s-default .cm-quote {color: #090;}
116
  .cm-s-default .cm-hr {color: #999;}
117
  .cm-s-default .cm-link {color: #00c;}
118
 
119
- .cm-negative {color: #d44;}
120
- .cm-positive {color: #292;}
121
- .cm-header, .cm-strong {font-weight: bold;}
122
- .cm-em {font-style: italic;}
123
- .cm-link {text-decoration: underline;}
124
- .cm-strikethrough {text-decoration: line-through;}
125
-
126
  .cm-s-default .cm-error {color: #f00;}
127
  .cm-invalidchar {color: #f00;}
128
 
@@ -162,7 +165,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
162
  }
163
 
164
  /* The fake, visible scrollbars. Used to force redraw during scrolling
165
- before actuall scrolling happens, thus preventing shaking and
166
  flickering artifacts. */
167
  .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
168
  position: absolute;
@@ -202,7 +205,13 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
202
  .CodeMirror-gutter-wrapper {
203
  position: absolute;
204
  z-index: 4;
205
- height: 100%;
 
 
 
 
 
 
206
  }
207
  .CodeMirror-gutter-elt {
208
  position: absolute;
@@ -277,19 +286,19 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
277
  overflow: hidden;
278
  visibility: hidden;
279
  }
280
- .CodeMirror-measure pre { position: static; }
281
 
282
- .CodeMirror div.CodeMirror-cursor {
283
- position: absolute;
284
- border-right: none;
285
- width: 0;
286
- }
287
 
288
  div.CodeMirror-cursors {
289
  visibility: hidden;
290
  position: relative;
291
  z-index: 3;
292
  }
 
 
 
 
293
  .CodeMirror-focused div.CodeMirror-cursors {
294
  visibility: visible;
295
  }
@@ -297,8 +306,8 @@ div.CodeMirror-cursors {
297
  .CodeMirror-selected { background: #d9d9d9; }
298
  .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
299
  .CodeMirror-crosshair { cursor: crosshair; }
300
- .CodeMirror ::selection { background: #d7d4f0; }
301
- .CodeMirror ::-moz-selection { background: #d7d4f0; }
302
 
303
  .cm-searching {
304
  background: #ffa;
41
 
42
  /* CURSOR */
43
 
44
+ .CodeMirror-cursor {
45
  border-left: 1px solid black;
46
+ border-right: none;
47
+ width: 0;
48
  }
49
  /* Shown when moving in bi-directional text */
50
  .CodeMirror div.CodeMirror-secondarycursor {
51
  border-left: 1px solid silver;
52
  }
53
+ .cm-fat-cursor .CodeMirror-cursor {
54
  width: auto;
55
  border: 0;
56
  background: #7e7;
57
  }
58
+ .cm-fat-cursor div.CodeMirror-cursors {
59
  z-index: 1;
60
  }
61
 
65
  -webkit-animation: blink 1.06s steps(1) infinite;
66
  -moz-animation: blink 1.06s steps(1) infinite;
67
  animation: blink 1.06s steps(1) infinite;
68
+ background-color: #7e7;
69
  }
70
  @-moz-keyframes blink {
71
+ 0% {}
72
+ 50% { background-color: transparent; }
73
+ 100% {}
74
  }
75
  @-webkit-keyframes blink {
76
+ 0% {}
77
+ 50% { background-color: transparent; }
78
+ 100% {}
79
  }
80
  @keyframes blink {
81
+ 0% {}
82
+ 50% { background-color: transparent; }
83
+ 100% {}
84
  }
85
 
86
  /* Can style cursor different in overwrite (non-insert) mode */
87
+ .CodeMirror-overwrite .CodeMirror-cursor {}
88
 
89
  .cm-tab { display: inline-block; text-decoration: inherit; }
90
 
95
 
96
  /* DEFAULT THEME */
97
 
98
+ .cm-s-default .cm-header {color: blue;}
99
+ .cm-s-default .cm-quote {color: #090;}
100
+ .cm-negative {color: #d44;}
101
+ .cm-positive {color: #292;}
102
+ .cm-header, .cm-strong {font-weight: bold;}
103
+ .cm-em {font-style: italic;}
104
+ .cm-link {text-decoration: underline;}
105
+ .cm-strikethrough {text-decoration: line-through;}
106
+
107
  .cm-s-default .cm-keyword {color: #708;}
108
  .cm-s-default .cm-atom {color: #219;}
109
  .cm-s-default .cm-number {color: #164;}
123
  .cm-s-default .cm-bracket {color: #997;}
124
  .cm-s-default .cm-tag {color: #170;}
125
  .cm-s-default .cm-attribute {color: #00c;}
 
 
126
  .cm-s-default .cm-hr {color: #999;}
127
  .cm-s-default .cm-link {color: #00c;}
128
 
 
 
 
 
 
 
 
129
  .cm-s-default .cm-error {color: #f00;}
130
  .cm-invalidchar {color: #f00;}
131
 
165
  }
166
 
167
  /* The fake, visible scrollbars. Used to force redraw during scrolling
168
+ before actual scrolling happens, thus preventing shaking and
169
  flickering artifacts. */
170
  .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
171
  position: absolute;
205
  .CodeMirror-gutter-wrapper {
206
  position: absolute;
207
  z-index: 4;
208
+ background: none !important;
209
+ border: none !important;
210
+ }
211
+ .CodeMirror-gutter-background {
212
+ position: absolute;
213
+ top: 0; bottom: 0;
214
+ z-index: 4;
215
  }
216
  .CodeMirror-gutter-elt {
217
  position: absolute;
286
  overflow: hidden;
287
  visibility: hidden;
288
  }
 
289
 
290
+ .CodeMirror-cursor { position: absolute; }
291
+ .CodeMirror-measure pre { position: static; }
 
 
 
292
 
293
  div.CodeMirror-cursors {
294
  visibility: hidden;
295
  position: relative;
296
  z-index: 3;
297
  }
298
+ div.CodeMirror-dragcursors {
299
+ visibility: visible;
300
+ }
301
+
302
  .CodeMirror-focused div.CodeMirror-cursors {
303
  visibility: visible;
304
  }
306
  .CodeMirror-selected { background: #d9d9d9; }
307
  .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
308
  .CodeMirror-crosshair { cursor: crosshair; }
309
+ .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
310
+ .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
311
 
312
  .cm-searching {
313
  background: #ffa;
lib/codemirror/lib/codemirror.js CHANGED
@@ -13,7 +13,7 @@
13
  else if (typeof define == "function" && define.amd) // AMD
14
  return define([], mod);
15
  else // Plain browser env
16
- this.CodeMirror = mod();
17
  })(function() {
18
  "use strict";
19
 
@@ -21,27 +21,29 @@
21
 
22
  // Kludges for bugs and behavior differences that can't be feature
23
  // detected are enabled based on userAgent etc sniffing.
 
 
24
 
25
- var gecko = /gecko\/\d/i.test(navigator.userAgent);
26
- var ie_upto10 = /MSIE \d/.test(navigator.userAgent);
27
- var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
28
  var ie = ie_upto10 || ie_11up;
29
  var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
30
- var webkit = /WebKit\//.test(navigator.userAgent);
31
- var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);
32
- var chrome = /Chrome\//.test(navigator.userAgent);
33
- var presto = /Opera\//.test(navigator.userAgent);
34
  var safari = /Apple Computer/.test(navigator.vendor);
35
- var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);
36
- var phantom = /PhantomJS/.test(navigator.userAgent);
37
 
38
- var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
39
  // This is woefully incomplete. Suggestions for alternative methods welcome.
40
- var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent);
41
- var mac = ios || /Mac/.test(navigator.platform);
42
- var windows = /win/i.test(navigator.platform);
43
 
44
- var presto_version = presto && navigator.userAgent.match(/Version\/(\d*\.\d*)/);
45
  if (presto_version) presto_version = Number(presto_version[1]);
46
  if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
47
  // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
@@ -65,7 +67,7 @@
65
  setGuttersForLineNumbers(options);
66
 
67
  var doc = options.value;
68
- if (typeof doc == "string") doc = new Doc(doc, options.mode);
69
  this.doc = doc;
70
 
71
  var input = new CodeMirror.inputStyles[options.inputStyle](this);
@@ -87,6 +89,7 @@
87
  focused: false,
88
  suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
89
  pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
 
90
  draggingText: false,
91
  highlight: new Delayed(), // stores highlight worker timeout
92
  keySeq: null, // Unfinished key sequence
@@ -407,7 +410,7 @@
407
  if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal");
408
  });
409
 
410
- this.checkedOverlay = false;
411
  // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
412
  if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
413
  }
@@ -442,29 +445,43 @@
442
  this.horiz.firstChild.style.width = "0";
443
  }
444
 
445
- if (!this.checkedOverlay && measure.clientHeight > 0) {
446
- if (sWidth == 0) this.overlayHack();
447
- this.checkedOverlay = true;
448
  }
449
 
450
  return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0};
451
  },
452
  setScrollLeft: function(pos) {
453
  if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos;
 
454
  },
455
  setScrollTop: function(pos) {
456
  if (this.vert.scrollTop != pos) this.vert.scrollTop = pos;
 
457
  },
458
- overlayHack: function() {
459
  var w = mac && !mac_geMountainLion ? "12px" : "18px";
460
- this.horiz.style.minHeight = this.vert.style.minWidth = w;
461
- var self = this;
462
- var barMouseDown = function(e) {
463
- if (e_target(e) != self.vert && e_target(e) != self.horiz)
464
- operation(self.cm, onMouseDown)(e);
465
- };
466
- on(this.vert, "mousedown", barMouseDown);
467
- on(this.horiz, "mousedown", barMouseDown);
 
 
 
 
 
 
 
 
 
 
 
 
468
  },
469
  clear: function() {
470
  var parent = this.horiz.parentNode;
@@ -714,7 +731,7 @@
714
  // width and height.
715
  removeChildren(display.cursorDiv);
716
  removeChildren(display.selectionDiv);
717
- display.gutters.style.height = 0;
718
 
719
  if (different) {
720
  display.lastWrapHeight = update.wrapperHeight;
@@ -728,12 +745,9 @@
728
  }
729
 
730
  function postUpdateDisplay(cm, update) {
731
- var force = update.force, viewport = update.viewport;
732
  for (var first = true;; first = false) {
733
- if (first && cm.options.lineWrapping && update.oldDisplayWidth != displayWidth(cm)) {
734
- force = true;
735
- } else {
736
- force = false;
737
  // Clip forced viewport to actual scrollable area.
738
  if (viewport && viewport.top != null)
739
  viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)};
@@ -809,7 +823,7 @@
809
  // given line.
810
  function updateWidgetHeight(line) {
811
  if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
812
- line.widgets[i].height = line.widgets[i].node.offsetHeight;
813
  }
814
 
815
  // Do a bulk-read of the DOM positions and sizes needed to draw the
@@ -958,12 +972,22 @@
958
  lineView.node.removeChild(lineView.gutter);
959
  lineView.gutter = null;
960
  }
 
 
 
 
 
 
 
 
 
 
 
961
  var markers = lineView.line.gutterMarkers;
962
  if (cm.options.lineNumbers || markers) {
963
  var wrap = ensureLineWrapped(lineView);
964
  var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " +
965
- (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) +
966
- "px; width: " + dims.gutterTotalWidth + "px");
967
  cm.display.input.setUneditable(gutterWrap);
968
  wrap.insertBefore(gutterWrap, lineView.text);
969
  if (lineView.line.gutterClass)
@@ -1070,10 +1094,6 @@
1070
  if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
1071
  }
1072
 
1073
- function isReadOnly(cm) {
1074
- return cm.options.readOnly || cm.doc.cantEdit;
1075
- }
1076
-
1077
  // This will be set to an array of strings when copying, so that,
1078
  // when pasting, we know what kind of selections the copied text
1079
  // was made out of.
@@ -1084,13 +1104,19 @@
1084
  cm.display.shift = false;
1085
  if (!sel) sel = doc.sel;
1086
 
1087
- var textLines = splitLines(inserted), multiPaste = null;
 
1088
  // When pasing N lines into N selections, insert one line per selection
1089
- if (cm.state.pasteIncoming && sel.ranges.length > 1) {
1090
- if (lastCopied && lastCopied.join("\n") == inserted)
1091
- multiPaste = sel.ranges.length % lastCopied.length == 0 && map(lastCopied, splitLines);
1092
- else if (textLines.length == sel.ranges.length)
 
 
 
 
1093
  multiPaste = map(textLines, function(l) { return [l]; });
 
1094
  }
1095
 
1096
  // Normal behavior is to insert the new text into every selection
@@ -1100,40 +1126,58 @@
1100
  if (range.empty()) {
1101
  if (deleted && deleted > 0) // Handle deletion
1102
  from = Pos(from.line, from.ch - deleted);
1103
- else if (cm.state.overwrite && !cm.state.pasteIncoming) // Handle overwrite
1104
  to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
1105
  }
1106
  var updateInput = cm.curOp.updateInput;
1107
  var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
1108
- origin: origin || (cm.state.pasteIncoming ? "paste" : cm.state.cutIncoming ? "cut" : "+input")};
1109
  makeChange(cm.doc, changeEvent);
1110
  signalLater(cm, "inputRead", cm, changeEvent);
1111
- // When an 'electric' character is inserted, immediately trigger a reindent
1112
- if (inserted && !cm.state.pasteIncoming && cm.options.electricChars &&
1113
- cm.options.smartIndent && range.head.ch < 100 &&
1114
- (!i || sel.ranges[i - 1].head.line != range.head.line)) {
1115
- var mode = cm.getModeAt(range.head);
1116
- var end = changeEnd(changeEvent);
1117
- var indented = false;
1118
- if (mode.electricChars) {
1119
- for (var j = 0; j < mode.electricChars.length; j++)
1120
- if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
1121
- indented = indentLine(cm, end.line, "smart");
1122
- break;
1123
- }
1124
- } else if (mode.electricInput) {
1125
- if (mode.electricInput.test(getLine(doc, end.line).text.slice(0, end.ch)))
1126
- indented = indentLine(cm, end.line, "smart");
1127
- }
1128
- if (indented) signalLater(cm, "electricInput", cm, end.line);
1129
- }
1130
  }
 
 
 
1131
  ensureCursorVisible(cm);
1132
  cm.curOp.updateInput = updateInput;
1133
  cm.curOp.typing = true;
1134
  cm.state.pasteIncoming = cm.state.cutIncoming = false;
1135
  }
1136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1137
  function copyableRanges(cm) {
1138
  var text = [], ranges = [];
1139
  for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
@@ -1206,21 +1250,9 @@
1206
  input.poll();
1207
  });
1208
 
1209
- on(te, "paste", function() {
1210
- // Workaround for webkit bug https://bugs.webkit.org/show_bug.cgi?id=90206
1211
- // Add a char to the end of textarea before paste occur so that
1212
- // selection doesn't span to the end of textarea.
1213
- if (webkit && !cm.state.fakedLastChar && !(new Date - cm.state.lastMiddleDown < 200)) {
1214
- var start = te.selectionStart, end = te.selectionEnd;
1215
- te.value += "$";
1216
- // The selection end needs to be set before the start, otherwise there
1217
- // can be an intermediate non-empty selection between the two, which
1218
- // can override the middle-click paste buffer on linux and cause the
1219
- // wrong thing to get pasted.
1220
- te.selectionEnd = end;
1221
- te.selectionStart = start;
1222
- cm.state.fakedLastChar = true;
1223
- }
1224
  cm.state.pasteIncoming = true;
1225
  input.fastPoll();
1226
  });
@@ -1253,7 +1285,7 @@
1253
  on(te, "copy", prepareCopyCut);
1254
 
1255
  on(display.scroller, "paste", function(e) {
1256
- if (eventInWidget(display, e)) return;
1257
  cm.state.pasteIncoming = true;
1258
  input.focus();
1259
  });
@@ -1265,6 +1297,7 @@
1265
 
1266
  on(te, "compositionstart", function() {
1267
  var start = cm.getCursor("from");
 
1268
  input.composing = {
1269
  start: start,
1270
  range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
@@ -1384,14 +1417,11 @@
1384
  // possible when it is clear that nothing happened. hasSelection
1385
  // will be the case when there is a lot of text in the textarea,
1386
  // in which case reading its value would be expensive.
1387
- if (!cm.state.focused || (hasSelection(input) && !prevInput) ||
1388
- isReadOnly(cm) || cm.options.disableInput || cm.state.keySeq)
 
1389
  return false;
1390
- // See paste handler for more on the fakedLastChar kludge
1391
- if (cm.state.pasteIncoming && cm.state.fakedLastChar) {
1392
- input.value = input.value.substring(0, input.value.length - 1);
1393
- cm.state.fakedLastChar = false;
1394
- }
1395
  var text = input.value;
1396
  // If nothing changed, bail.
1397
  if (text == prevInput && !cm.somethingSelected()) return false;
@@ -1516,6 +1546,10 @@
1516
  }
1517
  },
1518
 
 
 
 
 
1519
  setUneditable: nothing,
1520
 
1521
  needsContentAttribute: false
@@ -1534,16 +1568,11 @@
1534
  init: function(display) {
1535
  var input = this, cm = input.cm;
1536
  var div = input.div = display.lineDiv;
1537
- div.contentEditable = "true";
1538
  disableBrowserMagic(div);
1539
 
1540
  on(div, "paste", function(e) {
1541
- var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
1542
- if (pasted) {
1543
- e.preventDefault();
1544
- cm.replaceSelection(pasted, null, "paste");
1545
- }
1546
- });
1547
 
1548
  on(div, "compositionstart", function(e) {
1549
  var data = e.data;
@@ -1581,7 +1610,7 @@
1581
 
1582
  on(div, "input", function() {
1583
  if (input.composing) return;
1584
- if (!input.pollContent())
1585
  runInOp(input.cm, function() {regChange(cm);});
1586
  });
1587
 
@@ -1661,8 +1690,13 @@
1661
  try { var rng = range(start.node, start.offset, end.offset, end.node); }
1662
  catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
1663
  if (rng) {
1664
- sel.removeAllRanges();
1665
- sel.addRange(rng);
 
 
 
 
 
1666
  if (old && sel.anchorNode == null) sel.addRange(old);
1667
  else if (gecko) this.startGracePeriod();
1668
  }
@@ -1756,13 +1790,13 @@
1756
  var toIndex = findViewIndex(cm, to.line);
1757
  if (toIndex == display.view.length - 1) {
1758
  var toLine = display.viewTo - 1;
1759
- var toNode = display.view[toIndex].node;
1760
  } else {
1761
  var toLine = lineNo(display.view[toIndex + 1].line) - 1;
1762
  var toNode = display.view[toIndex + 1].node.previousSibling;
1763
  }
1764
 
1765
- var newText = splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
1766
  var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
1767
  while (newText.length > 1 && oldText.length > 1) {
1768
  if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
@@ -1806,17 +1840,24 @@
1806
  this.div.focus();
1807
  },
1808
  applyComposition: function(composing) {
1809
- if (composing.data && composing.data != composing.startData)
 
 
1810
  operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel);
1811
  },
1812
 
1813
  setUneditable: function(node) {
1814
- node.setAttribute("contenteditable", "false");
1815
  },
1816
 
1817
  onKeyPress: function(e) {
1818
  e.preventDefault();
1819
- operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
 
 
 
 
 
1820
  },
1821
 
1822
  onContextMenu: nothing,
@@ -1836,7 +1877,7 @@
1836
  var partPos = getBidiPartAt(order, pos.ch);
1837
  side = partPos % 2 ? "right" : "left";
1838
  }
1839
- var result = nodeAndOffsetInLineMap(info.map, pos.ch, "left");
1840
  result.offset = result.collapse == "right" ? result.end : result.start;
1841
  return result;
1842
  }
@@ -1918,7 +1959,7 @@
1918
  }
1919
 
1920
  function domTextBetween(cm, from, to, fromLine, toLine) {
1921
- var text = "", closing = false;
1922
  function recognizeMarker(id) { return function(marker) { return marker.id == id; }; }
1923
  function walk(node) {
1924
  if (node.nodeType == 1) {
@@ -1932,7 +1973,7 @@
1932
  if (markerID) {
1933
  var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
1934
  if (found.length && (range = found[0].find()))
1935
- text += getBetween(cm.doc, range.from, range.to).join("\n");
1936
  return;
1937
  }
1938
  if (node.getAttribute("contenteditable") == "false") return;
@@ -1944,7 +1985,7 @@
1944
  var val = node.nodeValue;
1945
  if (!val) return;
1946
  if (closing) {
1947
- text += "\n";
1948
  closing = false;
1949
  }
1950
  text += val;
@@ -2116,7 +2157,7 @@
2116
 
2117
  // Give beforeSelectionChange handlers a change to influence a
2118
  // selection update.
2119
- function filterSelectionChange(doc, sel) {
2120
  var obj = {
2121
  ranges: sel.ranges,
2122
  update: function(ranges) {
@@ -2124,7 +2165,8 @@
2124
  for (var i = 0; i < ranges.length; i++)
2125
  this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
2126
  clipPos(doc, ranges[i].head));
2127
- }
 
2128
  };
2129
  signal(doc, "beforeSelectionChange", doc, obj);
2130
  if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
@@ -2150,7 +2192,7 @@
2150
 
2151
  function setSelectionNoUndo(doc, sel, options) {
2152
  if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
2153
- sel = filterSelectionChange(doc, sel);
2154
 
2155
  var bias = options && options.bias ||
2156
  (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
@@ -2184,8 +2226,9 @@
2184
  var out;
2185
  for (var i = 0; i < sel.ranges.length; i++) {
2186
  var range = sel.ranges[i];
2187
- var newAnchor = skipAtomic(doc, range.anchor, bias, mayClear);
2188
- var newHead = skipAtomic(doc, range.head, bias, mayClear);
 
2189
  if (out || newAnchor != range.anchor || newHead != range.head) {
2190
  if (!out) out = sel.ranges.slice(0, i);
2191
  out[i] = new Range(newAnchor, newHead);
@@ -2194,54 +2237,59 @@
2194
  return out ? normalizeSelection(out, sel.primIndex) : sel;
2195
  }
2196
 
2197
- // Ensure a given position is not inside an atomic range.
2198
- function skipAtomic(doc, pos, bias, mayClear) {
2199
- var flipped = false, curPos = pos;
2200
- var dir = bias || 1;
2201
- doc.cantEdit = false;
2202
- search: for (;;) {
2203
- var line = getLine(doc, curPos.line);
2204
- if (line.markedSpans) {
2205
- for (var i = 0; i < line.markedSpans.length; ++i) {
2206
- var sp = line.markedSpans[i], m = sp.marker;
2207
- if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) &&
2208
- (sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) {
2209
- if (mayClear) {
2210
- signal(m, "beforeCursorEnter");
2211
- if (m.explicitlyCleared) {
2212
- if (!line.markedSpans) break;
2213
- else {--i; continue;}
2214
- }
2215
- }
2216
- if (!m.atomic) continue;
2217
- var newPos = m.find(dir < 0 ? -1 : 1);
2218
- if (cmp(newPos, curPos) == 0) {
2219
- newPos.ch += dir;
2220
- if (newPos.ch < 0) {
2221
- if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1));
2222
- else newPos = null;
2223
- } else if (newPos.ch > line.text.length) {
2224
- if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0);
2225
- else newPos = null;
2226
- }
2227
- if (!newPos) {
2228
- if (flipped) {
2229
- // Driven in a corner -- no valid cursor position found at all
2230
- // -- try again *with* clearing, if we didn't already
2231
- if (!mayClear) return skipAtomic(doc, pos, bias, true);
2232
- // Otherwise, turn off editing until further notice, and return the start of the doc
2233
- doc.cantEdit = true;
2234
- return Pos(doc.first, 0);
2235
- }
2236
- flipped = true; newPos = pos; dir = -dir;
2237
- }
2238
- }
2239
- curPos = newPos;
2240
- continue search;
2241
  }
2242
  }
 
 
 
 
 
 
 
 
 
 
 
 
2243
  }
2244
- return curPos;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2245
  }
2246
  }
2247
 
@@ -2261,7 +2309,7 @@
2261
  var range = doc.sel.ranges[i];
2262
  var collapsed = range.empty();
2263
  if (collapsed || cm.options.showCursorWhenSelecting)
2264
- drawSelectionCursor(cm, range, curFragment);
2265
  if (!collapsed)
2266
  drawSelectionRange(cm, range, selFragment);
2267
  }
@@ -2269,8 +2317,8 @@
2269
  }
2270
 
2271
  // Draws a cursor for the given range
2272
- function drawSelectionCursor(cm, range, output) {
2273
- var pos = cursorCoords(cm, range.head, "div", null, null, !cm.options.singleCursorHeightPerLine);
2274
 
2275
  var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
2276
  cursor.style.left = pos.left + "px";
@@ -2394,8 +2442,8 @@
2394
 
2395
  doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {
2396
  if (doc.frontier >= cm.display.viewFrom) { // Visible
2397
- var oldStyles = line.styles;
2398
- var highlighted = highlightLine(cm, line, state, true);
2399
  line.styles = highlighted.styles;
2400
  var oldCls = line.styleClasses, newCls = highlighted.classes;
2401
  if (newCls) line.styleClasses = newCls;
@@ -2404,9 +2452,10 @@
2404
  oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
2405
  for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
2406
  if (ischange) changedLines.push(doc.frontier);
2407
- line.stateAfter = copyState(doc.mode, state);
2408
  } else {
2409
- processLine(cm, line.text, state);
 
2410
  line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
2411
  }
2412
  ++doc.frontier;
@@ -2551,10 +2600,12 @@
2551
  function prepareMeasureForLine(cm, line) {
2552
  var lineN = lineNo(line);
2553
  var view = findViewForLine(cm, lineN);
2554
- if (view && !view.text)
2555
  view = null;
2556
- else if (view && view.changes)
2557
  updateLineForChanges(cm, view, lineN, getDimensions(cm));
 
 
2558
  if (!view)
2559
  view = updateExternalMeasurement(cm, line);
2560
 
@@ -2967,12 +3018,12 @@
2967
  var callbacks = group.delayedCallbacks, i = 0;
2968
  do {
2969
  for (; i < callbacks.length; i++)
2970
- callbacks[i]();
2971
  for (var j = 0; j < group.ops.length; j++) {
2972
  var op = group.ops[j];
2973
  if (op.cursorActivityHandlers)
2974
  while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
2975
- op.cursorActivityHandlers[op.cursorActivityCalled++](op.cm);
2976
  }
2977
  } while (i < callbacks.length);
2978
  }
@@ -3066,7 +3117,8 @@
3066
 
3067
  if (cm.state.focused && op.updateInput)
3068
  cm.display.input.reset(op.typing);
3069
- if (op.focus && op.focus == activeElt()) ensureFocus(op.cm);
 
3070
  }
3071
 
3072
  function endOperation_finish(op) {
@@ -3432,9 +3484,11 @@
3432
  on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
3433
 
3434
  d.dragFunctions = {
3435
- simple: function(e) {if (!signalDOMEvent(cm, e)) e_stop(e);},
 
3436
  start: function(e){onDragStart(cm, e);},
3437
- drop: operation(cm, onDrop)
 
3438
  };
3439
 
3440
  var inp = d.input.getField();
@@ -3451,8 +3505,9 @@
3451
  var funcs = cm.display.dragFunctions;
3452
  var toggle = value ? on : off;
3453
  toggle(cm.display.scroller, "dragstart", funcs.start);
3454
- toggle(cm.display.scroller, "dragenter", funcs.simple);
3455
- toggle(cm.display.scroller, "dragover", funcs.simple);
 
3456
  toggle(cm.display.scroller, "drop", funcs.drop);
3457
  }
3458
  }
@@ -3525,7 +3580,10 @@
3525
 
3526
  switch (e_button(e)) {
3527
  case 1:
3528
- if (start)
 
 
 
3529
  leftButtonDown(cm, e, start);
3530
  else if (e_target(e) == display.scroller)
3531
  e_preventDefault(e);
@@ -3560,9 +3618,10 @@
3560
  }
3561
 
3562
  var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained;
3563
- if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) &&
3564
  type == "single" && (contained = sel.contains(start)) > -1 &&
3565
- !sel.ranges[contained].empty())
 
3566
  leftButtonStartDrag(cm, e, start, modifier);
3567
  else
3568
  leftButtonSelect(cm, e, start, type, modifier);
@@ -3644,7 +3703,8 @@
3644
  setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
3645
  {scroll: false, origin: "*mouse"});
3646
  } else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single" && !e.shiftKey) {
3647
- setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0));
 
3648
  startSel = doc.sel;
3649
  } else {
3650
  replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
@@ -3722,6 +3782,7 @@
3722
  }
3723
 
3724
  function done(e) {
 
3725
  counter = Infinity;
3726
  e_preventDefault(e);
3727
  display.input.focus();
@@ -3735,13 +3796,14 @@
3735
  else extend(e);
3736
  });
3737
  var up = operation(cm, done);
 
3738
  on(document, "mousemove", move);
3739
  on(document, "mouseup", up);
3740
  }
3741
 
3742
  // Determines whether an event happened in the gutter, and fires the
3743
  // handlers for the corresponding event.
3744
- function gutterEvent(cm, e, type, prevent, signalfn) {
3745
  try { var mX = e.clientX, mY = e.clientY; }
3746
  catch(e) { return false; }
3747
  if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;
@@ -3758,14 +3820,14 @@
3758
  if (g && g.getBoundingClientRect().right >= mX) {
3759
  var line = lineAtHeight(cm.doc, mY);
3760
  var gutter = cm.options.gutters[i];
3761
- signalfn(cm, type, cm, line, gutter, e);
3762
  return e_defaultPrevented(e);
3763
  }
3764
  }
3765
  }
3766
 
3767
  function clickInGutter(cm, e) {
3768
- return gutterEvent(cm, e, "gutterClick", true, signalLater);
3769
  }
3770
 
3771
  // Kludge to work around strange IE behavior where it'll sometimes
@@ -3774,23 +3836,32 @@
3774
 
3775
  function onDrop(e) {
3776
  var cm = this;
 
3777
  if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
3778
  return;
3779
  e_preventDefault(e);
3780
  if (ie) lastDrop = +new Date;
3781
  var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
3782
- if (!pos || isReadOnly(cm)) return;
3783
  // Might be a file drop, in which case we simply extract the text
3784
  // and insert it.
3785
  if (files && files.length && window.FileReader && window.File) {
3786
  var n = files.length, text = Array(n), read = 0;
3787
  var loadFile = function(file, i) {
 
 
 
 
3788
  var reader = new FileReader;
3789
  reader.onload = operation(cm, function() {
3790
- text[i] = reader.result;
 
 
3791
  if (++read == n) {
3792
  pos = clipPos(cm.doc, pos);
3793
- var change = {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"};
 
 
3794
  makeChange(cm.doc, change);
3795
  setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
3796
  }
@@ -3844,6 +3915,25 @@
3844
  }
3845
  }
3846
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3847
  // SCROLL EVENTS
3848
 
3849
  // Sync the scrollable area and scrollbars, ensure the viewport
@@ -3908,8 +3998,9 @@
3908
 
3909
  var display = cm.display, scroll = display.scroller;
3910
  // Quit if there's nothing to scroll here
3911
- if (!(dx && scroll.scrollWidth > scroll.clientWidth ||
3912
- dy && scroll.scrollHeight > scroll.clientHeight)) return;
 
3913
 
3914
  // Webkit browsers on OS X abort momentum scrolls when the target
3915
  // of the scroll event is removed from the scrollable element.
@@ -3933,10 +4024,15 @@
3933
  // scrolling entirely here. It'll be slightly off from native, but
3934
  // better than glitching out.
3935
  if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
3936
- if (dy)
3937
  setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight)));
3938
  setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)));
3939
- e_preventDefault(e);
 
 
 
 
 
3940
  display.wheelStartX = null; // Abort measurement, if in progress
3941
  return;
3942
  }
@@ -3985,7 +4081,7 @@
3985
  cm.display.input.ensurePolled();
3986
  var prevShift = cm.display.shift, done = false;
3987
  try {
3988
- if (isReadOnly(cm)) cm.state.suppressEdits = true;
3989
  if (dropShift) cm.display.shift = false;
3990
  done = bound(cm) != Pass;
3991
  } finally {
@@ -4164,12 +4260,13 @@
4164
  // right-click take effect on it.
4165
  function onContextMenu(cm, e) {
4166
  if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return;
 
4167
  cm.display.input.onContextMenu(e);
4168
  }
4169
 
4170
  function contextMenuInGutter(cm, e) {
4171
  if (!hasHandler(cm, "gutterContextMenu")) return false;
4172
- return gutterEvent(cm, e, "gutterContextMenu", false, signal);
4173
  }
4174
 
4175
  // UPDATING
@@ -4473,7 +4570,7 @@
4473
  function replaceRange(doc, code, from, to, origin) {
4474
  if (!to) to = from;
4475
  if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; }
4476
- if (typeof code == "string") code = splitLines(code);
4477
  makeChange(doc, {from: from, to: to, text: code, origin: origin});
4478
  }
4479
 
@@ -4757,7 +4854,7 @@
4757
  if (dir > 0 && !moveOnce(!first)) break;
4758
  }
4759
  }
4760
- var result = skipAtomic(doc, Pos(line, ch), origDir, true);
4761
  if (!possible) result.hitSide = true;
4762
  return result;
4763
  }
@@ -5050,9 +5147,11 @@
5050
 
5051
  execCommand: function(cmd) {
5052
  if (commands.hasOwnProperty(cmd))
5053
- return commands[cmd](this);
5054
  },
5055
 
 
 
5056
  findPosH: function(from, amount, unit, visually) {
5057
  var dir = 1;
5058
  if (amount < 0) { dir = -1; amount = -amount; }
@@ -5143,6 +5242,7 @@
5143
  signal(this, "overwriteToggle", this, this.state.overwrite);
5144
  },
5145
  hasFocus: function() { return this.display.input.getField() == activeElt(); },
 
5146
 
5147
  scrollTo: methodOp(function(x, y) {
5148
  if (x != null || y != null) resolveScrollToPos(this);
@@ -5266,6 +5366,22 @@
5266
  clearCaches(cm);
5267
  regChange(cm);
5268
  }, true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5269
  option("specialChars", /[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, function(cm, val, old) {
5270
  cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
5271
  if (old != CodeMirror.Init) cm.refresh();
@@ -5324,11 +5440,12 @@
5324
  cm.display.disabled = true;
5325
  } else {
5326
  cm.display.disabled = false;
5327
- if (!val) cm.display.input.reset();
5328
  }
 
5329
  });
5330
  option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true);
5331
  option("dragDrop", true, dragDropChanged);
 
5332
 
5333
  option("cursorBlinkRate", 530);
5334
  option("cursorScrollMargin", 0);
@@ -5616,7 +5733,8 @@
5616
  } else if (cur.line > cm.doc.first) {
5617
  var prev = getLine(cm.doc, cur.line - 1).text;
5618
  if (prev)
5619
- cm.replaceRange(line.charAt(0) + "\n" + prev.charAt(prev.length - 1),
 
5620
  Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose");
5621
  }
5622
  }
@@ -5630,10 +5748,10 @@
5630
  var len = cm.listSelections().length;
5631
  for (var i = 0; i < len; i++) {
5632
  var range = cm.listSelections()[i];
5633
- cm.replaceRange("\n", range.anchor, range.head, "+input");
5634
  cm.indentLine(range.from().line + 1, null, true);
5635
- ensureCursorVisible(cm);
5636
  }
 
5637
  });
5638
  },
5639
  toggleOverwrite: function(cm) {cm.toggleOverwrite();}
@@ -5720,7 +5838,7 @@
5720
  for (var i = 0; i < keys.length; i++) {
5721
  var val, name;
5722
  if (i == keys.length - 1) {
5723
- name = keyname;
5724
  val = value;
5725
  } else {
5726
  name = keys.slice(0, i + 1).join(" ");
@@ -6561,7 +6679,7 @@
6561
  parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;";
6562
  removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle));
6563
  }
6564
- return widget.height = widget.node.offsetHeight;
6565
  }
6566
 
6567
  function addLineWidget(doc, handle, node, options) {
@@ -6750,7 +6868,9 @@
6750
 
6751
  function getLineStyles(cm, line, updateFrontier) {
6752
  if (!line.styles || line.styles[0] != cm.state.modeGen) {
6753
- var result = highlightLine(cm, line, line.stateAfter = getStateBefore(cm, lineNo(line)));
 
 
6754
  line.styles = result.styles;
6755
  if (result.classes) line.styleClasses = result.classes;
6756
  else if (line.styleClasses) line.styleClasses = null;
@@ -6767,7 +6887,7 @@
6767
  var stream = new StringStream(text, cm.options.tabSize);
6768
  stream.start = stream.pos = startAt || 0;
6769
  if (text == "") callBlankLine(mode, state);
6770
- while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) {
6771
  readToken(mode, stream, state);
6772
  stream.start = stream.pos;
6773
  }
@@ -6794,7 +6914,7 @@
6794
  // is needed on Webkit to be able to get line-level bounding
6795
  // rectangles for it (in measureChar).
6796
  var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
6797
- var builder = {pre: elt("pre", [content]), content: content,
6798
  col: 0, pos: 0, cm: cm,
6799
  splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")};
6800
  lineView.measure = {};
@@ -6884,6 +7004,10 @@
6884
  txt.setAttribute("role", "presentation");
6885
  txt.setAttribute("cm-text", "\t");
6886
  builder.col += tabWidth;
 
 
 
 
6887
  } else {
6888
  var txt = builder.cm.options.specialCharPlaceholder(m[0]);
6889
  txt.setAttribute("cm-text", m[0]);
@@ -6965,7 +7089,7 @@
6965
  if (nextChange == pos) { // Update current marker set
6966
  spanStyle = spanEndStyle = spanStartStyle = title = css = "";
6967
  collapsed = null; nextChange = Infinity;
6968
- var foundBookmarks = [];
6969
  for (var j = 0; j < spans.length; ++j) {
6970
  var sp = spans[j], m = sp.marker;
6971
  if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
@@ -6976,9 +7100,9 @@
6976
  spanEndStyle = "";
6977
  }
6978
  if (m.className) spanStyle += " " + m.className;
6979
- if (m.css) css = m.css;
6980
  if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
6981
- if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle;
6982
  if (m.title && !title) title = m.title;
6983
  if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
6984
  collapsed = sp;
@@ -6986,6 +7110,9 @@
6986
  nextChange = sp.from;
6987
  }
6988
  }
 
 
 
6989
  if (collapsed && (collapsed.from || 0) == pos) {
6990
  buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
6991
  collapsed.marker, collapsed.from == null);
@@ -7229,8 +7356,8 @@
7229
  };
7230
 
7231
  var nextDocId = 0;
7232
- var Doc = CodeMirror.Doc = function(text, mode, firstLine) {
7233
- if (!(this instanceof Doc)) return new Doc(text, mode, firstLine);
7234
  if (firstLine == null) firstLine = 0;
7235
 
7236
  BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
@@ -7244,8 +7371,10 @@
7244
  this.history = new History(null);
7245
  this.id = ++nextDocId;
7246
  this.modeOption = mode;
 
 
7247
 
7248
- if (typeof text == "string") text = splitLines(text);
7249
  updateDoc(this, {from: start, to: start, text: text});
7250
  setSelection(this, simpleSelection(start), sel_dontScroll);
7251
  };
@@ -7275,12 +7404,12 @@
7275
  getValue: function(lineSep) {
7276
  var lines = getLines(this, this.first, this.first + this.size);
7277
  if (lineSep === false) return lines;
7278
- return lines.join(lineSep || "\n");
7279
  },
7280
  setValue: docMethodOp(function(code) {
7281
  var top = Pos(this.first, 0), last = this.first + this.size - 1;
7282
  makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
7283
- text: splitLines(code), origin: "setValue", full: true}, true);
7284
  setSelection(this, simpleSelection(top));
7285
  }),
7286
  replaceRange: function(code, from, to, origin) {
@@ -7291,7 +7420,7 @@
7291
  getRange: function(from, to, lineSep) {
7292
  var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
7293
  if (lineSep === false) return lines;
7294
- return lines.join(lineSep || "\n");
7295
  },
7296
 
7297
  getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;},
@@ -7331,10 +7460,11 @@
7331
  extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
7332
  }),
7333
  extendSelections: docMethodOp(function(heads, options) {
7334
- extendSelections(this, clipPosArray(this, heads, options));
7335
  }),
7336
  extendSelectionsBy: docMethodOp(function(f, options) {
7337
- extendSelections(this, map(this.sel.ranges, f), options);
 
7338
  }),
7339
  setSelections: docMethodOp(function(ranges, primary, options) {
7340
  if (!ranges.length) return;
@@ -7357,13 +7487,13 @@
7357
  lines = lines ? lines.concat(sel) : sel;
7358
  }
7359
  if (lineSep === false) return lines;
7360
- else return lines.join(lineSep || "\n");
7361
  },
7362
  getSelections: function(lineSep) {
7363
  var parts = [], ranges = this.sel.ranges;
7364
  for (var i = 0; i < ranges.length; i++) {
7365
  var sel = getBetween(this, ranges[i].from(), ranges[i].to());
7366
- if (lineSep !== false) sel = sel.join(lineSep || "\n");
7367
  parts[i] = sel;
7368
  }
7369
  return parts;
@@ -7378,7 +7508,7 @@
7378
  var changes = [], sel = this.sel;
7379
  for (var i = 0; i < sel.ranges.length; i++) {
7380
  var range = sel.ranges[i];
7381
- changes[i] = {from: range.from(), to: range.to(), text: splitLines(code[i]), origin: origin};
7382
  }
7383
  var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
7384
  for (var i = changes.length - 1; i >= 0; i--)
@@ -7459,7 +7589,7 @@
7459
  removeLineWidget: function(widget) { widget.clear(); },
7460
 
7461
  markText: function(from, to, options) {
7462
- return markText(this, clipPos(this, from), clipPos(this, to), options, "range");
7463
  },
7464
  setBookmark: function(pos, options) {
7465
  var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
@@ -7528,7 +7658,8 @@
7528
  },
7529
 
7530
  copy: function(copyHistory) {
7531
- var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first);
 
7532
  doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
7533
  doc.sel = this.sel;
7534
  doc.extend = false;
@@ -7544,7 +7675,7 @@
7544
  var from = this.first, to = this.first + this.size;
7545
  if (options.from != null && options.from > from) from = options.from;
7546
  if (options.to != null && options.to < to) to = options.to;
7547
- var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from);
7548
  if (options.sharedHist) copy.history = this.history;
7549
  (this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
7550
  copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
@@ -7573,14 +7704,20 @@
7573
  iterLinkedDocs: function(f) {linkedDocs(this, f);},
7574
 
7575
  getMode: function() {return this.mode;},
7576
- getEditor: function() {return this.cm;}
 
 
 
 
 
 
7577
  });
7578
 
7579
  // Public alias.
7580
  Doc.prototype.eachLine = Doc.prototype.iter;
7581
 
7582
  // Set up methods on CodeMirror's prototype to redirect to the editor's document.
7583
- var dontDelegate = "iter insert remove copy getEditor".split(" ");
7584
  for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
7585
  CodeMirror.prototype[prop] = (function(method) {
7586
  return function() {return method.apply(this.doc, arguments);};
@@ -8013,24 +8150,30 @@
8013
  }
8014
  };
8015
 
 
 
 
 
 
 
 
8016
  var off = CodeMirror.off = function(emitter, type, f) {
8017
  if (emitter.removeEventListener)
8018
  emitter.removeEventListener(type, f, false);
8019
  else if (emitter.detachEvent)
8020
  emitter.detachEvent("on" + type, f);
8021
  else {
8022
- var arr = emitter._handlers && emitter._handlers[type];
8023
- if (!arr) return;
8024
- for (var i = 0; i < arr.length; ++i)
8025
- if (arr[i] == f) { arr.splice(i, 1); break; }
8026
  }
8027
  };
8028
 
8029
  var signal = CodeMirror.signal = function(emitter, type /*, values...*/) {
8030
- var arr = emitter._handlers && emitter._handlers[type];
8031
- if (!arr) return;
8032
  var args = Array.prototype.slice.call(arguments, 2);
8033
- for (var i = 0; i < arr.length; ++i) arr[i].apply(null, args);
8034
  };
8035
 
8036
  var orphanDelayedCallbacks = null;
@@ -8043,8 +8186,8 @@
8043
  // them to be executed when the last operation ends, or, if no
8044
  // operation is active, when a timeout fires.
8045
  function signalLater(emitter, type /*, values...*/) {
8046
- var arr = emitter._handlers && emitter._handlers[type];
8047
- if (!arr) return;
8048
  var args = Array.prototype.slice.call(arguments, 2), list;
8049
  if (operationGroup) {
8050
  list = operationGroup.delayedCallbacks;
@@ -8084,8 +8227,7 @@
8084
  }
8085
 
8086
  function hasHandler(emitter, type) {
8087
- var arr = emitter._handlers && emitter._handlers[type];
8088
- return arr && arr.length > 0;
8089
  }
8090
 
8091
  // Add on and off methods to a constructor's prototype, to make
@@ -8132,7 +8274,7 @@
8132
 
8133
  // The inverse of countColumn -- find the offset that corresponds to
8134
  // a particular column.
8135
- function findColumn(string, goal, tabSize) {
8136
  for (var pos = 0, col = 0;;) {
8137
  var nextTab = string.indexOf("\t", pos);
8138
  if (nextTab == -1) nextTab = string.length;
@@ -8272,7 +8414,12 @@
8272
  } while (child = child.parentNode);
8273
  };
8274
 
8275
- function activeElt() { return document.activeElement; }
 
 
 
 
 
8276
  // Older versions of IE throws unspecified error when touching
8277
  // document.activeElement in some cases (during loading, in iframe)
8278
  if (ie && ie_version < 11) activeElt = function() {
@@ -8374,7 +8521,7 @@
8374
 
8375
  // See if "".split is the broken IE version, if so, provide an
8376
  // alternative way to split lines.
8377
- var splitLines = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) {
8378
  var pos = 0, result = [], l = string.length;
8379
  while (pos <= l) {
8380
  var nl = string.indexOf("\n", pos);
@@ -8420,14 +8567,16 @@
8420
 
8421
  // KEY NAMES
8422
 
8423
- var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
8424
- 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
8425
- 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
8426
- 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 107: "=", 109: "-", 127: "Delete",
8427
- 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
8428
- 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
8429
- 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"};
8430
- CodeMirror.keyNames = keyNames;
 
 
8431
  (function() {
8432
  // Number keys
8433
  for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i);
@@ -8732,7 +8881,7 @@
8732
 
8733
  // THE END
8734
 
8735
- CodeMirror.version = "5.2.0";
8736
 
8737
  return CodeMirror;
8738
  });
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