1 /**
  2  * source editor for kissy editor
  3  * @author yiminghe@gmail.com
  4  */
  5 KISSY.add("editor/plugin/sourceArea/index", function (S, Editor) {
  6 
  7     var SOURCE_MODE = Editor.SOURCE_MODE ,
  8         WYSIWYG_MODE = Editor.WYSIWYG_MODE;
  9 
 10     function sourceArea() {
 11     }
 12 
 13     S.augment(sourceArea, {
 14         renderUI:function (editor) {
 15             editor.addButton("sourceArea", {
 16                 tooltip:"源码",
 17                 listeners:{
 18                     afterSyncUI:function () {
 19                         var self = this;
 20                         editor.on("wysiwygMode", function () {
 21                             self.set("checked", false);
 22                         });
 23                         editor.on("sourceMode", function () {
 24                             self.set("checked", true);
 25                         });
 26 
 27                     },
 28                     click:function () {
 29                         var self = this;
 30                         var checked = self.get("checked");
 31                         if (checked) {
 32                             editor.set("mode", SOURCE_MODE);
 33                         } else {
 34                             editor.set("mode", WYSIWYG_MODE);
 35                         }
 36 
 37                         editor.focus();
 38 
 39                     }
 40                 },
 41                 checkable:true
 42             });
 43         }
 44     });
 45 
 46     return sourceArea;
 47 }, {
 48     requires:['editor', '../button/']
 49 });
 50