Authored by 周少峰

Merge branch 'feature/students' into release/4.9.1.0

@@ -9,7 +9,8 @@ var $ = require('yoho-jquery'), @@ -9,7 +9,8 @@ var $ = require('yoho-jquery'),
9 9
10 var defaultOptions = { 10 var defaultOptions = {
11 mask: true, 11 mask: true,
12 - closeIcon: true 12 + closeIcon: true,
  13 + refreshOnClose: false
13 }; 14 };
14 15
15 var tpl = 16 var tpl =
@@ -53,6 +54,15 @@ function createDialog(data) { @@ -53,6 +54,15 @@ function createDialog(data) {
53 return $('.yoho-dialog'); 54 return $('.yoho-dialog');
54 } 55 }
55 56
  57 +function cerateSubContent(text) {
  58 + var $yohoDialog = $('.yoho-dialog'),
  59 + subContent = '<p class="sub-content">' + text + '</p>';
  60 +
  61 + if ($yohoDialog && $yohoDialog.length > 0) {
  62 + $yohoDialog.find('.content').after(subContent);
  63 + }
  64 +}
  65 +
56 function Dialog(options) { 66 function Dialog(options) {
57 var opt = $.extend({}, defaultOptions, options); 67 var opt = $.extend({}, defaultOptions, options);
58 var that = this, 68 var that = this,
@@ -66,11 +76,31 @@ function Dialog(options) { @@ -66,11 +76,31 @@ function Dialog(options) {
66 if (opt.mask) { 76 if (opt.mask) {
67 that.$mask = createMask(); 77 that.$mask = createMask();
68 } 78 }
  79 +
69 that.$el = createDialog(opt); 80 that.$el = createDialog(opt);
70 81
  82 +
  83 + if (opt.subContent) {
  84 + cerateSubContent(opt.subContent);
  85 + }
  86 +
  87 + if (opt.subContents) {
  88 + for (i = opt.subContents.length - 1; i >= 0; i--) {
  89 + cerateSubContent(opt.subContents[i]);
  90 + }
  91 + }
  92 +
71 // 绑定x关闭事件 93 // 绑定x关闭事件
72 that.$el.find('.close').click(function() { 94 that.$el.find('.close').click(function() {
73 that.close(); 95 that.close();
  96 + if (options.refreshOnClose) {
  97 + window.location.reload();
  98 + }
  99 + });
  100 +
  101 + // 绑定btn关闭事件
  102 + that.$el.find('.btn-close').click(function() {
  103 + that.close();
74 }); 104 });
75 105
76 function bindBtnEvt(index) { 106 function bindBtnEvt(index) {