-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.ui.inplaceModal.js
79 lines (74 loc) · 2.74 KB
/
jquery.ui.inplaceModal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* jQuery UI Inplace Modal
* version: 0.2b (2009-01-30 20:12:58)
* @requires jQuery v1.2.6 or later
* @requires jQuery UI v1.6 or later
* Examples and documentation at: http://www.ringce.com/code/jQuery/jQuery.html
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
(function($) {
$.widget("ui.inplaceModal",{
show: function(){
widget = this;
var overlay_html = '';
$.each(['left', 'top', 'right', 'bottom'], function(){
var overlay = widget.overlayId(this);
if($("#" + overlay).length == 0)
overlay_html += '<div id="' + overlay + '" class="overlay"/>';
});
$('body').append(overlay_html);
$(this.element).attr("hasModal", true);
this.resizeOverlay(true);
},
resizeOverlay: function(force){
if(!force && !$("#" + widget.overlayId("left")).attr("style")) return;
widget = this;
container = this.element;
var pos = $(container).offset();
var width = $(container).width();
var height = $(container).height();
var docwidth = $(document).width();
var docheight = $(document).height();
$("#" + widget.overlayId("top")).css({
height: pos.top,
width: '100%'
});
$("#" + widget.overlayId("left")).css({
top: pos.top,
height: docheight - pos.top,
width: pos.left
});
$("#" + widget.overlayId("right")).css({
top: pos.top,
left: pos.left + width + 20,
height: docheight - pos.top,
width: docwidth - pos.left - width - 20
});
$("#" + widget.overlayId("bottom")).css({
top: pos.top + height + 20,
left:pos.left,
width: width + 20,
height: docheight - pos.top - height - 20
});
},
hide: function(){
var widget = this;
$(this.element).attr("hasModal", false);
$.each(['left', 'top', 'right', 'bottom'], function(){
$("#" + widget.overlayId(this)).removeAttr("style");
});
},
overlayId: function(side){
container = this.element;
var id = '';
containerId = $(container).attr("id");
if(containerId)
id = containerId;
else
id = $(container).parent()[0].id;
return id + "_overlay_" + side;
}
});
})(jQuery);