Skip to content

Commit 4131d2b

Browse files
committed
version 2.5.0 release
New **option.controls.confirmClose**. If set to a text value this text will be used for a **window.confirm()** and panel will only be closed if true is returned (only for close button of panel)
1 parent 3989000 commit 4131d2b

14 files changed

+133
-10374
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
---
44

5+
### Version 2.5.0
6+
7+
+ new **option.controls.confirmClose**. If set to a text value this text will be used for a **window.confirm()** and panel will only be closed if true is returned (only for close button of panel)
8+
9+
---
10+
511
### Version 2.4.1
612

713
+ **fix** issue with some links/events not working properly inside a jsPanel

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## [jsPanel 2.4.1 released 2015-04-09](#)
1+
## [jsPanel 2.5.0 released 2015-05-04](#)
22

33
**A jQuery plugin to create multifunctional floating panels.**
44

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jspanel",
3-
"version": "v2.4.1",
3+
"version": "v2.5.0",
44
"description": "A jQuery Plugin to create highly configurable multifunctional floating panels for use in backend solutions and other web applications. Also usable as modal panel, tooltip or hint. With built in support for bootstrap, right-to-left text direction and more ...",
55
"keywords": [
66
"jQuery",

jsPanel.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"hint",
1616
"bootstrap"
1717
],
18-
"version": "2.4.1",
18+
"version": "2.5.0",
1919
"author": {
2020
"name": "Stefan Straesser",
2121
"url": "http://jspanel.de/",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jspanel",
3-
"version": "2.4.1",
3+
"version": "2.5.0",
44
"description": "A jQuery Plugin to create highly configurable floating panels for use in a backend solution and other web applications",
55
"main": [
66
"source/jquery.jspanel.js",

source/jquery.jspanel.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* jsPanel.css version 2.4.0 - 2015-03-11 11:10 */
1+
/* jsPanel.css version 2.5.0 - 2015-05-04 14:04 */
22
@font-face {
33
font-family: 'jsglyphregular';
44
src: url('fonts/jsglyph.eot');

source/jquery.jspanel.js

Lines changed: 62 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@
2525
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2626
THE SOFTWARE.
2727
28-
You should have received a copy of the MIT License along with this program. If not, see <http://opensource.org/licenses/MIT>.
28+
<http://opensource.org/licenses/MIT>.
2929
*/
3030

3131
/*
32-
CHANGES IN 2.4.1:
33-
+ jsPanel.resize() altered to exclude minimized panels
34-
+ fix of broken events inside panels
32+
CHANGES IN 2.5.0:
33+
+ new "option.controls.confirmClose". If set to a text value this text will be used for a "window.confirm()" and panel will only
34+
be closed if true is returned (only for close button of panel)
35+
+ arrays with hints obsolete (replaced with jquery collections)
3536
*/
3637

37-
// check for jQuery and jQuery UI
38+
// check for jQuery and jQuery UI components
3839
if (!$.fn.jquery || !$.fn.uniqueId || !$.widget || !$.ui.mouse || !$.ui.draggable || !$.ui.resizable) {
3940
console.log("Error: jQuery or at least one jQuery UI component is not loaded! You need at least jQuery 1.9.1 and jQuery UI 1.9.2 (modules Core, Mouse, Widget, Draggable and Resizable).");
4041
} else {
@@ -48,7 +49,7 @@ var jsPanel;
4849
(function($){
4950
"use strict";
5051
jsPanel = {
51-
version: '2.4.1 2015-04-09 11:39',
52+
version: '2.5.0 2015-05-02 16:08',
5253
device: (function(){
5354
try {
5455
// requires "mobile-detect.js" to be loaded
@@ -64,11 +65,8 @@ var jsPanel;
6465
return {mobile: undefined, tablet: undefined, phone: undefined, os: undefined, userAgent: undefined};
6566
}
6667
})(),
67-
ID: 0, // kind of a counter to add to automatically generated id attribute
68-
widthForMinimized: 180, // default width of minimized panels
69-
hintsTc: [], // arrays that log hints for option.position 'top center', 'top left' and 'top right'
70-
hintsTl: [],
71-
hintsTr: [],
68+
ID: 0, // kind of a counter to add to automatically generated id attribute
69+
widthForMinimized: 180, // default width of minimized panels
7270
template: '<div class="jsPanel jsPanel-theme-default jsPanel-state-initialized">' +
7371
'<div class="jsPanel-hdr jsPanel-theme-default">' +
7472
'<h3 class="jsPanel-title"></h3>' +
@@ -229,13 +227,13 @@ var jsPanel;
229227
// corrections if jsPanel is appended to the body element
230228
if (panel.option.selector === 'body') {
231229
if (prop === 'top') {
232-
panel.option.position.top = parseInt(optPosition.top, 10) + $(window).scrollTop() + 'px';
230+
panel.option.position.top = parseInt(optPosition.top, 10) + window.scrollY + 'px';
233231
} else if (prop === 'bottom') {
234-
panel.option.position.bottom = parseInt(optPosition.bottom, 10) - $(window).scrollTop() + 'px';
232+
panel.option.position.bottom = parseInt(optPosition.bottom, 10) - window.scrollY + 'px';
235233
} else if (prop === 'left') {
236-
panel.option.position.left = parseInt(optPosition.left, 10) + $(window).scrollLeft() + 'px';
234+
panel.option.position.left = parseInt(optPosition.left, 10) + window.scrollX + 'px';
237235
} else if (prop === 'right') {
238-
panel.option.position.right = parseInt(optPosition.right, 10) - $(window).scrollLeft() + 'px';
236+
panel.option.position.right = parseInt(optPosition.right, 10) - window.scrollX + 'px';
239237
}
240238
}
241239
return panel.option.position[prop];
@@ -248,7 +246,7 @@ var jsPanel;
248246
posL = ($(optSelector).outerWidth() / 2) - ((parseInt(optSize.width, 10) / 2)),
249247
posT;
250248
if (optSelector === 'body') {
251-
posT = ($(window).outerHeight() / 2) - ((parseInt(optSize.height, 10) / 2) - $(window).scrollTop());
249+
posT = ($(window).outerHeight() / 2) - ((parseInt(optSize.height, 10) / 2) - window.scrollY);
252250
} else {
253251
posT = ($(optSelector).outerHeight() / 2) - ((parseInt(optSize.height, 10) / 2));
254252
}
@@ -308,15 +306,14 @@ var jsPanel;
308306
},
309307

310308
calcVerticalOffset: function (panel) {
311-
return Math.floor(panel.offset().top - $(window).scrollTop());
309+
return Math.floor(panel.offset().top - window.scrollY);
312310
},
313311

314312
// closes a jsPanel and removes it from the DOM
315313
close: function (panel) {
316314
// get parent-element of jsPanel
317315
var context = panel.parent(),
318-
panelID = panel.attr('id'),
319-
ind, hints;
316+
panelID = panel.attr('id');
320317
panel.trigger('jspanelbeforeclose', panelID);
321318
// delete childpanels ...
322319
this.closeChildpanels(panel);
@@ -333,17 +330,15 @@ var jsPanel;
333330
}
334331
// reposition minimized panels
335332
this.reposMinimized(this.widthForMinimized);
336-
// update arrays with hints
333+
// reposition hints
337334
if (panel.option.paneltype.type === 'hint') {
338-
hints = [jsPanel.hintsTc, jsPanel.hintsTl, jsPanel.hintsTr];
339-
hints.forEach(function(arrayItem){
340-
ind = arrayItem.indexOf(panelID);
341-
if (ind !== -1) {
342-
arrayItem.splice(ind, 1);
343-
// reposition hints
344-
jsPanel.reposHints(arrayItem, panel.parentElmtTagname);
345-
}
346-
});
335+
if (panel.hasClass("jsPanel-hint-tl")) {
336+
jsPanel.reposHints("jsPanel-hint-tl", panel.parentElmtTagname);
337+
} else if (panel.hasClass("jsPanel-hint-tc")) {
338+
jsPanel.reposHints("jsPanel-hint-tc", panel.parentElmtTagname);
339+
} else if (panel.hasClass("jsPanel-hint-tr")) {
340+
jsPanel.reposHints("jsPanel-hint-tr", panel.parentElmtTagname);
341+
}
347342
}
348343
return context;
349344
},
@@ -508,8 +503,8 @@ var jsPanel;
508503
elmtPosition = $(elmt).position();
509504
if (elmtStatus === "minimized") {
510505
if (panelParent.toLowerCase() === "body") {
511-
elmtTop = $(elmt).data("paneltop") - $(window).scrollTop() + "px";
512-
elmtLeft = $(elmt).data("panelleft") - $(window).scrollLeft() + "px";
506+
elmtTop = $(elmt).data("paneltop") - window.scrollY + "px";
507+
elmtLeft = $(elmt).data("panelleft") - window.scrollX + "px";
513508
} else {
514509
elmtTop = $(elmt).data("paneltop") + "px";
515510
elmtLeft = $(elmt).data("panelleft") + "px";
@@ -518,8 +513,8 @@ var jsPanel;
518513
elmtHeight = $(elmt).data("panelheight") + "px";
519514
} else {
520515
if (panelParent.toLowerCase() === "body") {
521-
elmtTop = Math.floor(elmtOffset.top - $(window).scrollTop()) + "px";
522-
elmtLeft = Math.floor(elmtOffset.left - $(window).scrollLeft()) + "px";
516+
elmtTop = Math.floor(elmtOffset.top - window.scrollY) + "px";
517+
elmtLeft = Math.floor(elmtOffset.left - window.scrollX) + "px";
523518
} else {
524519
elmtTop = Math.floor(elmtPosition.top) + "px";
525520
elmtLeft = Math.floor(elmtPosition.left) + "px";
@@ -598,9 +593,9 @@ var jsPanel;
598593

599594
// maintains panel position relative to window on scroll of page
600595
fixPosition: function (panel) {
601-
var jspaneldiff = panel.offset().top - $(window).scrollTop();
596+
var jspaneldiff = panel.offset().top - window.scrollY;
602597
panel.jsPanelfixPos = function () {
603-
panel.css('top', $(window).scrollTop() + jspaneldiff + 'px');
598+
panel.css('top', window.scrollY + jspaneldiff + 'px');
604599
};
605600
$(window).on('scroll', panel.jsPanelfixPos);
606601
},
@@ -616,9 +611,9 @@ var jsPanel;
616611
if(!selector || selector === "body") {
617612
// panel margins relative to browser viewport
618613
off = panel.offset();
619-
mR = winWidth - off.left - panelWidth + $(window).scrollLeft();
614+
mR = winWidth - off.left - panelWidth + window.scrollX;
620615
mL = winWidth - panelWidth - mR;
621-
mB = winHeight - off.top - panelHeight + $(window).scrollTop();
616+
mB = winHeight - off.top - panelHeight + window.scrollY;
622617
mT = winHeight - panelHeight - mB;
623618
} else {
624619
// panel margins relative to element matching selector "selector"
@@ -659,14 +654,14 @@ var jsPanel;
659654
// calculates option.position for hints using 'top left', 'top center' or 'top right'
660655
hintTop: function (hintGroup) {
661656
var hintH = 0;
662-
hintGroup.forEach(function(item){
663-
hintH += $('#' + item).outerHeight(true);
657+
$("." + hintGroup).each(function(){
658+
hintH += $(this).outerHeight(true);
664659
});
665-
if (hintGroup === this.hintsTr) {
660+
if (hintGroup === "jsPanel-hint-tr") {
666661
return {top: hintH, right: 0};
667-
} else if (hintGroup === this.hintsTl) {
662+
} else if (hintGroup === "jsPanel-hint-tl") {
668663
return {top: hintH, left: 0};
669-
} else if (hintGroup === this.hintsTc) {
664+
} else if (hintGroup === "jsPanel-hint-tc") {
670665
return {top: hintH, left: 'center'};
671666
}
672667
return {top: 0, left: 0};
@@ -894,7 +889,7 @@ var jsPanel;
894889
}
895890
// correction for panels maximized in body after page was scrolled
896891
if (panel.parentElmtTagname === 'body') {
897-
panelTop = $(window).scrollTop() + panel.verticalOffset + 'px';
892+
panelTop = window.scrollY + panel.verticalOffset + 'px';
898893
} else {
899894
panelTop = panel.option.position.top;
900895
}
@@ -941,27 +936,26 @@ var jsPanel;
941936

942937
// reposition hint upon closing
943938
reposHints: function (hintGroup, jsPtagname) {
944-
var hintH, elmt;
939+
var hintH;
945940
if (jsPtagname === 'body') {
946-
hintH = $(window).scrollTop();
941+
hintH = window.scrollY;
947942
} else {
948943
hintH = 0;
949944
}
950-
hintGroup.forEach(function(item){
951-
elmt = $('#' + item);
952-
elmt.animate({
945+
$("." + hintGroup).each(function(){
946+
$(this).animate({
953947
top: hintH + 'px'
954948
});
955-
hintH += elmt.outerHeight(true);
949+
hintH += $(this).outerHeight(true);
956950
});
957951
},
958952

959953
// reposition hints on window scroll
960954
reposHintsScroll: function(panel) {
961-
var dif = panel.offset().top - $(window).scrollTop();
955+
var dif = panel.offset().top - window.scrollY;
962956
// with window.onscroll only the last added hint would stay in position
963957
$(window).scroll(function () {
964-
panel.css('top', $(window).scrollTop() + dif + 'px');
958+
panel.css('top', window.scrollY + dif + 'px');
965959
});
966960
},
967961

@@ -1560,7 +1554,13 @@ var jsPanel;
15601554
// jsPanel close
15611555
$('.jsPanel-btn-close', jsP).on('click', function (e) {
15621556
e.preventDefault();
1563-
jsPanel.close(jsP, jsP.parentElmtTagname);
1557+
if (!jsP.option.controls.confirmClose) {
1558+
jsPanel.close(jsP, jsP.parentElmtTagname);
1559+
} else {
1560+
if (window.confirm(jsP.option.controls.confirmClose) === true) {
1561+
jsPanel.close(jsP, jsP.parentElmtTagname);
1562+
}
1563+
}
15641564
});
15651565

15661566
// jsPanel minimize
@@ -1684,22 +1684,20 @@ var jsPanel;
16841684
});
16851685
// set option.position for hints using 'top left', 'top center' or 'top right'
16861686
if (jsP.option.position.top === '0' && jsP.option.position.left === 'center') {
1687-
// Schleife über alle hints in jsPanel.hintsTc, Höhen aufsummieren und als top für option.position verwenden
1688-
if (jsPanel.hintsTc.length > 0) {
1689-
jsP.option.position = jsPanel.hintTop(jsPanel.hintsTc);
1687+
jsP.addClass("jsPanel-hint-tc");
1688+
if ($(".jsPanel-hint-tc").length > 0) {
1689+
jsP.option.position = jsPanel.hintTop("jsPanel-hint-tc");
16901690
}
1691-
// populate array with hints
1692-
jsPanel.hintsTc.push(jsP.attr('id'));
16931691
} else if (jsP.option.position.top === '0' && jsP.option.position.left === '0') {
1694-
if (jsPanel.hintsTl.length > 0) {
1695-
jsP.option.position = jsPanel.hintTop(jsPanel.hintsTl);
1692+
jsP.addClass("jsPanel-hint-tl");
1693+
if ($(".jsPanel-hint-tl").length > 0) {
1694+
jsP.option.position = jsPanel.hintTop("jsPanel-hint-tl");
16961695
}
1697-
jsPanel.hintsTl.push(jsP.attr('id'));
16981696
} else if (jsP.option.position.top === '0' && jsP.option.position.right === '0') {
1699-
if (jsPanel.hintsTr.length > 0) {
1700-
jsP.option.position = jsPanel.hintTop(jsPanel.hintsTr);
1697+
jsP.addClass("jsPanel-hint-tr");
1698+
if ($(".jsPanel-hint-tr").length > 0) {
1699+
jsP.option.position = jsPanel.hintTop("jsPanel-hint-tr");
17011700
}
1702-
jsPanel.hintsTr.push(jsP.attr('id'));
17031701
}
17041702
}
17051703

@@ -1933,7 +1931,6 @@ var jsPanel;
19331931
};
19341932
}
19351933
});
1936-
19371934
} else {
19381935
// does not work with certain combinations of type of animation and positioning
19391936
jsP.css({
@@ -1973,7 +1970,6 @@ var jsPanel;
19731970
/* resizestart & resizestop & dragstop callbacks ------------------------------------------------------------ */
19741971
if (!jsP.option.paneltype || jsP.option.paneltype.mode !== 'default') {
19751972
// not needed for modals, hints and tooltips
1976-
19771973
$(jsP).on("resizestart", function () {
19781974
$("iframe", jsP.content).css("display", "none"); // on test
19791975
});
@@ -2105,6 +2101,7 @@ var jsPanel;
21052101
buttons: true,
21062102
iconfont: 'jsglyph',
21072103
close: false,
2104+
confirmClose: false,
21082105
maximize: false,
21092106
minimize: false,
21102107
normalize: false,

0 commit comments

Comments
 (0)