Skip to content

Commit a7dba05

Browse files
committed
1 parent d48daa6 commit a7dba05

File tree

3 files changed

+33
-34
lines changed

3 files changed

+33
-34
lines changed

src/main/resources/META-INF/resources/primefaces/core/core.utils.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,31 @@ if (!PrimeFaces.utils) {
3434
}
3535
},
3636

37-
addDynamicOverlayModal: function(element, id) {
37+
addModal: function(id, zIndex) {
3838
var modalId = id + '_modal';
3939

4040
var modalOverlay = $('<div id="' + modalId + '" class="ui-widget-overlay ui-dialog-mask"></div>');
4141
modalOverlay.appendTo($(document.body));
42-
modalOverlay.css('z-index' , element.css('z-index') - 1);
42+
modalOverlay.css('z-index' , zIndex);
4343

4444
return modalOverlay;
4545
},
4646

47-
removeDynamicOverlayModal: function(id) {
47+
removeModal: function(id) {
4848
var modalId = id + '_modal';
4949

5050
// if the id contains a ':'
5151
$(PrimeFaces.escapeClientId(modalId)).remove();
5252

5353
// if the id does NOT contain a ':'
5454
$(document.body).children("[id='" + modalId + "']").remove();
55+
},
56+
57+
isModalActive: function(id) {
58+
var modalId = id + '_modal';
59+
60+
return $(PrimeFaces.escapeClientId(modalId)).length === 1
61+
|| $(document.body).children("[id='" + modalId + "']").length === 1;
5562
}
5663

5764
};

src/main/resources/META-INF/resources/primefaces/core/core.widget.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ if (!PrimeFaces.widget) {
149149
if (this.appendTo) {
150150
PrimeFaces.utils.removeDynamicOverlay(this, this.jq, this.id, this.appendTo);
151151
}
152-
PrimeFaces.utils.removeDynamicOverlayModal(this.id);
152+
PrimeFaces.utils.removeModal(this.id);
153153

154154
this.appendTo = null;
155155
this.modalOverlay = null;
@@ -162,18 +162,18 @@ if (!PrimeFaces.widget) {
162162
if (this.appendTo) {
163163
PrimeFaces.utils.removeDynamicOverlay(this, this.jq, this.id, this.appendTo);
164164
}
165-
PrimeFaces.utils.removeDynamicOverlayModal(this.id);
165+
PrimeFaces.utils.removeModal(this.id);
166166

167167
this.appendTo = null;
168168
this.modalOverlay = null;
169169
},
170170

171171
enableModality: function() {
172-
this.modalOverlay = PrimeFaces.utils.addDynamicOverlayModal(this.jq, this.id);
172+
this.modalOverlay = PrimeFaces.utils.addModal(this.id, this.jq.css('z-index') - 1);
173173
},
174174

175175
disableModality: function(){
176-
PrimeFaces.utils.removeDynamicOverlayModal(this.id);
176+
PrimeFaces.utils.removeModal(this.id);
177177
this.modalOverlay = null;
178178
}
179179
});

src/main/resources/META-INF/resources/primefaces/lightbox/lightbox.js

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,31 @@ PrimeFaces.widget.LightBox = PrimeFaces.widget.BaseWidget.extend({
2727
this.links.data('primefaces-lightbox-trigger', true).find('*').data('primefaces-lightbox-trigger', true);
2828
},
2929

30+
//@override
3031
refresh: function(cfg) {
31-
$(PrimeFaces.escapeClientId(cfg.id) + '_panel').remove();
32+
PrimeFaces.utils.removeDynamicOverlay(this, this.panel, this.id + '_panel', $(document.body));
3233

3334
this.init(cfg);
3435
},
3536

37+
//@override
3638
destroy: function() {
37-
this.panel.remove();
39+
PrimeFaces.utils.removeDynamicOverlay(this, this.panel, this.id + '_panel', $(document.body));
3840
},
3941

4042
createPanel: function() {
41-
var dom = '<div id="' + this.id + '_panel" class="ui-lightbox ui-widget ui-helper-hidden ui-corner-all ui-shadow">';
42-
dom += '<div class="ui-lightbox-content-wrapper">';
43-
dom += '<a class="ui-state-default ui-lightbox-nav-left ui-corner-right ui-helper-hidden"><span class="ui-icon ui-icon-carat-1-w">go</span></a>';
44-
dom += '<div class="ui-lightbox-content ui-corner-all"></div>';
45-
dom += '<a class="ui-state-default ui-lightbox-nav-right ui-corner-left ui-helper-hidden"><span class="ui-icon ui-icon-carat-1-e">go</span></a>';
46-
dom += '</div>';
47-
dom += '<div class="ui-lightbox-caption ui-widget-header"><span class="ui-lightbox-caption-text"></span>';
48-
dom += '<a class="ui-lightbox-close ui-corner-all" href="#"><span class="ui-icon ui-icon-closethick"></span></a><div style="clear:both" /></div>';
49-
dom += '</div>';
50-
51-
$(document.body).append(dom);
52-
53-
this.panel = $(this.jqId + '_panel');
43+
this.panel = $('<div id="' + this.id + '_panel" class="ui-lightbox ui-widget ui-helper-hidden ui-corner-all ui-shadow">'
44+
+ '<div class="ui-lightbox-content-wrapper">'
45+
+ '<a class="ui-state-default ui-lightbox-nav-left ui-corner-right ui-helper-hidden"><span class="ui-icon ui-icon-carat-1-w">go</span></a>'
46+
+ '<div class="ui-lightbox-content ui-corner-all"></div>'
47+
+ '<a class="ui-state-default ui-lightbox-nav-right ui-corner-left ui-helper-hidden"><span class="ui-icon ui-icon-carat-1-e">go</span></a>'
48+
+ '</div>'
49+
+ '<div class="ui-lightbox-caption ui-widget-header"><span class="ui-lightbox-caption-text"></span>'
50+
+ '<a class="ui-lightbox-close ui-corner-all" href="#"><span class="ui-icon ui-icon-closethick"></span></a><div style="clear:both" /></div>'
51+
+ '</div>');
52+
53+
this.panel.appendTo($(document.body));
54+
5455
this.contentWrapper = this.panel.children('.ui-lightbox-content-wrapper');
5556
this.content = this.contentWrapper.children('.ui-lightbox-content');
5657
this.caption = this.panel.children('.ui-lightbox-caption');
@@ -304,7 +305,7 @@ PrimeFaces.widget.LightBox = PrimeFaces.widget.BaseWidget.extend({
304305

305306
this.panel.css('z-index', ++PrimeFaces.zindex).show();
306307

307-
if(!this.isModalActive()) {
308+
if(!PrimeFaces.utils.isModalActive(this.id)) {
308309
this.enableModality();
309310
}
310311

@@ -340,20 +341,11 @@ PrimeFaces.widget.LightBox = PrimeFaces.widget.BaseWidget.extend({
340341
},
341342

342343
enableModality: function() {
343-
$(document.body).append('<div id="' + this.id + '_modal" class="ui-widget-overlay"></div>').
344-
children(this.jqId + '_modal').css({
345-
'width': $(document).width()
346-
,'height': $(document).height()
347-
,'z-index': this.panel.css('z-index') - 1
348-
});
344+
PrimeFaces.utils.addModal(this.id, this.panel.css('z-index') - 1);
349345
},
350346

351347
disableModality: function() {
352-
$(document.body).children(this.jqId + '_modal').remove();
353-
},
354-
355-
isModalActive: function() {
356-
return $(document.body).children(this.jqId + '_modal').length === 1;
348+
PrimeFaces.utils.removeModal(this.id);
357349
},
358350

359351
showNavigators: function() {

0 commit comments

Comments
 (0)