提交 88febbd3 编写于 作者: C Catouse

* fix rememberPos options of modal and modal trigger and update document.

上级 bd2c3fea
...@@ -273,7 +273,7 @@ $('#myModal').modal(options) ...@@ -273,7 +273,7 @@ $('#myModal').modal(options)
<td>* `false`(默认),不记住位置; <td>* `false`(默认),不记住位置;
* `true`,记住位置; * `true`,记住位置;
* 页面内值唯一的字符串,使用本地存储记住位置;</td> * 页面内值唯一的字符串,使用本地存储记住位置;</td>
<td>当该值为一个在页面范围内值唯一的字符串时,通过浏览器本地存储来存储数据,关闭页面或浏览器之后也不会忘记。</td> <td>启用该选项需要同时启用 `moveable` 选项,当该值为一个在页面范围内值唯一的字符串时,通过浏览器本地存储来存储数据,关闭页面或浏览器之后也不会忘记。</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
......
...@@ -402,6 +402,14 @@ myModalTrigger.show(); ...@@ -402,6 +402,14 @@ myModalTrigger.show();
* `true`,启用;</td> * `true`,启用;</td>
<td>是否启用对话框拖拽移动功能</td> <td>是否启用对话框拖拽移动功能</td>
</tr> </tr>
<tr>
<td>`rememberPos`</td>
<td>记住移动的位置</td>
<td>* `false`(默认),不记住位置;
* `true`,记住位置;
* 页面内值唯一的字符串,使用本地存储记住位置;</td>
<td>启用该选项需要同时启用 `moveable` 选项,当该值为一个在页面范围内值唯一的字符串时,通过浏览器本地存储来存储数据,关闭页面或浏览器之后也不会忘记。</td>
</tr>
<tr> <tr>
<td>`waittime`</td> <td>`waittime`</td>
<td>加载远程内容时的最大等待时间</td> <td>加载远程内容时的最大等待时间</td>
......
...@@ -74,11 +74,12 @@ ...@@ -74,11 +74,12 @@
var topPos = position == 'fit' ? (half * 2 / 3) : (position == 'center' ? half : position); var topPos = position == 'fit' ? (half * 2 / 3) : (position == 'center' ? half : position);
if($dialog.hasClass('modal-moveable')) { if($dialog.hasClass('modal-moveable')) {
var pos = null; var pos = null;
if(this.options.rememberPos) { var rememberPos = this.options.rememberPos;
if(this.options.rememberPos === true) { if(rememberPos) {
if(rememberPos === true) {
pos = this.$element.data('modal-pos'); pos = this.$element.data('modal-pos');
} else if($.zui.store) { } else if($.zui.store) {
pos = $.zui.store.pageGet(zuiname + '.rememberPos'); pos = $.zui.store.pageGet(zuiname + '.rememberPos.' + rememberPos);
} }
} }
if(!pos) { if(!pos) {
...@@ -108,10 +109,11 @@ ...@@ -108,10 +109,11 @@
$dialog.css('margin-top', '').addClass('modal-dragged'); $dialog.css('margin-top', '').addClass('modal-dragged');
}, },
finish: function(e) { finish: function(e) {
if(options.rememberPos) { var rememberPos = options.rememberPos;
if(rememberPos) {
that.$element.data('modal-pos', e.pos); that.$element.data('modal-pos', e.pos);
if($.zui.store && options.rememberPos !== true) { if($.zui.store && rememberPos !== true) {
$.zui.store.pageSet(zuiname + '.rememberPos', e.pos); $.zui.store.pageSet(zuiname + '.rememberPos.' + rememberPos, e.pos);
} }
} }
} }
......
...@@ -278,10 +278,11 @@ ...@@ -278,10 +278,11 @@
} }
$modal.modal({ $modal.modal({
show: 'show', show : 'show',
backdrop: options.backdrop, backdrop : options.backdrop,
moveable: options.moveable, moveable : options.moveable,
keyboard: options.keyboard rememberPos: options.rememberPos,
keyboard : options.keyboard
}); });
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册