",{id: "mainframe"}))
)
window.onresize = function(event) {
$("div.t_main").css("height", (event.target.innerHeight)+"px");
$("html").css("height", (event.target.innerHeight)+"px");
};
$(window).resize();
}
export function loadCSS(url) {
if (document.createStyleSheet)
{
document.createStyleSheet(url);
}
else
{
$('
').appendTo('head');
}
}
function xmenuToggle(el) {
$(document).unbind('keyup', xmenuHide);
$("body").unbind('click', xmenuHide);
let xmenu = $(".xmenu_hidable");
if (xmenu.hasClass("xmenu_hidden")) {
xmenu.removeClass("xmenu_hidden");
$(document).bind('keyup', xmenuHide);
$("body").bind('contextmenu click', xmenuHide);
} else {
xmenuHide();
}
return false;
}
export function xmenuHide(el) {
if (el != undefined && el.type=='keyup') {
if(el.keyCode !== 27) {
return;
}
}
if (el != undefined && el.type=='click') {
if($(el.target).closest("div.t_navy_main").length>0) {
return;
}
}
$(document).unbind('keyup', xmenuHide);
$("body").unbind('click', xmenuHide);
let xmenu = $(".xmenu_hidable");
if (!xmenu.hasClass("xmenu_hidden")) {
xmenu.addClass("xmenu_hidden");
}
}
export function contextMenuOpen(event, itemsList, title) {
$("body").unbind('contextmenu click', contextMenuClose);
let selText = getSelectionText();
$("div#contextMenu").empty();
if (isset(title)) { $("
",{class: "title cmTitle", text: title}).appendTo("div#contextMenu"); }
let items=$("
",{class: "items"}).appendTo("div#contextMenu");
if (isset(selText)) {
$("
",{class: "item", text: langPack.core.iface.contextMenuCopySelected}).appendTo(items).click(function() {
copySelText(selText);
contextMenuClose();
});
}
$.each(itemsList, function(key,val) {
let item=$("
",{class: "item"});
if (isset(val.href)) {
$("",{href: val.href, html: val.title}).appendTo(item);
item.click(function() {
window.location.href=val.href;
contextMenuClose();
return false;
})
} else {
item.html(val.title);
if (isset(val.onClick)) {
item.click(function(el) { val.onClick(el); contextMenuClose();return false;});
}
}
item.appendTo(items);
});
$("div#contextMenu").show();
if (($(window).scrollLeft()+event.clientX+350) < ($(window).scrollLeft()+$(window).width())) {
$("div#contextMenu").offset({top:$(window).scrollTop()+event.clientY, left:$(window).scrollLeft()+event.clientX});
} else {
$("div#contextMenu").offset({top:$(window).scrollTop()+event.clientY, left:$(window).scrollLeft()+event.clientX-338});
}
$("body").bind('contextmenu click', contextMenuClose);
$(document).bind('keyup', contextMenuClose);
}
export function contextMenuClose(el) {
if (el != undefined && $(el.target).closest("#contextMenu").length > 0) {
return;
}
if (el != undefined && el.type=='keyup') {
if(el.keyCode !== 27) {
return;
}
}
$(document).unbind('keyup', contextMenuClose);
$("body").unbind('contextmenu click', contextMenuClose);
$("div#contextMenu").hide().unbind('contextmenu click');
}
export function setLocation(curLoc){
try {
history.pushState(null, null, curLoc);
return;
} catch(e) {}
location.hash = '#' + curLoc;
}
export function xClick(ref) {
return smartClick(ref);
};
Number.prototype.pad = function(size) {
var s = String(this);
while (s.length < (size || 2)) {s = "0" + s;}
return s;
};
(function($){
$.fn.extend({
foxPager: function(cmd, value) {
if (cmd===undefined) { cmd = {}; }
var mode = undefined;
if (typeof(cmd) == 'object' && value===undefined) {
// initialize
mode='init';
var defaults={
page: undefined,
pages: 0,
prefix: '',
callback: function() {},
}
var options = $.extend(defaults, cmd);
if (!options.page) {
options.page = (!sessionStorage.getItem(options.prefix+"pager") || sessionStorage.getItem(options.prefix+"pager").replace(/[^0-9]/g,'')=='')?1:sessionStorage.getItem(options.prefix+"pager");
}
if (options.page > options.pages && options.pages >0) { options.page = options.pages; }
sessionStorage.setItem(options.prefix+"pager", options.page);
} else {
switch (cmd) {
case "clear":
mode='remove';
break;
case "getPage":
mode='getPage';
break;
case "update":
mode = 'update';
if (value.page > value.pages) { value.page = value.pages; }
var options = value;
break;
default:
return;
}
}
if (mode=='getPage') {
return sessionStorage.getItem($(this).prop('foxPager_prefix')+"pager");
}
this.each(function(rid,ref) {
if (mode!='remove') {
if (options.page!==undefined) {
$(ref).prop('foxPager_page', options.page);
} else {
options.page = $(ref).prop('foxPager_page');
}
if (options.pages!==undefined) {
$(ref).prop('foxPager_pages', options.pages);
} else {
options.page = $(ref).prop('foxPager_pages');
}
if (mode =='init') {
$(ref).empty();
$(ref).prop('foxPager_prefix', options.prefix);
$(ref).addClass('foxPager_'+options.prefix);
$(ref).addClass('foxPagerMain');
$("",{class: "fas fa-angle-double-left", css: { padding: "0 10 0 10", cursor: 'hand' }}).click(function() {
options.page = parseInt($(ref).prop('foxPager_page'));
options.pages = parseInt($(ref).prop('foxPager_pages'));
if (options.pages==0) { return; }
if (options.page > 1) {
options.page=1;
sessionStorage.setItem(options.prefix+"pager", options.page);
$(".foxPager_"+options.prefix).find(".foxPager_label").text("Стр: "+options.page+" из "+options.pages);
$(".foxPager_"+options.prefix).prop('foxPager_page', options.page);
options.callback({prefix: options.prefix, page: options.page});
}
})
.appendTo(ref);
$("",{class: "fas fa-angle-left", css: { padding: "0 10 0 10", cursor: 'hand'} }).click(function() {
options.page = parseInt($(ref).prop('foxPager_page'));
options.pages = parseInt($(ref).prop('foxPager_pages'));
if (options.pages==0) { return; }
if (options.page > 1) {
options.page=options.page-1;
sessionStorage.setItem(options.prefix+"pager", options.page);
$(".foxPager_"+options.prefix).find(".foxPager_label").text("Стр: "+options.page+" из "+options.pages);
$(".foxPager_"+options.prefix).prop('foxPager_page', options.page);
options.callback({prefix: options.prefix, page: options.page});
}
}).appendTo(ref);
$("",{text: "Стр: "+options.page+" из "+options.pages, class: 'foxPager_label', css: { padding: "0 10 0 10" }}).appendTo(ref);
$("",{class: "fas fa-angle-right", css: { padding: "0 10 0 10", cursor: 'hand' } }).click(function() {
options.page = parseInt($(ref).prop('foxPager_page'));
options.pages = parseInt($(ref).prop('foxPager_pages'));
if (options.pages==0) { return; }
if (options.page < options.pages) {
options.page=options.page+1;
sessionStorage.setItem(options.prefix+"pager", options.page);
$(".foxPager_"+options.prefix).find(".foxPager_label").text("Стр: "+options.page+" из "+options.pages);
$(".foxPager_"+options.prefix).prop('foxPager_page', options.page);
options.callback({prefix: options.prefix, page: options.page});
}
}).appendTo(ref);
$("",{class: "fas fa-angle-double-right", css: { padding: "0 10 0 10", cursor: 'hand' } }).click(function() {
options.page = parseInt($(ref).prop('foxPager_page'));
options.pages = parseInt($(ref).prop('foxPager_pages'));
if (options.pages==0) { return; }
if (options.page != options.pages) {
options.page=options.pages;
sessionStorage.setItem(options.prefix+"pager", options.page);
$(".foxPager_"+options.prefix).find(".foxPager_label").text("Стр: "+options.page+" из "+options.pages);
$(".foxPager_"+options.prefix).prop('foxPager_page', options.page);
options.callback({prefix: options.prefix, page: options.page});
}
}).appendTo(ref);
} else if (mode=='update') {
let prefix = $(ref).prop("foxPager_prefix");
sessionStorage.setItem(prefix+"pager", options.page);
$(ref).prop('foxPager_page',options.page);
$(ref).prop('foxPager_pages',options.pages);
$(ref).find(".foxPager_label").text("Стр: "+options.page+" из "+options.pages);
return;
}
} else {
$(ref).empty();
}
});
},
foxClick: function(href) {
if (typeof(href) != 'object') {
href={href: href};
}
if (href.external==true) {
this.click(function() {
if (getSelectionText()) { return; }
document.location.href=href.href; return false;
});
} else {
this.prop("href",href.href).click(function(ref) {
if (getSelectionText()) { return; }
xClick(ref);
});
}
this.addClass("clickable");
$.each(this.find("td"),function(key,val) {
if($(val).children().length == 0) {
let item=$("",{href: href.href, html: $(val).html() });
$(val).empty().append(item);
}
});
return this;
},
onEnter: function(callback) {
if (typeof(callback)=="function") {
this.on('keyup', function (e) {
if (e.key === 'Enter' || e.keyCode === 13) {
callback(this);
}
})
}
}
})})(jQuery)