码迷,mamicode.com
首页 > 其他好文 > 详细

138、脚本编辑器

时间:2019-08-21 13:35:07      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:ng-click   ati   The   toc   outline   btn   toolbar   init   lib   

dir_alert
              .set({
                theme: {
                  width: ‘70%‘,
                },
                title: ‘脚本编辑器‘,
                tpl: ‘<div ng-init="init()">‘ +
                  ‘<div id="editormd">‘ +
                  ‘<textarea style="display:none;"></textarea>‘ +
                  ‘</div>‘ +
                  ‘<div class="text-center">‘ +
                  ‘<button type="button" class="btn btn-outline-primary" style="margin-right:50px;width:150px" ng-click="cancel()">取消</button>‘ +
                  ‘<button type="button" class="btn btn-outline-danger"  style="width:150px"  ng-click="ok()">确认</button>‘ +
                  ‘</div>‘ +
                  ‘</div>‘,
                tpl_scope: {
                  init: function () {
                    var that = this;
                    angular.element(document).ready(function () {
                      that.testEditor = editormd(‘editormd‘, {
                        width: ‘100%‘,
                        height: ‘720‘,
                        watch: false,
                        toolbar: false,
                        codeFold: true,
                        searchReplace: true,
                        placeholder: ‘‘,
                        value: res.content,
                        theme: ‘default‘,
                        mode: current_config.language,
                        path: ‘../../static/common/editor.md/lib/‘
                      });
                    });
                    $timeout(function () {
                      that.past_value = that.testEditor.getValue();
                    }, 500);
                  },
                  ok: function () {
                    var that = this;
                    that.now_value = that.testEditor.getValue();
                    if (that.past_value === that.now_value) {
                      dir_alert.show(false);
                      return;
                    }
                    tradeApi
                      .query({
                        method: ‘post‘,
                        root: ‘protocol‘,
                        url: current_config.save_url,
                        data: {
                          id: li.id,
                          content: that.now_value
                        },
                        check_status: ‘never‘,
                      })
                      .then(function (res) {
                        if (res.data.status === 0) {
                          if (res.data.type === 2) {
                            dir_alert
                              .set({
                                content: res.data.msg,
                                button: true,
                                ok: function () {
                                  tradeApi
                                    .query({
                                      method: ‘post‘,
                                      root: ‘protocol‘,
                                      url: current_config.save_url,
                                      data: {
                                        id: li.id,
                                        content: that.now_value,
                                        action: 2,
                                      },
                                      check_status: ‘never‘,
                                    })
                                    .then(function () {
                                      $scope.g_tip(‘协议保存成功‘);
                                    });
                                }
                              });
                          } else if (res.data.type === 3) {
                            dir_alert.set({
                              content: res.data.msg,
                              button: true,
                              cancel_hiden: true,
                            });
                          } else {
                            dir_alert.set({
                              content: res.data.msg
                            });
                          }
                        } else if (res.data.status === 1) {
                          dir_alert.show(false);
                          $scope.g_tip(‘协议保存成功‘);
                        }
                      });
                  },
                  cancel: function () {
                    dir_alert.show(false);
                  }
                }
              });

  

138、脚本编辑器

标签:ng-click   ati   The   toc   outline   btn   toolbar   init   lib   

原文地址:https://www.cnblogs.com/gushixianqiancheng/p/11388151.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!