diff --git a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb index f30ee2236..73924c835 100644 --- a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb +++ b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb @@ -9,7 +9,9 @@ module RailsKindeditor output << text_area_tag(name, content, input_html) output << javascript_tag(js_replace(id, options.merge(window_onload: 'true', :autoHeightMode=>true, - afterCreate: 'eval(function(){enablePasteImg(self);this.loadPlugin("autoheight")})' + afterCreate: 'eval(function(){enablePasteImg(self);this.loadPlugin("autoheight");$(this.toolbar.div).hide();})', + afterFocus:'eval(function(){$(this.toolbar.div).show(); })', + afterBlur:'eval(function(){if(this.edit.html().trim() == "" ){$(this.toolbar.div).hide();}})' ))) end @@ -21,7 +23,9 @@ module RailsKindeditor output_buffer << build_text_area_tag(name, method, self, options, input_html) output_buffer << javascript_tag(js_replace(input_html['id'],options.merge(window_onload: 'true', :autoHeightMode=>true, - afterCreate: 'eval(function(){enablePasteImg(self);this.loadPlugin("autoheight")})' + afterCreate: 'eval(function(){enablePasteImg(self);this.loadPlugin("autoheight");$(this.toolbar.div).hide();})', + afterFocus:' eval(function(){$(this.toolbar.div).show(); })', + afterBlur:'eval(function(){if(this.edit.html().trim() == ""){$(this.toolbar.div).hide();}})' ))) end diff --git a/public/assets/kindeditor/kindeditor.js b/public/assets/kindeditor/kindeditor.js index 448585376..3ad625604 100644 --- a/public/assets/kindeditor/kindeditor.js +++ b/public/assets/kindeditor/kindeditor.js @@ -3931,7 +3931,9 @@ _extend(KToolbar, KWidget, { pdiv = $("#define",container); }else if(!$("#full",container).is(':hidden')){ pdiv = $("#full",container); - } + }else{ //都隐藏的情况下 + pdiv = $("#define",container); + } return (this._itemMap[name] = K('span.ke-icon-' + name, pdiv).parent()); }, select : function(name) { @@ -4728,13 +4730,19 @@ function _bindTabEvent() { function _bindFocusEvent() { var self = this; K(self.edit.textarea[0], self.edit.win).focus(function(e) { - if (self.afterFocus) { + if(typeof self.afterFocus == 'string'){ + self.afterFocus = eval(self.afterFocus); + } + if ( typeof self.afterFocus == 'function') { self.afterFocus.call(self, e); } }).blur(function(e) { - if (self.afterBlur) { - self.afterBlur.call(self, e); - } + if(typeof self.afterBlur == 'string'){ + self.afterBlur = eval(self.afterBlur); + } + if ( typeof self.afterBlur == 'function') { + self.afterBlur.call(self, e); + } }); } function _removeBookmarkTag(html) {