mirror of
https://github.com/serghey-rodin/vesta.git
synced 2024-12-25 21:41:13 -08:00
1 line
3.1 KiB
JavaScript
1 line
3.1 KiB
JavaScript
(function(){var e={}.hasOwnProperty,t=function(t,n){function i(){this.constructor=t}for(var r in n)e.call(n,r)&&(t[r]=n[r]);return i.prototype=n.prototype,t.prototype=new i,t.__super__=n.prototype,t};window.jQueryAce={initialize:function(e,t){var n;return n=function(){switch(!0){case $(e).is("textarea"):return jQueryAce.TextareaEditor;default:return jQueryAce.BaseEditor}}(),new n(e,t)},defaults:{theme:null,lang:null,mode:null,width:null,height:null},version:"1.0.3",require:function(){switch(!0){case typeof ace.require=="function":return ace.require.apply(null,arguments);case typeof window.require=="function":return window.require.apply(null,arguments);default:throw"Can't find 'require' function"}}},jQueryAce.BaseEditor=function(){function e(e,t){t==null&&(t={}),this.element=$(e),this.options=$.extend({},jQueryAce.defaults,t)}return e.prototype.create=function(){return this.editor=new jQueryAce.AceDecorator(ace.edit(this.element)),this.update()},e.prototype.update=function(e){var t;e!=null&&(this.options=$.extend({},this.options,e)),this.options.theme!=null&&this.editor.theme(this.options.theme),t=this.options.lang||this.options.mode;if(t!=null)return this.editor.lang(t)},e.prototype.destroy=function(){return this.element.data("ace",null),this.editor.destroy(),this.element.empty()},e}(),jQueryAce.TextareaEditor=function(e){function n(){return n.__super__.constructor.apply(this,arguments)}return t(n,e),n.prototype.show=function(){var e;return(e=this.container)!=null&&e.show(),this.element.hide()},n.prototype.hide=function(){var e;return(e=this.container)!=null&&e.hide(),this.element.show()},n.prototype.create=function(){var e=this;return this.container=this.createAceContainer(),this.editor=new jQueryAce.AceDecorator(ace.edit(this.container.get(0))),this.update(),this.editor.value(this.element.val()),this.editor.ace.on("change",function(t){return e.element.val(e.editor.value())}),this.show()},n.prototype.destroy=function(){return n.__super__.destroy.call(this),this.hide(),this.container.remove()},n.prototype.createAceContainer=function(){return this.buildAceContainer().insertAfter(this.element)},n.prototype.buildAceContainer=function(){return $("<div></div>").css({display:"none",position:"relative",width:this.options.width||this.element.width(),height:this.options.height||this.element.height()})},n}(jQueryAce.BaseEditor),jQueryAce.AceDecorator=function(){function e(e){this.ace=e}return e.prototype.theme=function(e){return this.ace.setTheme("ace/theme/"+e)},e.prototype.lang=function(e){var t;return t=jQueryAce.require("ace/mode/"+e).Mode,this.session().setMode(new t)},e.prototype.mode=function(e){return this.lang(e)},e.prototype.session=function(){return this.ace.getSession()},e.prototype.destroy=function(){return this.ace.destroy()},e.prototype.value=function(e){return e!=null?this.ace.insert(e):this.ace.getValue()},e}(),function(e){return e.ace=function(t,n){return e(t).ace(n)},e.fn.ace=function(t){return this.each(function(){var n;return n=e(this).data("ace"),n!=null?n.update(t):(n=jQueryAce.initialize(this,t),n.create(),e(this).data("ace",n))})}}(jQuery)}).call(this); |