<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    悟心

    成功不是將來才有的,而是從決定去做的那一刻起,持續(xù)累積而成。 上人生的旅途罷。前途很遠(yuǎn),也很暗。然而不要怕。不怕的人的面前才有路。

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      93 隨筆 :: 1 文章 :: 103 評(píng)論 :: 0 Trackbacks

    CJ_StarHtmlEditor.js的代碼如下,使用方法,直接復(fù)制,保存成CJ_StarHtmlEditor.js就可以用了。

    /**
    * 作者:陳杰
    * QQ : 710782046
    * Email:ovenjackchain@gmail.com
    * Blog :http://hi.baidu.com/jackvoilet
    */
    var HTMLEditor = Ext.extend(Ext.form.HtmlEditor, {
    addImage : function() {
       var editor = this;
       var imgform = new Ext.FormPanel({
        region : 'center',
        labelWidth : 55,
        frame : true,
        bodyStyle : 'padding:5px 5px 0',
        autoScroll : true,
        border : false,
        fileUpload : true,
        items : [{
           xtype : 'textfield',
           fieldLabel : '選擇文件',
           name : 'userfile',
           id : 'userfile',
           inputType : 'file',
           allowBlank : false,
           blankText : '文件不能為空',
           height : 25,
           anchor : '98%'
          }],
        buttons : [{
         text : '上傳',
         type : 'submit',
         handler : function() {
          var furl="";
          furl=imgform.form.findField('userfile').getValue();
          var type=furl.substring(furl.length-3).toLowerCase();
          var filename=furl.substring(furl.lastIndexOf("
    \\")+1);
          if (furl==""||furl==null) {return;}
          if(type!='jpg'&&type!='bmp'&&type!='gif'&&type!='png'){
           alert('僅支持jpg、bmp、gif、png格式的圖片');
           return;
          }
          imgform.form.submit({
           url : '/newsinfo.mvc/AddFiles_newsinfo',
           waitMsg : '正在上傳......',
           waitTitle : '請等待',
           method : 'POST',
           success : function() {
            var element = document.createElement("img");
            element.src = "../UploadFile/"+filename;
            element.style.width="300px";
                 element.style.height="200px";
            if (Ext.isIE) {
             editor.insertAtCursor(element.outerHTML);
            } else {
             var selection = editor.win.getSelection();
             if (!selection.isCollapsed) {
              selection.deleteFromDocument();
             }
             selection.getRangeAt(0).insertNode(element);
            }
            win.close();
           },
           failure : function(form, action) {
            form.reset();
            if (action.failureType == Ext.form.Action.SERVER_INVALID)
             Ext.MessageBox.alert('警告',
               '上傳失敗,僅支持jpg、bmp、gif、png格式的圖片');
           
           }
          
          });
         }
        }, {
         text : '關(guān)閉',
         type : 'submit',
         handler : function() {
          win.close(this);
         }
        }]
       })

       var win = new Ext.Window({
          title : "上傳圖片",
          id : 'picwin',
          width : 400,
          height : 120,
          modal : true,
          border : false,
          iconCls:'icon-uploadpic',
          layout : "fit",
          items : imgform

         });
       win.show();
      
    },//上傳圖片的擴(kuò)展
    addFile : function() {
       var editor = this;
       var fileform = new Ext.FormPanel({
        region : 'center',
        labelWidth : 55,
        frame : true,
        bodyStyle : 'padding:5px 5px 0',
        autoScroll : true,
        border : false,
        fileUpload : true,
        items : [{
           xtype : 'textfield',
           fieldLabel : '選擇文件',
           name : 'userfile_F',
           id : 'userfile_F',
           inputType : 'file',
           allowBlank : false,
           blankText : '文件不能為空',
           height : 25,
           anchor : '98%'
          }],
        buttons : [{
         text : '上傳',
         type : 'submit',
         handler : function() {
          var furl="";//文件物理地址
          var fname="";//文件名稱
          furl=fileform.form.findField('userfile_F').getValue();
          var type=furl.substring(furl.length-3).toLowerCase();
          if (furl==""||furl==null) {return;}
          if(type!='doc'&&type!='xls'){
           alert('僅支持上傳doc、xls格式的文件!');
           return;
          }
          fname=furl.substring(furl.lastIndexOf("
    \\")+1);
          fileform.form.submit({
           url : '/newsinfo.mvc/AddFiles_newsinfo',
           waitMsg : '正在上傳......',
           waitTitle : '請等待',
           method : 'POST',
           success : function() {
            var element = document.createElement("a");
            element.href = "../UploadFile/"+fname;
            element.target = '_blank';
            element.innerHTML = fname;
            if (Ext.isIE) {
             editor.insertAtCursor(element.outerHTML);
            } else {
             var selection = editor.win.getSelection();
             if (!selection.isCollapsed) {
              selection.deleteFromDocument();
             }
             selection.getRangeAt(0).insertNode(element);
            }
            winFile.close();
           },
           failure : function() {
            form.reset();
            if (action.failureType == Ext.form.Action.SERVER_INVALID)
             Ext.MessageBox.alert('警告',
               '上傳失敗,僅支持上傳doc、xls格式的文件!');
           
           }
          
          });
         }
        }, {
         text : '關(guān)閉',
         type : 'submit',
         handler : function() {
          winFile.close(this);
         }
        }]
       })

       var winFile = new Ext.Window({
          title : "上傳附件",
          id : 'picwin',
          width : 400,
          height : 120,
          modal : true,
          border : false,
          layout : "fit",
          iconCls : 'icon-uploadfile',
          items : fileform

         });
       winFile.show();
      
    },//上傳附件的擴(kuò)展
    addflash : function() {
       var editor = this;
       var flashform = new Ext.FormPanel({
        region : 'center',
        labelWidth : 55,
        frame : true,
        bodyStyle : 'padding:5px 5px 0',
        autoScroll : true,
        border : false,
        items : [{
           xtype : 'textfield',
           fieldLabel : 'flash地址',
           name : 'userflash',
           id : 'userflash',
           allowBlank : false,
           blankText : 'http://',
           emptyText : 'http://',
           height : 25,
           anchor : '98%'
          }],
        buttons : [{
         text : '添加',
         type : 'submit',
         handler : function() {
          var furl="";//文件物理地址
          furl=flashform.form.findField('userflash').getValue();
          var type=furl.substring(furl.length-3).toLowerCase();
          if (furl==""||furl==null) {return;}
          if(type!='swf'&&type!='flv'){
           alert('非法格式,請檢查!');
           return;
          }
          var element = document.createElement("embed");
          element.src = furl;
          element.type="application/x-shockwave-flash";
          element.quality="high";
          element.style.width="300px";
          element.style.height="200px";
          if(Ext.isIE) {
           editor.insertAtCursor(element.outerHTML);
          } else {
            var selection = editor.win.getSelection();
            if (!selection.isCollapsed) {
                selection.deleteFromDocument();
            }
            selection.getRangeAt(0).insertNode(element);
          }
          winflash.close();
         }
        }, {
         text : '關(guān)閉',
         type : 'submit',
         handler : function() {
          winflash.close(this);
         }
        }]
       })

       var winflash = new Ext.Window({
          title : "插入flash",
          id : 'flashwin',
          width : 400,
          height : 120,
          modal : true,
          border : false,
          layout : "fit",
          iconCls : 'icon-swf',
          items : flashform

         });
       winflash.show();
      
    },//插入flash的擴(kuò)展
    addfilm : function() {
       var editor = this;
       var filmform = new Ext.FormPanel({
        region : 'center',
        labelWidth : 70,
        frame : true,
        bodyStyle : 'padding:5px 5px 0',
        autoScroll : true,
        border : false,
        items : [{
           xtype : 'textfield',
           fieldLabel : '多媒體地址',
           name : 'userfilm',
           id : 'userfilm',
           allowBlank : false,
           blankText : 'http://',
           emptyText : 'http://',
           height : 25,
           anchor : '98%'
          }],
        buttons : [{
         text : '添加',
         type : 'submit',
         handler : function() {
          var furl="";//文件物理地址
          var regImg = new RegExp(/\.(mp3|wav|wma|wmv|avi|mpg|asf|rm|rmvb)$/);
          var regrm=new RegExp(/\.(rm|rmvb)$/);
          furl=filmform.form.findField('userfilm').getValue();
          //var type=furl.substring(furl.length-3).toLowerCase();
          if (furl==""||furl==null) {return;}
          if(!furl.match(regImg)){
           alert('非法格式,請檢查!系統(tǒng)支持:mp3,wav,wma,wmv,avi,mpg,asf,rm,rmvb');
           return;
          }
          var element = document.createElement("embed");
          element.src = furl;
          element.style.width="300px";
          element.style.height="200px";
          if(furl.match(regrm))
             element.type="audio/x-pn-realaudio-plugin";
          else
             element.type="video/x-ms-asf-plugin";
          element.loop="true";
          element.autostart="true";
          if(Ext.isIE) {
           editor.insertAtCursor(element.outerHTML);
          } else {
            var selection = editor.win.getSelection();
            if (!selection.isCollapsed) {
                selection.deleteFromDocument();
            }
            selection.getRangeAt(0).insertNode(element);
          }
          winfilm.close();
         }
        }, {
         text : '關(guān)閉',
         type : 'submit',
         handler : function() {
          winfilm.close(this);
         }
        }]
       })

       var winfilm = new Ext.Window({
          title : "插入多媒體",
          id : 'filmwin',
          width : 410,
          height : 120,
          modal : true,
          border : false,
          layout : "fit",
          iconCls : 'icon-film',
          items : filmform

         });
       winfilm.show();
      
    },//插入過媒體的擴(kuò)展
    createToolbar : function(editor) {
       HTMLEditor.superclass.createToolbar.call(this, editor);
       this.tb.insertButton(16, {
          cls : "x-btn-icon",
          iconCls : "icon-uploadpic",
          handler : this.addImage,
          tooltip : "添加圖片",
          scope : this
         });
       this.tb.insertButton(17, {
          cls : "x-btn-icon",
          iconCls : 'icon-uploadfile',
          handler : this.addFile,
          tooltip : "添加文件",
          scope : this
         });
         this.tb.insertButton(18, {
          cls : "x-btn-icon",
          iconCls : 'icon-swf',
          handler : this.addflash,
          tooltip : "添加flash文件",
          scope : this
         });
         this.tb.insertButton(19, {
          cls : "x-btn-icon",
          iconCls : 'icon-film',
          handler : this.addfilm,
          tooltip : "添加多媒體文件",
          scope : this
         });
      this.tb.insertButton(20, {//插入層的擴(kuò)展,即插入div
          cls : "x-btn-icon",
          iconCls : 'icon-div',
          handler : function() {
             var element = document.createElement("div");
             element.id="InsertDiv";
             element.style.backgroundColor="#FAFAFB";
             element.style.borderWidth="1px";
             element.style.borderStyle="solid";
             element.style.borderColor="#AECBE7";
             element.innerHTML="在此插入內(nèi)容:<BR>";
             if(Ext.isIE) {
           editor.insertAtCursor(element.outerHTML);
          } else {
            var selection = editor.win.getSelection();
            if (!selection.isCollapsed) {
                selection.deleteFromDocument();
            }
            selection.getRangeAt(0).insertNode(element);
          }
          },
          tooltip : "添加div層",
          scope : this
         });
         this.tb.insertButton(21, { //插入橫線的擴(kuò)展
          cls : "x-btn-icon",
          iconCls : 'icon-hr',
          handler :function() {
             var element = document.createElement("HR");
             if(Ext.isIE) {
           editor.insertAtCursor(element.outerHTML);
          } else {
            var selection = editor.win.getSelection();
            if (!selection.isCollapsed) {
                selection.deleteFromDocument();
            }
            selection.getRangeAt(0).insertNode(element);
          }
          },
          tooltip : "添加橫線",
          scope : this
         });
    }
    });
    Ext.reg('CJ_starthtmleditor', HTMLEditor);

    大家可以根據(jù)這個(gè)方法繼續(xù)擴(kuò)展自己想要的東西。

    上面上傳圖片和附件有一個(gè)方法,內(nèi)容如下:

    //上傳文件
            [AcceptVerbs(HttpVerbs.Post)]
            public ActionResult AddFiles_newsinfo(FormCollection collection)
            {
                var rdto = new ResultDTO();
                var c = Request.Files[0];
                if (c != null && c.ContentLength > 0)
                {
                    string filename = c.FileName;
                    string destination = Server.MapPath("/UploadFile/");
                    c.SaveAs(destination+ filename);
                }
                return null;
            }

     

    使用的時(shí)候,首先在頁面中添加該js的引用,然后,在需要的地方加入以下代碼:

                             {
                                border : false,
                                columnWidth : 1,
                                layout : 'form',
                                items : [{
                                   fieldLabel : '信息內(nèi)容',
                                   xtype : 'CJ_starthtmleditor',
                                   name : 'nr',
                                   id : 'nr',
                                   allowBlank : false,
                                   anchor : '98%'
                                  }]

                               }


    轉(zhuǎn)載地址:http://hi.baidu.com/jackvoilet/blog/item/38551a3dc709d40cbba16717.html

    posted on 2010-08-30 00:01 艾波 閱讀(3904) 評(píng)論(0)  編輯  收藏 所屬分類: Extjs
    主站蜘蛛池模板: 大地资源在线资源免费观看| 国产福利在线免费| 亚洲欧洲日产v特级毛片| 丁香花免费完整高清观看| 国产偷国产偷亚洲高清人| 亚洲av综合色区| 热99re久久免费视精品频软件| 久久精品免费网站网| 亚洲AV成人影视在线观看 | 久久噜噜噜久久亚洲va久| 美女视频黄的全免费视频网站| 添bbb免费观看高清视频| 亚洲色图.com| 免费人成激情视频| 国拍在线精品视频免费观看| jizz在线免费观看| 亚洲中文字幕乱码AV波多JI| 久久亚洲精品中文字幕三区| 国产精品免费电影| 1000部无遮挡拍拍拍免费视频观看 | 久久九九AV免费精品| 亚洲中文字幕无码中文字| 亚洲精品无码午夜福利中文字幕| 成人au免费视频影院| 特级精品毛片免费观看| 免费VA在线观看无码| 亚洲狠狠成人综合网| 久久九九亚洲精品| 亚洲AⅤ永久无码精品AA| 中文字幕无码视频手机免费看| 国产性生大片免费观看性| 久久亚洲AV成人无码国产电影| 亚洲第一成年人网站| 国产亚洲人成网站观看| 亚洲A∨午夜成人片精品网站 | 亚洲精品成人无码中文毛片不卡| 在线观看国产情趣免费视频| 黄色成人免费网站| 老汉精品免费AV在线播放| 两性色午夜视频免费网| 一级黄色免费网站|