//**************************************************************************************
//* /home3/yhekobro/public_html/ptz-beton.ru/js/libs/common/jquery.sticky.js
//**************************************************************************************
// Sticky Plugin v1.0.0 for jQuery
// =============
// Author: Anthony Garand
// Improvements by German M. Bravo (Kronuz) and Ruud Kamphuis (ruudk)
// Improvements by Leonardo C. Daronco (daronco)
// Created: 2/14/2011
// Date: 2/12/2012
// Website: http://labs.anthonygarand.com/sticky
// Description: Makes an element on the page stick on the screen as you scroll
// It will only set the 'top' and 'position' of your element, you
// might need to adjust the width in some cases.
(function($) {
var defaults = {
topSpacing: 0,
bottomSpacing: 0,
className: 'is-sticky',
wrapperClassName: 'sticky-wrapper',
center: false,
getWidthFrom: '',
responsiveWidth: false
},
$window = $(window),
$document = $(document),
sticked = [],
windowHeight = $window.height(),
scroller = function() {
var scrollTop = $window.scrollTop(),
documentHeight = $document.height(),
dwh = documentHeight - windowHeight,
extra = (scrollTop > dwh) ? dwh - scrollTop : 0;
for (var i = 0; i < sticked.length; i++) {
var s = sticked[i],
elementTop = s.stickyWrapper.offset().top,
etse = elementTop - s.topSpacing - extra;
if (scrollTop <= etse) {
if (s.currentTop !== null) {
s.stickyElement
.css('position', '')
.css('top', '');
s.stickyElement.trigger('sticky-end', [s]).parent().removeClass(s.className);
s.currentTop = null;
}
}
else {
var newTop = documentHeight - s.stickyElement.outerHeight()
- s.topSpacing - s.bottomSpacing - scrollTop - extra;
if (newTop < 0) {
newTop = newTop + s.topSpacing;
} else {
newTop = s.topSpacing;
}
if (s.currentTop != newTop) {
s.stickyElement
.css('position', 'fixed')
.css('top', newTop);
if (typeof s.getWidthFrom !== 'undefined') {
s.stickyElement.css('width', $(s.getWidthFrom).width());
}
s.stickyElement.trigger('sticky-start', [s]).parent().addClass(s.className);
s.currentTop = newTop;
}
}
}
},
resizer = function() {
windowHeight = $window.height();
for (var i = 0; i < sticked.length; i++) {
var s = sticked[i];
if (typeof s.getWidthFrom !== 'undefined' && s.responsiveWidth === true) {
s.stickyElement.css('width', $(s.getWidthFrom).width());
}
}
},
methods = {
init: function(options) {
var o = $.extend({}, defaults, options);
return this.each(function() {
var stickyElement = $(this);
var stickyId = stickyElement.attr('id');
var wrapperId = stickyId ? stickyId + '-' + defaults.wrapperClassName : defaults.wrapperClassName
var wrapper = $('
')
.attr('id', stickyId + '-sticky-wrapper')
.addClass(o.wrapperClassName);
stickyElement.wrapAll(wrapper);
if (o.center) {
stickyElement.parent().css({width:stickyElement.outerWidth(),marginLeft:"auto",marginRight:"auto"});
}
if (stickyElement.css("float") == "right") {
stickyElement.css({"float":"none"}).parent().css({"float":"right"});
}
var stickyWrapper = stickyElement.parent();
stickyWrapper.css('height', stickyElement.outerHeight());
sticked.push({
topSpacing: o.topSpacing,
bottomSpacing: o.bottomSpacing,
stickyElement: stickyElement,
currentTop: null,
stickyWrapper: stickyWrapper,
className: o.className,
getWidthFrom: o.getWidthFrom,
responsiveWidth: o.responsiveWidth
});
});
},
update: scroller,
unstick: function(options) {
return this.each(function() {
var unstickyElement = $(this);
var removeIdx = -1;
for (var i = 0; i < sticked.length; i++)
{
if (sticked[i].stickyElement.get(0) == unstickyElement.get(0))
{
removeIdx = i;
}
}
if(removeIdx != -1)
{
sticked.splice(removeIdx,1);
unstickyElement.unwrap();
unstickyElement.removeAttr('style');
}
});
}
};
// should be more efficient than using $window.scroll(scroller) and $window.resize(resizer):
if (window.addEventListener) {
window.addEventListener('scroll', scroller, false);
window.addEventListener('resize', resizer, false);
} else if (window.attachEvent) {
window.attachEvent('onscroll', scroller);
window.attachEvent('onresize', resizer);
}
$.fn.sticky = function(method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method ) {
return methods.init.apply( this, arguments );
} else {
$.error('Method ' + method + ' does not exist on jQuery.sticky');
}
};
$.fn.unstick = function(method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method ) {
return methods.unstick.apply( this, arguments );
} else {
$.error('Method ' + method + ' does not exist on jQuery.sticky');
}
};
$(function() {
setTimeout(scroller, 0);
});
})(jQuery);
//**************************************************************************************
//* /home3/yhekobro/public_html/ptz-beton.ru/js/libs/common/main.js
//**************************************************************************************
var topMenu = {};
topMenu.toElement = function (id) {
block = $("#" + id);
if (block.length) {
menuHeight = $("#top-menu").height();
positionY = block.offset().top - menuHeight;
$('body,html').animate({
scrollTop: positionY
}, Math.abs(positionY - $("html").scrollTop()) / 2);
}
};
// -----------------------------------------------------------------------------
var request = {
ajaxManagerUrl: '/data_manager.php'
};
request.showForm = function () {
dialog.openWithWaiter('Заявка на доставку бетона');
$.post(request.ajaxManagerUrl, {
section: "getRequestFormHtml"
}, request.showFormComplete);
};
request.showFormComplete = function (data) {
dialog.change(data, 500);
};
request.send = function () {
volume = $("#request_volume").val().trim();
name = $("#request_name").val().trim();
phone = $("#request_phone").val().trim();
err = '';
if (volume == '') {
err += '- Нужно указать заказываемый объем.\n';
}
if (name == '') {
err += '- Нужно указать ваше имя.\n';
}
if (phone == '') {
err += '- Нужно указать контактный телефон.\n';
}
if (err != '') {
alert(err);
return;
}
$.post(request.ajaxManagerUrl, {
section: "sendRequest",
name: name,
volume: volume,
phone: phone
}, request.sendComplete);
};
request.sendComplete = function (data) {
$("#request_form").slideUp(500, function () {
$("#request_form").html(data).slideDown(500);
})
};
var zhbi = {};
zhbi.showInfo = function (id, width) {
title = $("#zhbi-title-" + id + " b").html();
html = $("#zhbi-info-" + id).html();
/*
html += '\
\
';
*/
dialog.open(title, html, width);
};
//**************************************************************************************
//* /home3/yhekobro/public_html/ptz-beton.ru/js/libs/common/core.js
//**************************************************************************************
// *****************************************************************************
// ******
// ****** Common procedures
// ******
// *****************************************************************************
// Divs for waiting icon
document.write('');
document.write('');
document.write('');
document.write('');
var getResult, execQueryFinish;
var loading_icon = "loading_32.gif";
var loading_icon_24 = "loading_24.gif";
var _info_frames = new Array();
// -----------------------------------------------------------------------------
jQuery.fn.screenCenter = function () {
w = $(window);
this.css("position", "absolute");
this.css("top", (w.height() - this.height()) / 2 + w.scrollTop() + "px");
this.css("left", (w.width() - this.width()) / 2 + w.scrollLeft() + "px");
return this;
}
// -----------------------------------------------------------------------------
jQuery.fn.elementCenter = function (id) {
e = $('#' + id);
this.css("position", "absolute");
this.css("top", (e.innerHeight() - this.height()) / 2 + e.offset().top + "px");
this.css("left", (e.innerWidth() - this.width()) / 2 + e.offset().left + "px");
return this;
}
// -----------------------------------------------------------------------------
function mask_screen(func) {
mask_width = $(window).width();
mask_height = $(document).height();
$('.grey_box').css({
top: '0px',
left: '0px',
width: mask_width + 'px',
height: mask_height + 'px',
opacity: '0.5'
}).fadeIn();
$(".wait_slider").screenCenter().fadeTo('slow', '1', func);
}
// -----------------------------------------------------------------------------
function mask_element(id, func) {
qid = '#' + id;
if ($(qid).length == 0 || $('body').css('display') == 'none')
func();
else {
mask_width = $(qid).innerWidth();
mask_height = $(qid).innerHeight();
mask_top = $(qid).offset().top + 1;
mask_left = $(qid).offset().left + 1;
mask_border = $(qid).css('border');
mask_border_radius = $(qid).css('borderRadius');
$('.grey_box').css({
top: mask_top + 'px',
left: mask_left + 'px',
width: mask_width + 'px',
height: mask_height + 'px',
opacity: '0.6',
border: mask_border,
borderRadius: mask_border_radius
}).show();
$('.wait_slider').elementCenter(id).fadeTo(300, '1', func);
}
}
// -----------------------------------------------------------------------------
function mask_element_noicon(id, func) {
mask_width = $('#' + id).innerWidth();
mask_height = $('#' + id).innerHeight();
mask_top = $('#' + id).offset().top + 1;
mask_left = $('#' + id).offset().left + 1;
mask_border = $('#' + id).css('border');
$('.grey_box').css({
top: mask_top + 'px',
left: mask_left + 'px',
width: mask_width + 'px',
height: mask_height + 'px',
opacity: '0.5',
border: mask_border
}).show();
func();
}
// -----------------------------------------------------------------------------
function mask_screen_noicon(func) {
mask_width = $(window).width();
mask_height = $(document).height();
$('.grey_box').offset({top: 0, left: 0}).css({
top: '0px',
left: '0px',
width: mask_width + 'px',
height: mask_height + 'px',
opacity: '0.5'
}).fadeIn(300);
func();
}
// -----------------------------------------------------------------------------
function clear_mask() {
$('.wait_slider').fadeOut();
$('.grey_box').fadeOut();//.css({width: '0px', height: '0px'});
}
// -----------------------------------------------------------------------------
function execQueryCallback(data) {
getResult = data;
}
// -----------------------------------------------------------------------------
function execQuery(url, params) {
$.ajaxSetup({async: false});
$.post(url, params, execQueryCallback, 'text');
$.ajaxSetup({async: true});
return getResult;
}
// -----------------------------------------------------------------------------
if (!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
}
}
// -----------------------------------------------------------------------------
function get_unique_id() {
do {
n = Math.floor(Math.random() * Math.random() * 18954785965458745895);
id = 'uid_' + Math.floor(Math.random() * Math.random() * 18954785965458745895).toString(36).substr(2, 8);
l = $('#' + id).length;
} while (l != 0);
return id;
}
// -----------------------------------------------------------------------------
function info_frame_show(title, html, info_width) {
__info_show_id = get_unique_id();
_info_frames.push(__info_show_id);
w = $(window).width();
h = $(window).height();
hd = $(document).height();
$("body").append('');
$('#white_box_' + __info_show_id).css({width: w + 'px', height: hd + 'px', opacity: '0.7'}).fadeIn();
if (info_width == null) {
info_width = w * 2 / 3;
if (info_width > 600) info_width = 600;
}
if (title != '')
info_html = "";
else
info_html = '';
h = h * 3 / 4;
$("body").append('');
info_html = info_html + "" + html + "
";
$('#' + __info_show_id).html(info_html);
$('#' + __info_show_id).css('width', info_width + 'px');
$('#' + __info_show_id).screenCenter().fadeIn();
}
// -----------------------------------------------------------------------------
function info_frame_change(title, html, width) {
__info_change_id = _info_frames[_info_frames.length - 1];
$('#info_window_container_' + __info_change_id).html(html);
if (width != null) $('#' + __info_change_id).css('width', width + 'px');
if (title != '') $("#info_window_header_" + __info_change_id).html(title + "
");
$('#' + __info_change_id).screenCenter();
}
// -----------------------------------------------------------------------------
function info_frame_close() {
__info_close_id = _info_frames[_info_frames.length - 1];
_info_frames.pop();
$('#white_box_' + __info_close_id).fadeOut(function () {
$('#white_box_' + __info_close_id).remove();
});
$('#' + __info_close_id).fadeOut(function () {
$('#' + __info_close_id).html('').remove();
});
}
// -----------------------------------------------------------------------------
function info_frame_id() {
return _info_frames[_info_frames.length - 1];
}
// -----------------------------------------------------------------------------
function info_frame_inner_id() {
return "info_window_container_" + _info_frames[_info_frames.length - 1];
}
// -----------------------------------------------------------------------------
function info_frame_center() {
__info_center_id = _info_frames[_info_frames.length - 1];
$('#' + __info_center_id).screenCenter();
}
// -----------------------------------------------------------------------------
function confirm_box(title, html, func, args) {
$("#_show_dialog:ui-dialog").dialog("close");
$("#_show_dialog:ui-dialog").dialog("destroy");
$("#_show_dialog").attr("title", title);
$("#_show_dialog").html(html);
$("#_show_dialog").dialog({
modal: true,
draggable: true,
resizable: false,
zIndex: 999999,
buttons: {
"": function () {
$(this).dialog("close");
func(args);
},
"": function () {
$(this).dialog("close");
}
}
});
}
// -----------------------------------------------------------------------------
function _show_warning(title, text) {
$("#_show_dialog:ui-dialog").dialog("close");
$("#_show_dialog:ui-dialog").dialog("destroy");
$("#_show_dialog").attr("title", title);
html = "\
\
" + text + "
\
\
";
$("#_show_dialog").html(html);
$("#_show_dialog").dialog({
modal: true,
draggable: true,
resizable: false,
width: 400,
dialogClass: "_info_dialogs",
buttons: {
"Ok": function () {
$(this).dialog("close");
}
}
});
}
// -----------------------------------------------------------------------------
function _show_info(title, text) {
$("#_show_dialog:ui-dialog").dialog("close");
$("#_show_dialog:ui-dialog").dialog("destroy");
$("#_show_dialog").attr("title", title);
html = "\
" + text + "
\
\
";
$("#_show_dialog").html(html);
$("#_show_dialog").dialog({
modal: true,
draggable: true,
resizable: false,
width: 400,
dialogClass: "_info_dialogs",
buttons: {
"Ok": function () {
$(this).dialog("close");
}
}
});
}
// -----------------------------------------------------------------------------
function input_check_number(event) {
event = event || window.event;
target = event.target || event.srcElement;
if (window.event) key = window.event.keyCode; //IE
else key = event.which; //firefox
if (key < 32) return true;
if (key >= 48 && key <= 57) return true;
if ((key == 44 || key == 46) && $(target).val().indexOf(String.fromCharCode(key)) == -1) return true; //
return false;
}
// -----------------------------------------------------------------------------
function num_to_text(num) {
var i = 0, type = ['Bytes', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb'];
while ((num / 1000 | 0) && i < type.length - 1) {
num /= 1024;
i++;
}
return num.toFixed(2) + ' ' + type[i];
}
// -----------------------------------------------------------------------------
var md5unicode = new function () {
var l = 'length',
h = [
'0123456789abcdef', 0x0F, 0x80, 0xFFFF,
0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476
],
x = [
[0, 1, [7, 12, 17, 22]],
[1, 5, [5, 9, 14, 20]],
[5, 3, [4, 11, 16, 23]],
[0, 7, [6, 10, 15, 21]]
],
A = function (x, y, z) {
return (((x >> 16) + (y >> 16) + ((z = (x & h[3]) + (y & h[3])) >> 16)) << 16) | (z & h[3])
},
B = function (s) {
var n = ((s[l] + 8) >> 6) + 1, b = new Array(1 + n * 16).join('0').split('');
for (var i = 0; i < s[l]; i++)b[i >> 2] |= s.charCodeAt(i) << ((i % 4) * 8);
return (b[i >> 2] |= h[2] << ((i % 4) * 8), b[n * 16 - 2] = s[l] * 8, b)
},
R = function (n, c) {
return (n << c) | (n >>> (32 - c))
},
C = function (q, a, b, x, s, t) {
return A(R(A(A(a, q), A(x, t)), s), b)
},
F = function (a, b, c, d, x, s, t) {
return C((b & c) | ((~b) & d), a, b, x, s, t)
},
G = function (a, b, c, d, x, s, t) {
return C((b & d) | (c & (~d)), a, b, x, s, t)
},
H = function (a, b, c, d, x, s, t) {
return C(b ^ c ^ d, a, b, x, s, t)
},
I = function (a, b, c, d, x, s, t) {
return C(c ^ (b | (~d)), a, b, x, s, t)
},
_ = [F, G, H, I],
S = (function () {
with (Math)for (var i = 0, a = [], x = pow(2, 32); i < 64; a[i] = floor(abs(sin(++i)) * x));
return a
})(),
X = function (n) {
for (var j = 0, s = ''; j < 4; j++)
s += h[0].charAt((n >> (j * 8 + 4)) & h[1]) + h[0].charAt((n >> (j * 8)) & h[1]);
return s
};
return function (s) {
var $ = B('' + s), a = [0, 1, 2, 3], b = [0, 3, 2, 1], v = [h[4], h[5], h[6], h[7]];
for (var i, j, k, N = 0, J = 0, o = [].concat(v); N < $[l]; N += 16, o = [].concat(v), J = 0) {
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
for (k = 0; k < 4; k++, a.unshift(a.pop()))
v[b[k]] = _[i](
v[a[0]],
v[a[1]],
v[a[2]],
v[a[3]],
$[N + (((j * 4 + k) * x[i][1] + x[i][0]) % 16)],
x[i][2][k],
S[J++]
);
for (i = 0; i < 4; i++)
v[i] = A(v[i], o[i]);
}
;
return X(v[0]) + X(v[1]) + X(v[2]) + X(v[3]);
}
};
// -----------------------------------------------------------------------------
var trans = [];
for (var i = 0x410; i <= 0x44F; i++)
trans[i] = i - 0x350; // --
trans[0x401] = 0xA8; //
trans[0x451] = 0xB8; //
function md5(str) {
var ret = [];
for (var i = 0; i < str.length; i++) {
var n = str.charCodeAt(i);
if (typeof trans[n] != 'undefined')
n = trans[n];
if (n <= 0xFF)
ret.push(n);
}
return md5unicode(String.fromCharCode.apply(null, ret));
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// image loader procedure
// -----------------------------------------------------------------------------
var _swfu, _uploaded_files = new Array();
// -----------------------------------------------------------------------------
function _load_image(func, file_mask, uniqname) {
delete _swfu;
html = "\
\
\
\
";
info_frame_show(' ', html, 302);
_swfu = new SWFUpload(
{
upload_url: "/uploader/upload.php",
flash_url: "/uploader/swfupload.swf",
file_size_limit: "10 MB",
file_types: file_mask,
file_types_description: "Files",
file_upload_limit: 1,
button_placeholder_id: "_loader_button_holder",
button_image_url: "/images/upload_button.png",
button_width: 148,
button_height: 27,
button_text: " ",
button_text_style: ".uploadButtonText { color: #666666; font-size: 11px; font-weight: bold; font-family: Sans-Serif;}",
button_text_left_padding: 30,
button_text_top_padding: 4,
button_action: SWFUpload.BUTTON_ACTION.SELECT_FILES,
button_disabled: false,
button_cursor: SWFUpload.CURSOR.HAND,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
// swfupload_loaded_handler : swfupload_loaded_function,
// file_dialog_start_handler : file_dialog_start_function,
file_queued_handler: _uploader_fileQueued,
file_queue_error_handler: _uploader_fileQueueError,
// file_dialog_complete_handler : fileDialogComplete,
upload_start_handler: _uploader_uploadStart,
upload_progress_handler: _uploader_uploadProgress,
upload_error_handler: _uploader_uploadError,
// upload_success_handler : upload_success_function,
upload_complete_handler: _uploader_uploadComplete,
// debug_handler : debug_function,
// debug: true,
custom_settings: {
complete_func: func,
uname: '',
}
}
);
if (uniqname) {
rnd = Math.random() * 1234567890 + (new Date).getTime();
rnd = md5(rnd.toString());
_swfu.customSettings.uname = rnd;
}
}
// -----------------------------------------------------------------------------
function _uploader_fileQueued(file) {
$("#_loader_progress_block").html("\
\
\
");
uname = _swfu.customSettings.uname;
if (uname == '') {
_swfu.customSettings.uname = file.name;
_swfu.addFileParam(file.id, "upload_file_real_name", file.name);
}
else {
pos = file.name.lastIndexOf('.');
if (pos != -1) {
ext = file.name.substring(pos);
uname = uname + ext;
_swfu.customSettings.uname = uname;
}
_swfu.addFileParam(file.id, "upload_file_real_name", uname);
}
_swfu.startUpload();
}
// -----------------------------------------------------------------------------
function debug_function(message) {
alert(message);
}
// -----------------------------------------------------------------------------
function _uploader_fileQueueError() {
}
function _uploader_uploadStart() {
}
// -----------------------------------------------------------------------------
function _uploader_uploadProgress(file, bytes, total) {
w100 = 300;
w = parseInt(w100 * bytes / total);
if (bytes == total) w = w100;
$("#_loader_progress_bar").css({"width": w + "px"});
$("#_loader_progress_text").html(num_to_text(bytes) + " " + num_to_text(total));
}
// -----------------------------------------------------------------------------
function _uploader_uploadError(file, error, message) {
alert(message);
}
// -----------------------------------------------------------------------------
function _uploader_uploadComplete(file) {
complete_function = _swfu.customSettings.complete_func;
$("#_loader_progress_block").after(" ...
");
complete_function(_swfu.customSettings.uname);
_swfu.destroy();
}
// -----------------------------------------------------------------------------
var core = {};
core.setCookie = function (cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires;
};
core.getCookie = function (cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1);
if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
}
return "";
};
core.isEmail = function (email) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return regex.test(email);
};
core.getMaxZIndex = function () {
var highest = -999;
$("*").each(function () {
var current = parseInt($(this).css("z-index"), 10);
// if (current == 1999999) current = 0;
id = $(this).attr('id');
if (id == 'colorbox' || id == 'cboxOverlay' || id == 'cboxWrapper') current = 0;
if (current && highest < current) highest = current;
});
return highest;
};
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
/*
* The dialog class
*/
var dialog = {
ajaxManagerUrl: '/data_manager.php',
frames: new Array(),
closeHandlers: new Array(),
waitHtml: '',
scrollWidth: 0,
heightMax: $(window).height() * 5 / 6
};
/*
* Open the dialog contains waiter icon.
*/
dialog.openWithWaiter = function (title) {
dialog.open(title, dialog.waitHtml, 200);
};
/*
* Disable vertical scroller before show first dialog
*/
dialog.hideScroller = function () {
if (dialog.frames.length) return;
body = $('body');
w0 = $(window).innerWidth();
body.css('overflow-y', 'hidden');
w1 = $(window).innerWidth();
marginLeft = parseInt(body.css('margin-left'), 10);
dialog.scrollWidth = Math.ceil((w1 - w0) / 2);
// dialog.scrollWidth = w1 - w0;
marginLeft -= dialog.scrollWidth;
body.css('margin-left', marginLeft + 'px');
try {
dialog.offsetDesignElements(-dialog.scrollWidth);
}
catch (err) {
}
};
/*
* Disable vertical scroller before show first dialog
*/
dialog.showScroller = function () {
if (dialog.frames.length) return;
body = $('body');
marginLeft = parseInt(body.css('margin-left'), 10);
marginLeft += dialog.scrollWidth;
body.css({'margin-left': marginLeft + 'px', 'overflow-y': 'scroll'});
try {
dialog.offsetDesignElements(this.scrollWidth);
}
catch (err) {
}
};
/*
* Open the dialog contains HTML code.
*
* html - The HTML code inserting into dialog container.
* width - The width of opened dialog in pixels.
*/
dialog.open = function (title, html, width, closeHandler) {
dialog.hideScroller();
dialogId = get_unique_id();
dialog.frames.push(dialogId);
dialog.closeHandlers.push(closeHandler);
h = $(window).height() * 5 / 6;
w = $(window).width() * 5 / 6;
if (width > w) {
width = w;
}
// add dialog container
$("body").append('');
dialogElement = $("#" + dialogId);
dialogElement.attr("title", title);
dialogHtml = "" + html + "
";
dialogElement.html(dialogHtml);
dialogElement.dialog({
title: title,
modal: true,
draggable: true,
resizable: false,
width: width,
maxHeight: h,
minHeight: 10,
closeOnEscape: true,
close: dialog.close
});
};
/*
* Generate the unique ID for created dialog.
*/
dialog.getUniqueId = function () {
do {
randomIntId = Math.floor(Math.random() * Math.random() * 18954785965458745895);
id = 'uid_' + randomIntId.toString(36).substr(2, 8);
l = $('#' + id).length;
} while (l != 0);
return id;
};
/*
* Change the active dialog contents.
*
* html - The new HTML code for dialog.
* width - The new width of dialog in pixels (if 'null' then width will not changing).
*/
dialog.change = function (html, width) {
if (!dialog.frames.length) return;
dialogId = dialog.frames[dialog.frames.length - 1];
$('#dialog_container_' + dialogId).html(html);
if (width != null) {
$("#" + dialogId).dialog("option", "width", width);
}
dialog.center();
};
dialog.setCloseHandler = function (closeHandler) {
if (!dialog.closeHandlers.length) return;
dialog.closeHandlers[dialog.closeHandlers.length - 1] = closeHandler;
};
/*
* Close the topmost dialog.
*/
dialog.close = function () {
closeHandler = dialog.closeHandlers[dialog.closeHandlers.length - 1];
if (closeHandler) {
closeHandler();
}
dialog.closeHandlers.pop();
dialogId = dialog.frames[dialog.frames.length - 1];
$("#" + dialogId).dialog('destroy').remove();
dialog.frames.pop();
dialog.showScroller();
};
/*
* Return ID of frame element of active dialog.
*/
dialog.getFrameId = function () {
return dialog.frames[dialog.frames.length - 1];
};
/*
* Return ID of inner frame element of active dialog.
*/
dialog.getInnerId = function () {
return "dialog_container_" + dialog.frames[dialog.frames.length - 1];
};
/*
* Replace active dialog to center of screen.
*/
dialog.center = function () {
dialogId = dialog.getFrameId();
$("#" + dialogId).dialog("option", "position", "center")
};
// -----------------------------------------------------------------------------------------------
dialog.offsetDesignElements = function (offsetX) {
x = parseInt($("#header_static_container").css('left'), 10);
x += offsetX;
$("#header_static_container").css('left', x + 'px');
};
// -----------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------
var design = {
ajaxManagerUrl: '/data_manager.php',
waitIndicatorImage: 'white_indicator_64.png'
};
design.getWaitIndicatorHtml = function () {
html = '';
return html;
};
design.waitIndicator = function (elementId) {
element = $('#' + elementId);
elementPosition = element.css('position');
if (elementPosition == 'absolute' || elementPosition == 'relative') {
top = '50%';
left = '50%';
}
else {
elementWidth = element.width();
elementHeight = element.height();
elementOffset = element.offset();
top = elementOffset.top + elementHeight / 2;
top += 'px';
left = elementOffset.left + elementWidth / 2;
left += 'px';
}
element.append(design.getWaitIndicatorHtml());
waitIndicator = $("#__wait_indicator__");
waitIndicator.css({'top': top, 'left': left});
waitIndicator.fadeIn(300);
};