');
// append tooltip (jsPanel) to the wrapper div
jsP.parentElmt.parent().append(jsP);
if (jsP.option.paneltype.mode === 'semisticky') {
jsP.hover(
function () {
$.noop();
},
function () {
jsPanel.close(jsP);
}
);
} else if (jsP.option.paneltype.mode === 'sticky') {
$.noop();
} else {
jsP.option.controls.buttons = 'none';
// tooltip will be removed whenever mouse leaves trigger
jsP.parentElmt.off('mouseout'); // to prevent mouseout from firing several times
jsP.parentElmt.mouseout(function () {
jsPanel.close(jsP);
});
}
}
// corners
jsP.css('overflow', 'visible');
if (jsP.option.paneltype.cornerBG) {
var corner = $("
"),
cornerLoc = "jsPanel-corner-" + jsP.option.paneltype.position,
cornerPos,
cornerOX = parseInt(jsP.option.paneltype.cornerOX) || 0,
cornerOY = parseInt(jsP.option.paneltype.cornerOY) || 0,
cornerBG = jsP.option.paneltype.cornerBG;
if (jsP.option.paneltype.position !== "bottom") {
corner.addClass("jsPanel-corner " + cornerLoc).appendTo(jsP);
} else {
corner.addClass("jsPanel-corner " + cornerLoc).prependTo(jsP);
}
if (jsP.option.paneltype.position === "top") {
cornerPos = parseInt(jsP.option.size.width) / 2 - 12 + (cornerOX) + "px";
corner.css({ borderTopColor: cornerBG, left: cornerPos });
} else if (jsP.option.paneltype.position === "right") {
cornerPos = parseInt(jsP.option.size.height) / 2 - 12 + (cornerOY) + "px";
corner.css({ borderRightColor: cornerBG, left: "-22px", top: cornerPos });
} else if (jsP.option.paneltype.position === "bottom") {
cornerPos = parseInt(jsP.option.size.width) / 2 - 12 + (cornerOX) + "px";
corner.css({ borderBottomColor: cornerBG, left: cornerPos, top: "-22px" });
} else if (jsP.option.paneltype.position === "left") {
cornerPos = parseInt(jsP.option.size.height) / 2 - 12 + (cornerOY) + "px";
corner.css({ borderLeftColor: cornerBG, left: jsP.option.size.width, top: cornerPos });
}
}
} else if (jsP.option.paneltype.type === 'hint') {
jsPanel.setHintDefaults(jsP);
// bind callback for close button
$('.jsPanel-hint-close', jsP).on('click', jsP, function (event) {
event.data.close(jsP);
});
// set option.position for hints using 'top left', 'top center' or 'top right'
if (jsP.option.position.top === '0' && jsP.option.position.left === 'center') {
jsP.addClass("jsPanel-hint-tc");
if ($(".jsPanel-hint-tc").length > 0) {
jsP.option.position = jsPanel.hintTop("jsPanel-hint-tc");
}
} else if (jsP.option.position.top === '0' && jsP.option.position.left === '0') {
jsP.addClass("jsPanel-hint-tl");
if ($(".jsPanel-hint-tl").length > 0) {
jsP.option.position = jsPanel.hintTop("jsPanel-hint-tl");
}
} else if (jsP.option.position.top === '0' && jsP.option.position.right === '0') {
jsP.addClass("jsPanel-hint-tr");
if ($(".jsPanel-hint-tr").length > 0) {
jsP.option.position = jsPanel.hintTop("jsPanel-hint-tr");
}
}
}
/* option.selector - append jsPanel only to the first object in selector ------------------------------------ */
jsP.data("selector", jsP.option.selector); // needed for exportPanels()
if (jsP.option.paneltype.type !== 'tooltip') {
jsP.appendTo(jsP.parentElmt);
}
if (jsP.option.paneltype.type === 'modal') {
jsP.css('zIndex', 10001);
if (jsP.option.paneltype.mode === 'extended') {
$('.jsPanel-backdrop').css('z-index', '9998');
}
} else {
if (!jsP.hasClass("jsPanel-modal")) {
jsP.css('z-index', jsPanel.setZi(jsP));
}
}
/* option.bootstrap & option.theme -------------------------------------------------------------------------- */
if (jsP.option.bootstrap) {
// check whether a bootstrap compatible theme is used and set option.theme accordingly
jsP.option.theme = jsPanel.isBootstrapTheme(jsP.option.bootstrap);
jsP.option.controls.iconfont = 'bootstrap';
jsP.alterClass('jsPanel-theme-*', 'panel panel-' + jsP.option.theme);
jsP.header.alterClass('jsPanel-theme-*', 'panel-heading');
jsP.header.title.addClass('panel-title');
jsP.content.alterClass('jsPanel-theme-*', 'panel-body');
jsP.footer.addClass('panel-footer');
// fix css problems for panels nested in other bootstrap panels
jsP.header.title.css('color', function () {
return jsP.header.css('color');
});
jsP.content.css('border-top-color', function () {
return jsP.header.css('border-top-color');
});
} else {
// activate normal non bootstrap themes
var components = [jsP, jsP.header, jsP.content, jsP.footer];
components.forEach(function (elmt) {
$(elmt).alterClass('jsPanel-theme-*', 'jsPanel-theme-' + jsP.option.theme);
});
}
/* option.removeHeader; option.controls (buttons in header right) ------------------------------------------- */
if (jsP.option.removeHeader) {
jsP.header.remove();
} else {
jsPanel.configControls(jsP);
}
/* insert iconfonts if option.iconfont set (default is "jsglyph") */
if (jsP.option.controls.iconfont) {
jsPanel.configIconfont(jsP);
} else {
// if option.controls.iconfont === false restore old icon sprite
$('.jsPanel-btn-close, .jsPanel-btn-max, .jsPanel-btn-norm, .jsPanel-btn-min, .jsPanel-btn-small, .jsPanel-btn-smallrev', jsP.header.controls).empty();
}
/* option.toolbarHeader | default: false -------------------------------------------------------------------- */
if (jsP.option.toolbarHeader && jsP.option.removeHeader === false) {
if (typeof jsP.option.toolbarHeader === 'string') {
jsP.header.toolbar.append(jsP.option.toolbarHeader);
} else if ($.isFunction(jsP.option.toolbarHeader)) {
jsP.header.toolbar.append(jsP.option.toolbarHeader(jsP.header));
} else if ($.isArray(jsP.option.toolbarHeader)) {
jsPanel.configToolbar(jsP.option.toolbarHeader, jsP.header.toolbar, jsP);
}
// give toolbar the same font-family as title
jsP.header.toolbar.css("font-family", jsP.header.title.css("font-family"));
}
/* option.toolbarFooter | default: false -------------------------------------------------------------------- */
if (jsP.option.toolbarFooter) {
jsP.footer.css({
display: 'block'
});
if (typeof jsP.option.toolbarFooter === 'string') {
jsP.footer.append(jsP.option.toolbarFooter);
} else if ($.isFunction(jsP.option.toolbarFooter)) {
jsP.footer.append(jsP.option.toolbarFooter(jsP.footer));
} else if ($.isArray(jsP.option.toolbarFooter)) {
jsPanel.configToolbar(jsP.option.toolbarFooter, jsP.footer, jsP);
}
// give toolbar the same font-family as title
jsP.footer.css("font-family", jsP.header.title.css("font-family"));
}
/* option.rtl | default: false ------------------------------------------------------------------------------ */
if (jsP.option.rtl.rtl === true) {
jsPanel.setRTL(jsP, jsP.option.rtl.lang);
}
/* option.overflow | default: 'hidden' --------------------------------------------------------------------- */
if (typeof jsP.option.overflow === 'string') {
jsP.content.css('overflow', jsP.option.overflow);
} else if ($.isPlainObject(jsP.option.overflow)) {
jsP.content.css({
'overflow-y': jsP.option.overflow.vertical,
'overflow-x': jsP.option.overflow.horizontal
});
}
/* option.draggable ----------------------------------------------------------------------------------------- */
if ($.isPlainObject(jsP.option.draggable)) {
// if jsPanel is childpanel
if (jsP.parent().hasClass('jsPanel-content')) {
jsP.option.draggable.containment = 'parent';
}
// merge draggable settings and apply
jsP.option.customdraggable = $.extend(true, {}, $.jsPanel.defaults.draggable, jsP.option.draggable);
jsP.draggable(jsP.option.customdraggable);
} else if (jsP.option.draggable === 'disabled') {
// reset cursor, draggable deactivated
$('.jsPanel-title, .jsPanel-ftr', jsP).css('cursor', 'inherit');
// jquery ui draggable initialize disabled to allow to query status
jsP.draggable({ disabled: true });
}
/* option.resizable ----------------------------------------------------------------------------------------- */
if ($.isPlainObject(jsP.option.resizable)) {
jsP.option.customresizable = $.extend(true, {}, $.jsPanel.defaults.resizable, jsP.option.resizable);
jsP.resizable(jsP.option.customresizable);
} else if (jsP.option.resizable === 'disabled') {
// jquery ui resizable initialize disabled to allow to query status
jsP.resizable({ disabled: true });
$('.ui-icon-gripsmall-diagonal-se', jsP).css({ 'background-image': 'none', 'text-indent': -9999 });
$('.ui-resizable-handle', jsP).css({ 'cursor': 'inherit' });
}
/* option.content ------------------------------------------------------------------------------------------- */
// option.content can be any valid argument for jQuery.append()
if (jsP.option.content) {
jsP.content.append(jsP.option.content);
jsP.data("content", jsP.option.content);
}
/* option.load ---------------------------------------------------------------------------------------------- */
if ($.isPlainObject(jsP.option.load) && jsP.option.load.url) {
jsPanel.load(jsP);
}
/* option.ajax ---------------------------------------------------------------------------------------------- */
if ($.isPlainObject(jsP.option.ajax) && jsP.option.ajax.url) {
jsPanel.ajax(jsP);
}
/* option.size ---------------------------------------------------------------------------------------------- */
jsP.content.css({
width: jsP.option.size.width || 'auto',
height: jsP.option.size.height || 'auto'
});
// Important! limit title width; final adjustment follows later; otherwise title might be longer than panel width
jsP.header.title.css('width', jsP.content.width() - 90);
/* option.iframe -------------------------------------------------------------------------------------------- */
// implemented after option.size because option.size.width/height are either "auto" or pixel values already
if ($.isPlainObject(jsP.option.iframe) && (jsP.option.iframe.src || jsP.option.iframe.srcdoc)) {
jsPanel.iframe(jsP);
}
/* option.position ------------------------------------------------------------------------------------------ */
if (jsP.option.paneltype.type !== 'tooltip') {
// value "center" not allowed for option.position.bottom & option.position.right -> use top and/or left
// finally calculate & position the jsPanel
jsPanel.calcPanelposition(jsP);
}
/* option.addClass ------------------------------------------------------------------------------------------ */
if (typeof jsP.option.addClass.header === 'string') {
jsP.header.addClass(jsP.option.addClass.header);
}
if (typeof jsP.option.addClass.content === 'string') {
jsP.content.addClass(jsP.option.addClass.content);
}
if (typeof jsP.option.addClass.footer === 'string') {
jsP.footer.addClass(jsP.option.addClass.footer);
}
// handlers for doubleclicks -----------------------------------------------------------------------------------
// dblclicks disabled for normal modals, hints and tooltips
if (jsP.option.paneltype.mode !== "default") {
if (jsP.option.dblclicks) {
if (jsP.option.dblclicks.title) {
jsP.header.title.on('dblclick', function (e) {
e.preventDefault();
jsPanel.dblclickhelper(jsP.option.dblclicks.title, jsP);
});
}
if (jsP.option.dblclicks.content) {
jsP.content.on('dblclick', function (e) {
e.preventDefault();
jsPanel.dblclickhelper(jsP.option.dblclicks.content, jsP);
});
}
if (jsP.option.dblclicks.footer) {
jsP.footer.on('dblclick', function (e) {
e.preventDefault();
jsPanel.dblclickhelper(jsP.option.dblclicks.footer, jsP);
});
}
}
}
/* option.show ---------------------------------------------------------------------------------------------- */
if (!jsP.option.show) {
jsP.css({
display: 'block',
opacity: 1
});
$(jsP).trigger('jspanelloaded', jsP.attr('id'));
$(jsP).trigger('jspanelstatechange', jsP.attr('id'));
jsP.option.size = {
width: jsP.outerWidth(),
height: jsP.outerHeight()
};
} else if (jsP.option.show.indexOf(" ") === -1) {
// if no space is found in "jsP.option.show" -> function anwenden
jsP[jsP.option.show]({
done: function () {
// trigger custom event
$(jsP).trigger('jspanelloaded', jsP.attr('id'));
$(jsP).trigger('jspanelstatechange', jsP.attr('id'));
jsP.option.size = {
width: jsP.outerWidth(),
height: jsP.outerHeight()
};
}
});
} else {
// does not work with certain combinations of type of animation and positioning
jsP.css({
display: 'block',
opacity: 1
});
$(jsP).addClass(jsP.option.show);
$(jsP).trigger('jspanelloaded', jsP.attr('id'));
$(jsP).trigger('jspanelstatechange', jsP.attr('id'));
jsP.option.size = {
width: jsP.outerWidth(),
height: jsP.outerHeight()
};
}
/* needed if a maximized panel in body is normalized again -------------------------------------------------- */
// don't put this under $('body').on('jspanelloaded', function () { ... }
jsP.verticalOffset = jsPanel.calcVerticalOffset(jsP) || 0;
/* replace bottom/right values with corresponding top/left values if necessary ------------------------------ */
jsPanel.replaceCSSBottomRight(jsP);
/* option.title | needs to be late in the file! ------------------------------------------------------------- */
jsP.header.title.empty().prepend(jsP.option.title);
jsPanel.resizeTitle(jsP);
/* reposition hints while scrolling window, must be after normalization of position ------------------------- */
if (jsP.option.paneltype.type === 'hint') {
jsPanel.reposHintsScroll(jsP);
}
/* reposition jsPanel appended to body while scrolling window ----------------------------------------------- */
if (jsP.parentElmtTagname === 'body' && (jsP.option.paneltype.type !== 'tooltip' || jsP.option.paneltype.type !== 'hint')) {
jsPanel.fixPosition(jsP);
}
/* resizestart & resizestop & dragstop callbacks ------------------------------------------------------------ */
if (!jsP.option.paneltype || jsP.option.paneltype.mode !== 'default') {
// not needed for modals, hints and tooltips
$(jsP).on("resizestart", function () {
$("iframe", jsP.content).css("display", "none"); // on test
});
$(jsP).on("resize", function () {
// debugger;
// jquery ui resize event is also fired when panel is maximized or normalized (on request of Gareth Bult)
jsPanel.resizeContent(jsP);
jsPanel.resizeTitle(jsP);
});
$(jsP).on("resizestop", function () {
//alert('resized')
jsP.option.size = {
width: jsP.outerWidth(),
height: jsP.outerHeight()
};
if ($('.tools').length> 0) {
//nikita
if ($('#canvasDiv') != null) {
if (jsP.outerHeight() >= 435 && jsP.outerWidth() >= 650) {
// alert('resizestop')
$('#canvasDiv').css('height', jsP.outerHeight() - 85)
$('#canvasDiv').css('width', jsP.outerWidth() - 95)
$('#canvasDiv').css('overflow', 'scroll')
}
else {
$('#canvasDiv').css('height', jsP.outerHeight() - 110)
$('#canvasDiv').css('width', jsP.outerWidth() - 85)
$('#canvasDiv').css('overflow', 'scroll')
}
}
}
//nikita
// $('#leftToolBar').css('height', jsP.outerWidth())
jsPanel.updateStateProps(jsP, "normalized");
$(jsP).trigger('jspanelnormalized', jsP.attr('id'));
$(jsP).trigger('jspanelstatechange', jsP.attr('id'));
// controls und title zurücksetzen
jsPanel.hideControls(".jsPanel-btn-norm, .jsPanel-btn-smallrev", jsP);
$("iframe", jsP.content).css("display", "block"); // on test
});
$(jsP).on("dragstart", function () {
// alert("dragstart")
// debugger;
// remove window.scroll handler, is added again on dragstop
$(window).off('scroll', jsP.jsPanelfixPos);
if (jsP.option.paneltype.mode === 'extended') {
jsP.css('z-index', '1');
}
});
$(jsP).on("dragstop", function () {
// alert("dragstop")
// debugger;
jsP.option.position = {
top: jsP.css('top'),
left: jsP.css('left')
};
jsP.verticalOffset = jsPanel.calcVerticalOffset(jsP) || 0;
if (jsP.parentElmtTagname === 'body') {
jsPanel.fixPosition(jsP);
}
});
$(jsP).on("jspanelminimized", function () {
jsPanel.hideControls(".jsPanel-btn-min, .jsPanel-btn-small, .jsPanel-btn-smallrev, .jsPanel-btn-hide", jsP);
jsPanel.updateStateProps(jsP, "minimized");
$(window).off('scroll', jsP.jsPanelfixPos);
});
$(jsP).on("jspanelmaximized", function () {
// debugger;
jsPanel.resizeContent(jsP);
jsPanel.resizeTitle(jsP);
jsPanel.hideControls(".jsPanel-btn-max, .jsPanel-btn-smallrev", jsP);
jsPanel.updateStateProps(jsP, "maximized");
// additionally trigger the jQuery UI resize event (on request of Gareth Bult)
jsP.trigger("resize");
});
$(jsP).on("jspanelnormalized", function () {
jsPanel.hideControls(".jsPanel-btn-norm, .jsPanel-btn-smallrev", jsP);
jsPanel.resizeTitle(jsP);
jsPanel.resizeContent(jsP);
jsPanel.updateStateProps(jsP, "normalized");
// additionally trigger the jQuery UI resize event (on request of Gareth Bult)
jsP.trigger("resize");
});
}
/* option.autoclose | default: false --------------------------------------- */
if (typeof jsP.option.autoclose === 'number' && jsP.option.autoclose > 0) {
jsPanel.autoclose(jsP);
}
/* tooltip corrections ----------------------------------------------------- */
if (jsP.option.paneltype.type === "tooltip" && (jsP.option.paneltype.position === "top" || jsP.option.paneltype.position === "bottom")) {
jsPanel.shiftTooltipHorizontal(jsP, jsP.option.paneltype.shiftwithin);
} else if (jsP.option.paneltype.position === "left" || jsP.option.paneltype.position === "right") {
jsPanel.shiftTooltipVertical(jsP, jsP.option.paneltype.shiftwithin);
}
/* option.panelstatus --------------------------------------------------------------------------------------- */
if (jsP.option.panelstatus) {
switch (jsP.option.panelstatus) {
case "minimized":
jsPanel.minimize(jsP);
break;
case "maximized":
jsPanel.maximize(jsP);
break;
case ("smallified"):
jsPanel.smallify(jsP);
break;
case ("smallifiedMax"):
jsPanel.maximize(jsP);
jsPanel.smallify(jsP);
break;
}
} else {
jsPanel.updateStateProps(jsP, "normalized");
}
/* jsP.option.callback --------------------------------------------------------- */
if ($.isFunction(jsP.option.callback)) {
jsP.option.callback.call(jsP, jsP);
} else if ($.isArray(jsP.option.callback)) {
jsP.option.callback.forEach(function (item) {
if ($.isFunction(item)) {
item.call(jsP, jsP);
}
});
}
return jsP;
};
/* jsPanel.defaults */
$.jsPanel.defaults = {
"addClass": {
header: false,
content: false,
footer: false
},
"ajax": {
autoload: true
},
"autoclose": false,
"bootstrap": false,
"callback": undefined,
"content": false,
"controls": {
buttons: true,
iconfont: 'jsglyph',
close: false,
confirmClose: false,
maximize: false,
minimize: false,
normalize: false,
smallify: false,
maxtoScreen: false
},
"custom": false,
"dblclicks": false,
"draggable": {
handle: 'div.jsPanel-hdr, div.jsPanel-ftr',
stack: '.jsPanel',
opacity: 0.7
},
"id": function () {
jsPanel.ID += 1;
return 'jsPanel-' + jsPanel.ID;
},
"iframe": false,
"load": false,
"maximizedMargin": {
top: 5,
right: 5,
bottom: 5,
left: 5
},
"offset": {
top: 0,
left: 0
},
"onbeforeclose": false,
"onbeforemaximize": false,
"onbeforeminimize": false,
"onbeforenormalize": false,
"onclosed": false,
"oncmaximized": false,
"onminimized": false,
"onnormalized": false,
"overflow": 'hidden',
"panelstatus": false,
"paneltype": false,
"position": 'auto',
"removeHeader": false,
"resizable": {
handles: 'n, e, s, w, ne, se, sw, nw',
autoHide: false,
minWidth: 150,
minHeight: 93
},
"rtl": false,
"selector": 'body',
"show": 'fadeIn',
"size": {
width: '400px',
height: '222px'
},
"template": false,
"theme": 'default',
"title": 'jsPanel',
"toolbarFooter": false,
"toolbarHeader": false,
"currentController": '',
"parentSlug": ''
};
/*
* jQuery alterClass plugin
* Remove element classes with wildcard matching. Optionally add classes:
* $( '#foo' ).alterClass( 'foo-* bar-*', 'foobar' )
* Copyright (c) 2011 Pete Boere (the-echoplex.net)
* Free under terms of the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
$.fn.alterClass = function (removals, additions) {
var self = this,
patt;
if (removals.indexOf('*') === -1) {
// Use native jQuery methods if there is no wildcard matching
self.removeClass(removals);
return !additions ? self : self.addClass(additions);
}
patt = new RegExp('\\s' +
removals.replace(/\*/g, '[A-Za-z0-9-_]+').split(' ').join('\\s|\\s') +
'\\s', 'g');
self.each(function (i, it) {
var cn = ' ' + it.className + ' ';
while (patt.test(cn)) {
cn = cn.replace(patt, ' ');
}
it.className = $.trim(cn);
});
return !additions ? self : self.addClass(additions);
};
/* body click handler: remove all tooltips on click in body except click is inside tooltip */
$('body').click(function (e) {
var pID,
isTT = $(e.target).closest('.jsPanel-tt').length;
if (isTT < 1) {
$('.jsPanel-tt').each(function () {
pID = $(this).attr('id');
// if present remove tooltip wrapper and than remove tooltip
$('#' + pID).unwrap().remove();
$('body').trigger('jspanelclosed', pID);
});
}
});
}(jQuery));
/*
:: Number.isInteger() polyfill ::
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger
*/
if (!Number.isInteger) {
Number.isInteger = function isInteger(nVal) {
"use strict";
return typeof nVal === 'number' && isFinite(nVal) && nVal > -9007199254740992 && nVal < 9007199254740992 && Math.floor(nVal) === nVal;
};
}