From e6bb599a6c3a030fbd41256c49a18b6af51013bb Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 9 Oct 2015 11:34:39 +0800 Subject: [PATCH 1/5] =?UTF-8?q?TAG=E6=89=B9=E9=87=8F=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/tags_controller.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 6b03cff1e..c08f8a3e6 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -244,13 +244,16 @@ class TagsController < ApplicationController @taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type) unless @taggable_id.blank? @obj = get_object(@taggable_id,params[:taggableType]) unless @taggable_id.blank? if @taggable_id.blank? #如果没有传tag_id,那么直接更新tag_name就好了。但是要防止 重命名后的tag存在。 - #看重命名后的tag是否存在。如果存在的话,只需要更改taggings里边的id, - if @rename_tag - @taggings = ActsAsTaggableOn::Tagging.where(" `taggings`.`tag_id` = #{ @tag_id} AND `taggings`.`taggable_type` = 'Attachment' ")#find_by_tag_id_and_taggable_type(@tag_id,@taggable_type) - @taggings.each { |t| t.update_attributes({:tag_id=> @rename_tag.id}) if t.tag_id != @rename_tag.id } - ActsAsTaggableOn::Tag.find(@tag_id).update_attributes(:name=>@rename_tag_name)#并且将该tag改名 - else #如果不存在,那么就直接更新该tag名称为新的名称 - (ActsAsTaggableOn::Tag.find_by_name(@tag_name)).update_attributes(:name=>@rename_tag_name) + if @course_id + course = Course.find @course_id + course.attachments.each do |attachment| + taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,attachment.id,attachment.class) + if taggings + taggings.delete + attachment.tag_list.add(@rename_tag_name.split(",")) + attachment.save + end + end end else if(@rename_tag.nil?) #这次命名的是新的tag From 829e94c56318b27f1d4b19980264ade17f57a3fd Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 9 Oct 2015 14:02:02 +0800 Subject: [PATCH 2/5] =?UTF-8?q?enter=E5=8F=AF=E4=BF=AE=E6=94=B9tag=20name?= =?UTF-8?q?=E5=B9=B6=E4=B8=94=E5=8F=AA=E4=BF=AE=E6=94=B9=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/tags_controller.rb | 14 +++--- app/views/files/index.html.erb | 77 ++++++++++++++++++++---------- 2 files changed, 60 insertions(+), 31 deletions(-) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index c08f8a3e6..cb61177f5 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -246,12 +246,14 @@ class TagsController < ApplicationController if @taggable_id.blank? #如果没有传tag_id,那么直接更新tag_name就好了。但是要防止 重命名后的tag存在。 if @course_id course = Course.find @course_id - course.attachments.each do |attachment| - taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,attachment.id,attachment.class) - if taggings - taggings.delete - attachment.tag_list.add(@rename_tag_name.split(",")) - attachment.save + if course + course.attachments.each do |attachment| + taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,attachment.id,attachment.class) + if taggings + taggings.delete + attachment.tag_list.add(@rename_tag_name.split(",")) + attachment.save + end end end end diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 6b1fdb2e9..656baaf63 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -246,36 +246,63 @@ tagId = id; taggableType = type; width = parseInt(domEle.css('width').replace('px','')) >=100 ? parseInt(domEle.css('width').replace('px','')) : 100 - domEle.html(''); + domEle.html(''); domEle.parent().css("border","1px solid #ffffff"); $("#renameTagName").focus(); } //监听所有的单击事件 - $(document.body).click(function(e){ - isdb = false; //这是单击 - node = document.elementFromPoint(e.clientX, e.clientY); - if(node.tagName == "INPUT"){ //如果是输入框的聚焦,那么就不要进行下去了 - isdb = true; //为了防止在编辑的时候又去单击其他tag去过滤。导致tag过滤不可用 - return; - } - if($("#renameTagName")[0] != undefined ){//存在renameTagName,则处于编辑状态 - if($("#renameTagName").val().trim() == tagName){ //如果值一样,则恢复原来的状态 - ele.parent().css("border",""); - ele.parent().html(tagNameHtml); + $(function(){ + $("#renameTagName").live("blur",function(){ + updateTagName(); + }).live("keypress",function(e){ + if (e.keyCode == '13') { + updateTagName(); + } + }); + }); - }else{ //否则就要更新tag名称了 -// if(confirm("是否将标签改为 "+ $("#renameTagName").val().trim())){ 去掉询问 - $.post( - '<%= update_tag_name_path %>', - {"taggableId": tagId, "taggableType": taggableType, "tagName": tagName, "renameName": $("#renameTagName").val().trim(),"courseId":<%= @course.id%>} - ) -// }else{ -// ele.parent().css("border",""); -// ele.parent().html(tagNameHtml); -// } - } - } - }); + //执行修改TAGName方法 + function updateTagName(){ + if(isdb){ + isdb = false; + if($("#renameTagName").val() == tagName){ //如果值一样,则恢复原来的状态 + ele.parent().css("border",""); + ele.parent().html(tagNameHtml); + + } + else{ + $.post( + '<%= update_tag_name_path %>', + {"taggableId": tagId, "taggableType": taggableType, "tagName": tagName, "renameName": $("#renameTagName").val().trim(),"courseId":<%= @course.id%>} + ); + } + } + } +// $(document.body).click(function(e){ +// isdb = false; //这是单击 +// node = document.elementFromPoint(e.clientX, e.clientY); +// if(node.tagName == "INPUT"){ //如果是输入框的聚焦,那么就不要进行下去了 +// isdb = true; //为了防止在编辑的时候又去单击其他tag去过滤。导致tag过滤不可用 +// return; +// } +// if($("#renameTagName")[0] != undefined ){//存在renameTagName,则处于编辑状态 +// if($("#renameTagName").val().trim() == tagName){ //如果值一样,则恢复原来的状态 +// ele.parent().css("border",""); +// ele.parent().html(tagNameHtml); +// +// }else{ //否则就要更新tag名称了 +//// if(confirm("是否将标签改为 "+ $("#renameTagName").val().trim())){ 去掉询问 +// $.post( +// '<%= update_tag_name_path %>', +// {"taggableId": tagId, "taggableType": taggableType, "tagName": tagName, "renameName": $("#renameTagName").val().trim(),"courseId":<%= @course.id%>} +// ) +//// }else{ +//// ele.parent().css("border",""); +//// ele.parent().html(tagNameHtml); +//// } +// } +// } +// }); <%end %> From b04e20ed7d0fe500b2101fc104297b6b72379edd Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 9 Oct 2015 14:25:40 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=A0=8F=E8=81=9A?= =?UTF-8?q?=E7=84=A6=E5=92=8C=E4=B8=8D=E8=81=9A=E7=84=A6=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=20=E7=9A=84=E9=9A=90=E8=97=8F=E5=92=8C=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/rails_kindeditor/helper.rb | 8 ++++++-- public/assets/kindeditor/kindeditor.js | 18 +++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) 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) { From 5f8d21f1cb45de9f4f0ec8580d673d92663d84d3 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 9 Oct 2015 14:26:27 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=9A=82=E6=97=B6=E5=8E=BB=E6=8E=89=20?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=A0=8F=E8=81=9A=E7=84=A6=E5=92=8C=E4=B8=8D?= =?UTF-8?q?=E8=81=9A=E7=84=A6=E7=9A=84=E6=97=B6=E5=80=99=20=E7=9A=84?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E5=92=8C=E6=98=BE=E7=A4=BA=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/rails_kindeditor/helper.rb | 8 ++------ public/assets/kindeditor/kindeditor.js | 18 +++++------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb index 73924c835..f30ee2236 100644 --- a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb +++ b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb @@ -9,9 +9,7 @@ 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");$(this.toolbar.div).hide();})', - afterFocus:'eval(function(){$(this.toolbar.div).show(); })', - afterBlur:'eval(function(){if(this.edit.html().trim() == "" ){$(this.toolbar.div).hide();}})' + afterCreate: 'eval(function(){enablePasteImg(self);this.loadPlugin("autoheight")})' ))) end @@ -23,9 +21,7 @@ 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");$(this.toolbar.div).hide();})', - afterFocus:' eval(function(){$(this.toolbar.div).show(); })', - afterBlur:'eval(function(){if(this.edit.html().trim() == ""){$(this.toolbar.div).hide();}})' + afterCreate: 'eval(function(){enablePasteImg(self);this.loadPlugin("autoheight")})' ))) end diff --git a/public/assets/kindeditor/kindeditor.js b/public/assets/kindeditor/kindeditor.js index 3ad625604..448585376 100644 --- a/public/assets/kindeditor/kindeditor.js +++ b/public/assets/kindeditor/kindeditor.js @@ -3931,9 +3931,7 @@ _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) { @@ -4730,19 +4728,13 @@ function _bindTabEvent() { function _bindFocusEvent() { var self = this; K(self.edit.textarea[0], self.edit.win).focus(function(e) { - if(typeof self.afterFocus == 'string'){ - self.afterFocus = eval(self.afterFocus); - } - if ( typeof self.afterFocus == 'function') { + if (self.afterFocus) { self.afterFocus.call(self, e); } }).blur(function(e) { - if(typeof self.afterBlur == 'string'){ - self.afterBlur = eval(self.afterBlur); - } - if ( typeof self.afterBlur == 'function') { - self.afterBlur.call(self, e); - } + if (self.afterBlur) { + self.afterBlur.call(self, e); + } }); } function _removeBookmarkTag(html) { From 724abee12ad4e924444bd65a65c0792cd3e2846c Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 9 Oct 2015 15:49:50 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E7=BC=A9=E8=BF=9B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/prettify.css | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/stylesheets/prettify.css b/public/stylesheets/prettify.css index 4ae3a5e0d..0e6a00928 100644 --- a/public/stylesheets/prettify.css +++ b/public/stylesheets/prettify.css @@ -44,12 +44,12 @@ pre li,ul,ol { /* Specify class=linenums on a pre to get line numbering */ ol.linenums { margin-top: 0; margin-bottom: 0;line-height: 15px;margin-left: 0px !important; } /* IE indents via margin-left */ -.list_style ol li { - list-style-type: decimal; - margin-left: 10px !important; -} +/*.list_style ol li {*/ + /*list-style-type: decimal;*/ + /*margin-left: 10px !important;*/ +/*}*/ .linenums li { - margin-left: 0px !important; + margin-left: 5px !important; } li.L0, li.L1,