You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

des_kindEditor.js 5.6 kB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. var editor2;
  2. function init_des_editor(params){
  3. // var minHeight; //最小高度
  4. var paramsHeight = params.height; //设定的高度
  5. var paramsWidth = params.width == undefined ? "100%" : params.width;
  6. var editor = params.kindutil.create(params.textarea, {
  7. resizeType : 1,minWidth:"1px",width:paramsWidth,
  8. height:"30px",// paramsHeight == undefined ? "30px":paramsHeight+"px",
  9. minHeight:"30px",// paramsHeight == undefined ? "30px":paramsHeight+"px",
  10. items : ['code','emoticons','fontname',
  11. 'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|',
  12. 'formatblock', 'fontsize', '|','indent', 'outdent',
  13. '|','imagedirectupload','table', 'media', 'preview',"more"
  14. ],
  15. afterChange:function(){//按键事件
  16. //nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
  17. var edit = this.edit;
  18. var body = edit.doc.body;
  19. edit.iframe.height(paramsHeight);
  20. this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 33, paramsHeight));
  21. },
  22. afterCreate:function(){
  23. //init
  24. var edit = this.edit;
  25. var body = edit.doc.body;
  26. edit.iframe[0].scroll = 'no';
  27. body.style.overflowY = 'hidden';
  28. //reset height
  29. var edit = this.edit;
  30. edit.html(params.textarea.innerHTML);
  31. var body = edit.doc.body;
  32. paramsHeight = paramsHeight == undefined ? params.kindutil.removeUnit(this.height) : paramsHeight;
  33. edit.iframe.height(paramsHeight);
  34. this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight), paramsHeight));
  35. elocalStorage(editor2,'org_document');
  36. }
  37. }).loadPlugin('paste');
  38. return editor;
  39. }
  40. function nh_check_field(params){
  41. var result=true;
  42. if(!check_org_title()) {
  43. result=false;
  44. return result;
  45. }
  46. if(params.content!=undefined){
  47. if(params.content.isEmpty()){
  48. result=false;
  49. }
  50. if(params.content.html()!=params.textarea.html() || params.issubmit==true){
  51. params.textarea.html(params.content.html());
  52. params.content.sync();
  53. if(params.content.isEmpty()){
  54. params.contentmsg.html('请输入文章描述');
  55. params.contentmsg.css({color:'#ff0000'});
  56. }else{
  57. params.contentmsg.html('填写正确');
  58. params.contentmsg.css({color:'#008000'});
  59. }
  60. }
  61. }
  62. return result;
  63. }
  64. function init_form(params){
  65. params.form.submit(function(){
  66. var flag = false;
  67. if(params.form.attr('data-remote') != undefined ){
  68. flag = true
  69. }
  70. var is_checked = nh_check_field({
  71. issubmit:true,
  72. //title:params.texttitle,
  73. content:params.editor,
  74. //titlemsg:params.titlemsg,
  75. contentmsg:params.contentmsg,
  76. textarea:params.textarea
  77. });
  78. if(is_checked){
  79. if(flag){
  80. return true;
  81. }else{
  82. $(this)[0].submit();
  83. return false;
  84. }
  85. }
  86. return false;
  87. });
  88. }
  89. function nh_reset_form(params){
  90. params.form[0].reset();
  91. $("#document_title").val("");
  92. $('#org_document_editor').hide();
  93. $('#doc_title_hint').hide();
  94. params.textarea.empty();
  95. if(params.editor != undefined){
  96. params.editor.html(params.textarea.html());
  97. }
  98. params.contentmsg.hide();
  99. params.titlemsg.html("");
  100. }
  101. //第二个参数是高度,可以传,可以不传
  102. function init_des_data(){
  103. var height = arguments[0] ? arguments[0] : undefined;
  104. var width = arguments[1] ? arguments[1] : undefined;
  105. KindEditor.ready(function (K) {
  106. $("div[nhname='new_topic_form']").each(function () {
  107. var params = {};
  108. params.kindutil = K;
  109. params.div_form = $(this);
  110. params.form = $("form", params.div_form);
  111. if (params.form == undefined || params.form.length == 0) {
  112. return;
  113. }
  114. //params.texttitle = $("#document_title", params.div_form);
  115. params.textarea = $("textarea[nhname='description_textarea']", params.div_form);
  116. //params.titlemsg = $("#doc_title_hint", params.div_form);
  117. params.contentmsg = $("#homework_course_id_span", params.div_form);
  118. params.cancel_btn = $("#new_topic_cancel_btn");
  119. params.submit_btn = $("#new_topic_submit_btn");
  120. params.height = height;
  121. params.width = width;
  122. if (params.textarea.data('init') == undefined) {
  123. params.editor = init_des_editor(params);
  124. editor2 = params.editor;
  125. init_form(params);
  126. params.cancel_btn.click(function () {
  127. nh_reset_form(params);
  128. });
  129. params.submit_btn.click(function () {
  130. params.editor.sync();
  131. params.form.submit();
  132. });
  133. params.textarea.data('init', 1);
  134. $(this).show();
  135. }
  136. });
  137. });
  138. div_form = $("div[nhname='new_topic_form']");
  139. $(".ke-edit", div_form).css("height","150px");
  140. $(".ke-edit-iframe",div_form).css("height","150px");
  141. }

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...