Index: branches/5.2.x/core/admin_templates/js/script.js =================================================================== diff -u -N -r15042 -r15371 --- branches/5.2.x/core/admin_templates/js/script.js (.../script.js) (revision 15042) +++ branches/5.2.x/core/admin_templates/js/script.js (.../script.js) (revision 15371) @@ -1,7 +1,7 @@ if ( !( isset($init_made) && $init_made ) ) { var Application = new kApplication(); var Grids = new Array(); - var GridScrollers = new Array (); + var GridScrollers = new Array(); var Toolbars = new Array(); var $Menus = new Array(); var $ViewMenus = new Array(); @@ -11,121 +11,133 @@ var $CKEditors = {}; // input name VS ck options mapping var $form_name = 'kernel_form'; - if(!$fw_menus) var $fw_menus = new Array(); + if ( !$fw_menus ) { + var $fw_menus = new Array(); + } + var $env = ''; var submitted = false; var unload_legal = false; var $edit_mode = false; var $init_made = true; // in case of double inclusion of script.js :) // hook processing - var hBEFORE = 1; // this is const, but including this twice causes errors - var hAFTER = 2; // this is const, but including this twice causes errors + var hBEFORE = 1; // this is const, but including this twice causes errors + var hAFTER = 2; // this is const, but including this twice causes errors replaceFireBug(); } function use_popups($prefix_special, $event, $mode) { - if ($mode === undefined || $mode == 'popup') { + if ( $mode === undefined || $mode == 'popup' ) { return $use_popups; } return $modal_windows; } -function getArrayValue() -{ +function getArrayValue() { var $value = arguments[0]; var $current_key = 0; $i = 1; + while ($i < arguments.length) { $current_key = arguments[$i]; - if (isset($value[$current_key])) { + if ( isset($value[$current_key]) ) { $value = $value[$current_key]; } else { return false; } + $i++; } + return $value; } -function setArrayValue() -{ +function setArrayValue() { // first argument - array, other arguments - keys (arrays too), last argument - value var $array = arguments[0]; var $current_key = 0; $i = 1; + while ($i < arguments.length - 1) { $current_key = arguments[$i]; - if (!isset($array[$current_key])) { + + if ( !isset($array[$current_key]) ) { $array[$current_key] = new Array(); } + $array = $array[$current_key]; $i++; } + $array[$array.length] = arguments[arguments.length - 1]; } -function resort_grid($prefix_special, $field, $ajax) -{ +function resort_grid($prefix_special, $field, $ajax) { set_form($prefix_special, $ajax); set_hidden_field($prefix_special + '_Sort1', $field); submit_event($prefix_special, 'OnSetSorting', null, null, $ajax); } -function direct_sort_grid($prefix_special, $field, $direction, $field_pos, $ajax) -{ - if(!isset($field_pos)) $field_pos = 1; +function direct_sort_grid($prefix_special, $field, $direction, $field_pos, $ajax) { + if ( !isset($field_pos) ) { + $field_pos = 1; + } + set_form($prefix_special, $ajax); - set_hidden_field($prefix_special+'_Sort'+$field_pos,$field); - set_hidden_field($prefix_special+'_Sort'+$field_pos+'_Dir',$direction); - set_hidden_field($prefix_special+'_SortPos',$field_pos); - submit_event($prefix_special,'OnSetSortingDirect', null, null, $ajax); + set_hidden_field($prefix_special + '_Sort' + $field_pos, $field); + set_hidden_field($prefix_special + '_Sort' + $field_pos + '_Dir', $direction); + set_hidden_field($prefix_special + '_SortPos', $field_pos); + submit_event($prefix_special, 'OnSetSortingDirect', null, null, $ajax); } -function reset_sorting($prefix_special, $ajax) -{ - submit_event($prefix_special,'OnResetSorting', null, null, $ajax); +function reset_sorting($prefix_special, $ajax) { + submit_event($prefix_special, 'OnResetSorting', null, null, $ajax); } -function set_per_page($prefix_special, $per_page, $ajax) -{ +function set_per_page($prefix_special, $per_page, $ajax) { set_form($prefix_special, $ajax); set_hidden_field($prefix_special + '_PerPage', $per_page); submit_event($prefix_special, 'OnSetPerPage', null, null, $ajax); } -function set_refresh_interval($prefix_special, $refresh_interval, $ajax) -{ +function set_refresh_interval($prefix_special, $refresh_interval, $ajax) { set_form($prefix_special, $ajax); set_hidden_field('refresh_interval', $refresh_interval); submit_event($prefix_special, 'OnSetAutoRefreshInterval', null, null, $ajax); } -function submit_event(prefix_special, event, t, form_action, $ajax) -{ - if (!Application.processHooks(prefix_special + ':' + event)) { +function submit_event(prefix_special, event, t, form_action, $ajax) { + if ( !Application.processHooks(prefix_special + ':' + event) ) { return false; } - if ($ajax) { + + if ( $ajax ) { return $Catalog.submit_event(prefix_special, event, t); } - if (event) { + if ( event ) { set_hidden_field('events[' + prefix_special + ']', event); } - if (t) set_hidden_field('t', t); - if (form_action) { + if ( t ) { + set_hidden_field('t', t); + } + + if ( form_action ) { var old_env = ''; - if (!form_action.match(/\?/)) { + + if ( !form_action.match(/\?/) ) { document.getElementById($form_name).action.match(/.*(\?.*)/); old_env = RegExp.$1; } + document.getElementById($form_name).action = form_action + old_env; } + submit_kernel_form(); // reset remove special mark (otherwise all future events will have special removed too) @@ -137,11 +149,11 @@ return false; } - if (event) { + if ( event ) { set_hidden_field('events[' + prefix_special + ']', event); } - if (t) { + if ( t ) { set_hidden_field('t', t); } @@ -155,29 +167,27 @@ set_hidden_field('remove_specials[' + prefix_special + ']', null); } -function submit_action($url, $action) -{ +function submit_action($url, $action) { $form = document.getElementById($form_name); $form.action = $url; set_hidden_field('Action', $action); submit_kernel_form(); } -function show_form_data() -{ +function show_form_data() { var $kf = document.getElementById($form_name); $ret = ''; - for(var i in $kf.elements) - { + + for (var i in $kf.elements) { $elem = $kf.elements[i]; $ret += $elem.id + ' = ' + $elem.value + "\n"; } + alert($ret); } -function submit_kernel_form() -{ - if (submitted) { +function submit_kernel_form() { + if ( submitted ) { return; } @@ -186,7 +196,7 @@ var $form = document.getElementById($form_name); - if ($.isFunction($form.onsubmit)) { + if ( $.isFunction($form.onsubmit) ) { $form.onsubmit(); } @@ -198,94 +208,96 @@ // window.setTimeout(function() {submitted = false}, 500); } -function set_event(prefix_special, event) -{ - var event_field=document.getElementById('events[' + prefix_special + ']'); - if(isset(event_field)) - { +function set_event(prefix_special, event) { + var event_field = document.getElementById('events[' + prefix_special + ']'); + + if ( isset(event_field) ) { event_field.value = event; } } -function isset(variable) -{ - if(variable==null) return false; - return (typeof(variable)=='undefined')?false:true; +function isset(variable) { + if ( variable == null ) { + return false; + } + + return (typeof(variable) == 'undefined') ? false : true; } -function in_array(needle, haystack) -{ +function in_array(needle, haystack) { return array_search(needle, haystack) != -1; } -function array_search(needle, haystack) -{ - for (var i=0; i "+variable[prop] + "\n"; - } - alert(s); + + for (prop in variable) { + s += prop + " => " + variable[prop] + "\n"; + } + + alert(s); } -function go_to_page($prefix_special, $page, $ajax) -{ +function go_to_page($prefix_special, $page, $ajax) { set_form($prefix_special, $ajax); set_hidden_field($prefix_special + '_Page', $page); submit_event($prefix_special, 'OnSetPage', null, null, $ajax); } -function go_to_list(prefix_special, tab) -{ - set_hidden_field(prefix_special+'_GoTab', tab); - submit_event(prefix_special,'OnUpdateAndGoToTab',null); +function go_to_list(prefix_special, tab) { + set_hidden_field(prefix_special + '_GoTab', tab); + submit_event(prefix_special, 'OnUpdateAndGoToTab', null); } -function go_to_tab(prefix_special, tab) -{ - set_hidden_field(prefix_special+'_GoTab', tab); - submit_event(prefix_special,'OnPreSaveAndGoToTab',null); +function go_to_tab(prefix_special, tab) { + set_hidden_field(prefix_special + '_GoTab', tab); + submit_event(prefix_special, 'OnPreSaveAndGoToTab', null); } -function go_to_id(prefix_special, id) -{ - set_hidden_field(prefix_special+'_GoId', id); - submit_event(prefix_special,'OnPreSaveAndGo') +function go_to_id(prefix_special, id) { + set_hidden_field(prefix_special + '_GoId', id); + submit_event(prefix_special, 'OnPreSaveAndGo') } // in-portal compatibility functions: begin -function getScriptURL($script_name, tpl) -{ - tpl = tpl ? '-'+tpl : ''; +function getScriptURL($script_name, tpl) { + tpl = tpl ? '-' + tpl : ''; var $asid = get_hidden_field('sid'); - return base_url+$script_name+'?env='+( isset($env)&&$env?$env:$asid )+tpl+'&en=0'; + + return base_url + $script_name + '?env=' + ( isset($env) && $env ? $env : $asid ) + tpl + '&en=0'; } -function OpenEditor(extra_env,TargetForm,TargetField) -{ +function OpenEditor(extra_env, TargetForm, TargetField) { var $url = getScriptURL('admin/index.php', 'popups/editor'); - $url = $url+'&TargetForm='+TargetForm+'&TargetField='+TargetField+'&destform=popup'; - if(extra_env.length>0) $url += extra_env; - openwin($url,'html_edit',800,575); + + $url = $url + '&TargetForm=' + TargetForm + '&TargetField=' + TargetField + '&destform=popup'; + + if ( extra_env.length > 0 ) { + $url += extra_env; + } + + openwin($url, 'html_edit', 800, 575); } // in-portal compatibility functions: end -function InitTranslator(prefix, field, t, multi_line, $before_callback) -{ +function InitTranslator(prefix, field, t, multi_line, $before_callback) { var $window_name = 'select_' + t.replace(/(\/|-)/g, '_'); var $options = { onAfterShow: function ($popup_window) { - if ($modal_windows) { + if ( $modal_windows ) { getFrame('main').initTranslatorOnAfterShow(prefix, field, t, multi_line, $before_callback); } else { @@ -301,9 +313,10 @@ var $window_name = 'select_' + t.replace(/(\/|-)/g, '_'); $popup_window = onAfterWindowOpen($window_name, undefined, $popup_window); - if ($popup_window === false) { + + if ( $popup_window === false ) { // iframe onload happens on frame content change too -> don't react on it - return ; + return; } var $opener = getWindowOpener($popup_window); @@ -316,7 +329,7 @@ $opener.set_hidden_field('translator_prefixes', prefix); $opener.set_hidden_field('translator_multi_line', isset(multi_line) ? multi_line : 0); - if ($.isFunction($before_callback)) { + if ( $.isFunction($before_callback) ) { $before_callback($opener); } @@ -329,13 +342,11 @@ $opener.submitted = false; } -function PreSaveAndOpenTranslator(prefix, field, t, multi_line) -{ +function PreSaveAndOpenTranslator(prefix, field, t, multi_line) { InitTranslator(prefix, field, t, multi_line); } -function PreSaveAndOpenTranslatorCV(prefix, field, t, resource_id, multi_line) -{ +function PreSaveAndOpenTranslatorCV(prefix, field, t, resource_id, multi_line) { InitTranslator( prefix, field, t, multi_line, function ($opener) { @@ -344,8 +355,7 @@ ); } -function openTranslator(prefix,field,url,wnd) -{ +function openTranslator(prefix, field, url, wnd) { var $kf = document.getElementById($form_name); set_hidden_field('trans_prefix', prefix); @@ -354,18 +364,18 @@ var $regex = new RegExp('(.*)\?env=(' + document.getElementById('sid').value + ')?-(.*?):(.*)'); var $t = $regex.exec(url)[3]; + $kf.target = wnd; - submit_event(prefix,'',$t,url); + submit_event(prefix, '', $t, url); submitted = false; } -function openwin($url, $name, $width, $height, $options) -{ +function openwin($url, $name, $width, $height, $options) { var $settings = { url: base_url + 'core/admin_templates/blank.html?width=' + $width + '&height=' + $height + '&TB_iframe=true&modal=true', caption: 'Loading ...', onAfterShow: function ($popup_window) { - if ($modal_windows) { + if ( $modal_windows ) { getFrame('main').onAfterWindowOpen($name, $url); } else { @@ -374,19 +384,19 @@ } }; - if ($options !== undefined) { + if ( $options !== undefined ) { $.extend($settings, $options); } - if ($modal_windows) { - if (window.name != 'main') { + if ( $modal_windows ) { + if ( window.name != 'main' ) { // all popups are opened based on main frame return getFrame('main').TB.show($settings); } TB.show($settings); - return ; + return; } // prevent window from opening larger, then screen resolution on user's computer (to Kostja) @@ -395,7 +405,7 @@ var cur_x = document.all ? window.screenLeft : window.screenX; var cur_y = document.all ? window.screenTop : window.screenY; - var $window_params = 'left='+left+',top='+top+',width='+$width+',height='+$height+',status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no'; + var $window_params = 'left=' + left + ',top=' + top + ',width=' + $width + ',height=' + $height + ',status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no'; var $popup_window = window.open($url, $name, $window_params); if ( $.isFunction($settings.onAfterShow) ) { @@ -407,9 +417,10 @@ function onAfterWindowOpen($window_name, $url, $popup_window) { // this is always invoked from "main" frame - if ($popup_window === undefined) { + if ( $popup_window === undefined ) { var $popup_window = $('#' + TB.getId('TB_iframeContent')).get(0).contentWindow; - if (!$.isFunction($popup_window.onLoad)) { + + if ( !$.isFunction($popup_window.onLoad) ) { // iframe onload happens on frame content change too -> don't react on it return false; } @@ -419,19 +430,19 @@ $popup_window.name = $window_name; - if ($url !== undefined) { + if ( $url !== undefined ) { $popup_window.location.href = $url; } - if ($modal_windows) { + if ( $modal_windows ) { TB.setWindowMetaData('window_name', $window_name); // used to simulate window.opener functionality } return $popup_window; } function OnResizePopup(e) { - if (!document.all) { + if ( !document.all ) { var $winW = window.innerWidth; var $winH = window.innerHeight; } @@ -443,22 +454,22 @@ window.status = '[width: ' + $winW + '; height: ' + $winH + ']'; } -function opener_action(new_action) -{ +function opener_action(new_action) { var $prev_opener = get_hidden_field('m_opener'); set_hidden_field('m_opener', new_action); return $prev_opener; } function open_popup($prefix_special, $event, $t, $window_size, $onAfterOpenPopup) { - if (!$window_size) { + if ( !$window_size ) { // if no size given, then query it from ajax var $default_size = '750x400'; var $pm = getFrame('head').$popup_manager; - if ($pm) { + + if ( $pm ) { // popup manager was found in head frame $pm.ResponceFunction = function ($responce) { - if (!$responce.match(/([\d]+)x([\d]+)/)) { + if ( !$responce.match(/([\d]+)x([\d]+)/) ) { // invalid responce was received, may be php fatal error during AJAX request $responce = $default_size; } @@ -467,7 +478,7 @@ } $pm.GetSize($t); - return ; + return; } $window_size = $default_size; @@ -479,14 +490,14 @@ var $options = { onAfterShow: function ($popup_window) { - if ($modal_windows) { + if ( $modal_windows ) { getFrame('main').onAfterOpenPopup($prefix_special, $event, $t); } else { onAfterOpenPopup($prefix_special, $event, $t, $popup_window); } - if ($onAfterOpenPopup !== undefined && $.isFunction($onAfterOpenPopup)) { + if ( $onAfterOpenPopup !== undefined && $.isFunction($onAfterOpenPopup) ) { $onAfterOpenPopup($popup_window); } } @@ -500,22 +511,23 @@ var $window_name = $t.replace(/(\/|-)/g, '_'); // replace "/" and "-" with "_" $popup_window = onAfterWindowOpen($window_name, undefined, $popup_window); - if ($popup_window === false) { + if ( $popup_window === false ) { // iframe onload happens on frame content change too -> don't react on it - return ; + return; } var $opener = getWindowOpener($popup_window); - if ($opener === null) { + if ( $opener === null ) { // we are already in main window $opener = window; } $opener.document.getElementById($opener.$form_name).target = $window_name; var $prev_opener = $opener.opener_action('p'); + event_bak = $opener.get_hidden_field('events[' + $prefix_special + ']') - if (!event_bak) { + if ( !event_bak ) { event_bak = ''; } @@ -532,8 +544,7 @@ } -function openSelector($prefix, $url, $dst_field, $window_size, $event) -{ +function openSelector($prefix, $url, $dst_field, $window_size, $event) { // get template name from url var $regex = new RegExp('(.*)\?env=(' + document.getElementById('sid').value + ')?-(.*?):(m[^:]+)'); $regex = $regex.exec($url); @@ -547,7 +558,7 @@ $kf.action = $url; // check parameter values - if (!isset($event)) { + if ( !isset($event) ) { $event = ''; } @@ -560,7 +571,7 @@ // alert('openSelector(' + $prefix + ', ' + $event + ', ' + $t + ', ' + $window_size + ')'); open_popup( $prefix, $event, $t, $window_size, - function() { + function () { // restore form action back $kf.action = $prev_action; } @@ -571,10 +582,10 @@ set_hidden_field('phrases_label', $label); var $event = $options.event === undefined ? 'OnNew' : $options.event; - if ($options.simple_mode !== undefined) { + if ( $options.simple_mode !== undefined ) { Application.SetVar('simple_mode', $options.simple_mode ? 1 : 0); - if ($options.simple_mode) { + if ( $options.simple_mode ) { Application.SetVar('front', 1); } } @@ -584,8 +595,8 @@ Application.SetVar('phrases_label', null); } - if (use_popups('phrases', $event)) { - open_popup('phrases', $event, $edit_template, null, function() { + if ( use_popups('phrases', $event) ) { + open_popup('phrases', $event, $edit_template, null, function () { Application.SetVar('front', null); Application.SetVar('simple_mode', null); }); @@ -601,7 +612,7 @@ } function direct_edit($prefix_special, $url) { - if (use_popups($prefix_special, '')) { + if ( use_popups($prefix_special, '') ) { openSelector($prefix_special, $url); } else { @@ -611,158 +622,154 @@ return false; } -function std_precreate_item(prefix_special, edit_template, $onAfterOpenPopup) -{ - set_hidden_field(prefix_special+'_mode', 't'); - if (use_popups(prefix_special, 'OnPreCreate')) { +function std_precreate_item(prefix_special, edit_template, $onAfterOpenPopup) { + set_hidden_field(prefix_special + '_mode', 't'); + + if ( use_popups(prefix_special, 'OnPreCreate') ) { open_popup(prefix_special, 'OnPreCreate', edit_template, null, $onAfterOpenPopup); } else { opener_action('d'); - submit_event(prefix_special,'OnPreCreate', edit_template); + submit_event(prefix_special, 'OnPreCreate', edit_template); } // set_hidden_field(prefix_special+'_mode', ''); } -function std_new_item(prefix_special, edit_template, $onAfterOpenPopup) -{ - if (use_popups(prefix_special, 'OnNew')) { +function std_new_item(prefix_special, edit_template, $onAfterOpenPopup) { + if ( use_popups(prefix_special, 'OnNew') ) { open_popup(prefix_special, 'OnNew', edit_template, null, $onAfterOpenPopup); } else { opener_action('d'); - submit_event(prefix_special,'OnNew', edit_template); + submit_event(prefix_special, 'OnNew', edit_template); } } -function std_edit_item(prefix_special, edit_template, $onAfterOpenPopup) -{ - set_hidden_field(prefix_special+'_mode', 't'); - if (use_popups(prefix_special, 'OnEdit')) { +function std_edit_item(prefix_special, edit_template, $onAfterOpenPopup) { + set_hidden_field(prefix_special + '_mode', 't'); + + if ( use_popups(prefix_special, 'OnEdit') ) { open_popup(prefix_special, 'OnEdit', edit_template, null, $onAfterOpenPopup); } else { opener_action('d'); - submit_event(prefix_special,'OnEdit',edit_template); + submit_event(prefix_special, 'OnEdit', edit_template); } // set_hidden_field(prefix_special+'_mode', ''); } -function std_edit_temp_item(prefix_special, edit_template, $onAfterOpenPopup) -{ - if (use_popups(prefix_special, 'OnStoreSelected')) { +function std_edit_temp_item(prefix_special, edit_template, $onAfterOpenPopup) { + if ( use_popups(prefix_special, 'OnStoreSelected') ) { open_popup(prefix_special, 'OnStoreSelected', edit_template, null, $onAfterOpenPopup); } else { opener_action('d'); - submit_event(prefix_special,'OnStoreSelected',edit_template); + submit_event(prefix_special, 'OnStoreSelected', edit_template); } } -function std_delete_items(prefix_special, t, $ajax) -{ +function std_delete_items(prefix_special, t, $ajax) { var phrase = phrases['la_Delete_Confirm'] ? phrases['la_Delete_Confirm'] : 'Are you sure you want to delete selected items?'; - if (inpConfirm(phrase)) { - submit_event(prefix_special, 'OnMassDelete', t, null, $ajax); + + if ( inpConfirm(phrase) ) { + submit_event(prefix_special, 'OnMassDelete', t, null, $ajax); } } -function std_csv_export(prefix_special, grid, template) -{ +function std_csv_export(prefix_special, grid, template) { set_hidden_field('PrefixSpecial', prefix_special); set_hidden_field('grid', grid); open_popup(prefix_special, '', template); } -function std_csv_import(prefix_special, grid, template) -{ +function std_csv_import(prefix_special, grid, template) { set_hidden_field('PrefixSpecial', prefix_special); set_hidden_field('grid', grid); - if (use_popups(prefix_special, '')) { + + if ( use_popups(prefix_special, '') ) { open_popup(prefix_special, '', template); } else { - submit_event(prefix_special, '', template); - } + submit_event(prefix_special, '', template); + } } // set current form base on ajax -function set_form($prefix_special, $ajax) -{ - if ($ajax) { +function set_form($prefix_special, $ajax) { + if ( $ajax ) { $form_name = $Catalog.queryTabRegistry('prefix', $prefix_special, 'tab_id') + '_form'; } } // sets hidden field value // if the field does not exist - creates it -function set_hidden_field($field_id, $value, $has_id) -{ +function set_hidden_field($field_id, $value, $has_id) { var $kf = document.getElementById($form_name); var $field = $kf.elements[$field_id]; - if ($value === null) { - if ($field) { + if ( $value === null ) { + if ( $field ) { // alert('tag name on remove: ' + $field.parentNode.tagName); $field.parentNode.removeChild($field); // bug: sometimes hidden fields are inside BODY tag in DOM model, why? } + return true; } - if ($field) { + if ( $field ) { $field.value = $value; + return true; } $field = document.createElement('INPUT'); $field.type = 'hidden'; $field.name = $field_id; - if (!isset($has_id) || $has_id) { + + if ( !isset($has_id) || $has_id ) { $field.id = $field_id; } $field.value = $value; $kf.appendChild($field); + return false; } // sets hidden field value // if the field does not exist - creates it function setInnerHTML($field_id, $value) { - $( jq('#' + $field_id) ).html($value); + $(jq('#' + $field_id)).html($value); } -function get_hidden_field($field) -{ +function get_hidden_field($field) { var $kf = document.getElementById($form_name); + return $kf.elements[$field] ? $kf.elements[$field].value : false; } -function search($prefix_special, $grid_name, $ajax) -{ +function search($prefix_special, $grid_name, $ajax) { set_form($prefix_special, $ajax); set_hidden_field('grid_name', $grid_name); submit_event($prefix_special, 'OnSearch', null, null, $ajax); } -function search_reset($prefix_special, $grid_name, $ajax) -{ +function search_reset($prefix_special, $grid_name, $ajax) { set_form($prefix_special, $ajax); set_hidden_field('grid_name', $grid_name); submit_event($prefix_special, 'OnSearchReset', null, null, $ajax); } -function search_keydown($event, $prefix_special, $grid, $ajax) -{ - if ($prefix_special !== undefined) { +function search_keydown($event, $prefix_special, $grid, $ajax) { + if ( $prefix_special !== undefined ) { // if $prefix_special is passed, then keydown event was not assigned by jQuery $event = $event ? $event : event; - if (window.event) {// IE + if ( window.event ) {// IE var $key_code = $event.keyCode; } - else if($event.which) { // Netscape/Firefox/Opera + else if ( $event.which ) { // Netscape/Firefox/Opera var $key_code = $event.which; } } @@ -786,31 +793,32 @@ } } -function getRealLeft(el) -{ - if (typeof(el) == 'string') { +function getRealLeft(el) { + if ( typeof(el) == 'string' ) { el = document.getElementById(el); } + xPos = el.offsetLeft; tempEl = el.offsetParent; - while (tempEl != null) - { + + while (tempEl != null) { xPos += tempEl.offsetLeft; tempEl = tempEl.offsetParent; } + // if (obj.x) return obj.x; return xPos; } -function getRealTop(el) -{ - if (typeof(el) == 'string') { +function getRealTop(el) { + if ( typeof(el) == 'string' ) { el = document.getElementById(el); } + yPos = el.offsetTop; tempEl = el.offsetParent; - while (tempEl != null) - { + + while (tempEl != null) { yPos += tempEl.offsetTop; tempEl = tempEl.offsetParent; } @@ -819,37 +827,32 @@ return yPos; } -function show_viewmenu_old($toolbar, $button_id) -{ +function show_viewmenu_old($toolbar, $button_id) { var $img = $toolbar.GetButtonImage($button_id); var $pos_x = getRealLeft($img) - ((document.all) ? 6 : -2); var $pos_y = getRealTop($img) + 32; var $prefix_special = ''; window.triedToWriteMenus = false; - if($ViewMenus.length == 1) - { - $prefix_special = $ViewMenus[$ViewMenus.length-1]; - $fw_menus[$prefix_special+'_view_menu'](); - $Menus[$prefix_special+'_view_menu'].writeMenus('MenuContainers['+$prefix_special+']'); - window.FW_showMenu($Menus[$prefix_special+'_view_menu'], $pos_x, $pos_y); + if ( $ViewMenus.length == 1 ) { + $prefix_special = $ViewMenus[$ViewMenus.length - 1]; + $fw_menus[$prefix_special + '_view_menu'](); + $Menus[$prefix_special + '_view_menu'].writeMenus('MenuContainers[' + $prefix_special + ']'); + window.FW_showMenu($Menus[$prefix_special + '_view_menu'], $pos_x, $pos_y); } - else - { + else { // prepare menus - for(var $i in $ViewMenus) - { + for (var $i in $ViewMenus) { $prefix_special = $ViewMenus[$i]; - $fw_menus[$prefix_special+'_view_menu'](); + $fw_menus[$prefix_special + '_view_menu'](); } $Menus['mixed'] = new Menu('ViewMenu_mixed'); // merge menus into new one - for(var $i in $ViewMenus) - { + for (var $i in $ViewMenus) { $prefix_special = $ViewMenus[$i]; - $Menus['mixed'].addMenuItem( $Menus[$prefix_special+'_view_menu'] ); + $Menus['mixed'].addMenuItem($Menus[$prefix_special + '_view_menu']); } $Menus['mixed'].writeMenus('MenuContainers[mixed]'); @@ -858,79 +861,70 @@ } var nlsMenuRendered = false; -function show_viewmenu($toolbar, $button_id) -{ - if($ViewMenus.length == 1) { - $prefix_special = $ViewMenus[$ViewMenus.length-1]; - menu_to_show = $prefix_special+'_view_menu'; +function show_viewmenu($toolbar, $button_id) { + if ( $ViewMenus.length == 1 ) { + $prefix_special = $ViewMenus[$ViewMenus.length - 1]; + menu_to_show = $prefix_special + '_view_menu'; } - else - { + else { mixed_menu = menuMgr.createMenu(rs('mixed_menu')); mixed_menu.applyBorder(false, false, false, false); mixed_menu.dropShadow("none"); mixed_menu.showIcon = true; // merge menus into new one - for(var $i in $ViewMenus) - { + for (var $i in $ViewMenus) { $prefix_special = $ViewMenus[$i]; - mixed_menu.addItem( rs($prefix_special+'.view.menu.mixed'), - $MenuNames[$prefix_special+'_view_menu'], - 'javascript:void()', null, true, null, - rs($prefix_special+'.view.menu'),$MenuNames[$prefix_special+'_view_menu'] ); + mixed_menu.addItem(rs($prefix_special + '.view.menu.mixed'), + $MenuNames[$prefix_special + '_view_menu'], + 'javascript:void()', null, true, null, + rs($prefix_special + '.view.menu'), $MenuNames[$prefix_special + '_view_menu']); } menu_to_show = 'mixed_menu'; } renderMenus(); - nls_showMenu(rs(menu_to_show), $toolbar.GetButtonImage($button_id)) } -function renderMenus() -{ +function renderMenus() { // menuMgr.renderMenus closes all opened menus, but doesn't mark them as closed menuMgr.hideMenus(); menuMgr.renderMenus('nlsMenuPlace'); nlsMenuRendered = true; } -function set_window_title($title) -{ +function set_window_title($title) { var $window = window; - if ($window.name != 'main') { + if ( $window.name != 'main' ) { // traverse through real popups $window = getFrame('main'); } $window.top.document.title = (main_title.length ? main_title + ' - ' : '') + $title; - if ($modal_windows) { + if ( $modal_windows ) { $window.TB.setWindowTitle(''); } } -function set_filter($prefix_special, $filter_id, $filter_value, $ajax) -{ +function set_filter($prefix_special, $filter_id, $filter_value, $ajax) { set_form($prefix_special, $ajax); set_hidden_field('filter_id', $filter_id); set_hidden_field('filter_value', $filter_value); submit_event($prefix_special, 'OnSetFilter', null, null, $ajax); } -function filters_remove_all($prefix_special, $ajax) -{ +function filters_remove_all($prefix_special, $ajax) { set_form($prefix_special, $ajax); - submit_event($prefix_special,'OnRemoveFilters', null, null, $ajax); + submit_event($prefix_special, 'OnRemoveFilters', null, null, $ajax); } -function filters_apply_all($prefix_special, $ajax) -{ +function filters_apply_all($prefix_special, $ajax) { set_form($prefix_special, $ajax); - submit_event($prefix_special,'OnApplyFilters', null, null, $ajax); + submit_event($prefix_special, 'OnApplyFilters', null, null, $ajax); } function filter_toggle($row_id, $prefix) { @@ -939,7 +933,7 @@ var $row = $('tr.to-range-filter'); var $hidden = $row.hasClass('hidden-filter'); - if ($hidden) { + if ( $hidden ) { $('td', $row).show(); $row.removeClass('hidden-filter'); @@ -954,7 +948,7 @@ var $grid = GridScrollers[$prefix]; $grid.UpdateColWidths(); - if ($hidden && $grid.FiltersExpanded !== true) { + if ( $hidden && $grid.FiltersExpanded !== true ) { $grid.AdjustInputWidths(); $grid.FiltersExpanded = true; } @@ -966,34 +960,36 @@ // $grid.Resize( $grid.GetAutoSize() ); } -function RemoveTranslationLink($string, $escaped) -{ - if (!isset($escaped)) $escaped = true; +function RemoveTranslationLink($string, $escaped) { + if ( !isset($escaped) ) $escaped = true; - if ($escaped) { + if ( $escaped ) { return $string.replace(/<a href="(.*?)".*>(.*?)<\/a>/g, '$2'); } return $string.replace(/(.*?)<\/a>/g, '$2'); } -function redirect($url) -{ +function redirect($url) { window.location.href = $url; } -function update_checkbox_options($cb_mask, $hidden_id) -{ +function update_checkbox_options($cb_mask, $hidden_id) { var $kf = document.getElementById($form_name); var $tmp = ''; - for (var i = 0; i < $kf.elements.length; i++) - { - if ( $kf.elements[i].id.match($cb_mask) ) - { - if ($kf.elements[i].checked) $tmp += '|'+$kf.elements[i].value; + + for (var i = 0; i < $kf.elements.length; i++) { + if ( $kf.elements[i].id.match($cb_mask) ) { + if ( $kf.elements[i].checked ) { + $tmp += '|' + $kf.elements[i].value; + } } } - if($tmp.length > 0) $tmp += '|'; + + if ( $tmp.length > 0 ) { + $tmp += '|'; + } + document.getElementById($hidden_id).value = $tmp.replace(/,$/, ''); } @@ -1002,565 +998,578 @@ var $result = ''; for (var $i = 0; $i < $select.options.length; $i++) { - if ($select.options[$i].selected) { + if ( $select.options[$i].selected ) { $result += $select.options[$i].value + '|'; } } + document.getElementById($hidden_id).value = $result ? '|' + $result : ''; } // related to lists operations (moving) - function move_selected($from_list, $to_list, $error_msg) - { - if (typeof($from_list) != 'object') $from_list = document.getElementById($from_list); - if (typeof($to_list) != 'object') $to_list = document.getElementById($to_list); +function move_selected($from_list, $to_list, $error_msg) { + if ( typeof($from_list) != 'object' ) $from_list = document.getElementById($from_list); + if ( typeof($to_list) != 'object' ) $to_list = document.getElementById($to_list); - if (has_selected_options($from_list)) - { - var $from_array = select_to_array($from_list); - var $to_array = select_to_array($to_list); - var $new_from = Array(); - var $cur = null; + if ( has_selected_options($from_list) ) { + var $from_array = select_to_array($from_list); + var $to_array = select_to_array($to_list); + var $new_from = Array(); + var $cur = null; - for (var $i = 0; $i < $from_array.length; $i++) + for (var $i = 0; $i < $from_array.length; $i++) { + $cur = $from_array[$i]; + if ( $cur[2] ) // If selected - add to To array { - $cur = $from_array[$i]; - if ($cur[2]) // If selected - add to To array - { - $to_array[$to_array.length] = $cur; - } - else //Else - keep in new From - { - $new_from[$new_from.length] = $cur; - } + $to_array[$to_array.length] = $cur; } - - $from_list = array_to_select($new_from, $from_list); - $to_list = array_to_select($to_array, $to_list); + else //Else - keep in new From + { + $new_from[$new_from.length] = $cur; + } } - else - { - alert(isset($error_msg) ? $error_msg : 'Please select items to perform moving!'); - } + + $from_list = array_to_select($new_from, $from_list); + $to_list = array_to_select($to_array, $to_list); } + else { + alert(isset($error_msg) ? $error_msg : 'Please select items to perform moving!'); + } +} - function select_to_array($aSelect) - { - var $an_array = new Array(); - var $cur = null; +function select_to_array($aSelect) { + var $an_array = new Array(); + var $cur = null; - for (var $i = 0; $i < $aSelect.length; $i++) - { - $cur = $aSelect.options[$i]; - $an_array[$an_array.length] = new Array($cur.text, $cur.value, $cur.selected); - } - return $an_array; + for (var $i = 0; $i < $aSelect.length; $i++) { + $cur = $aSelect.options[$i]; + $an_array[$an_array.length] = new Array($cur.text, $cur.value, $cur.selected); } - function array_to_select($anArray, $aSelect) - { - var $initial_length = $aSelect.length; - for (var $i = $initial_length - 1; $i >= 0; $i--) - { - $aSelect.options[$i] = null; - } + return $an_array; +} - for (var $i = 0; $i < $anArray.length; $i++) - { - $cur = $anArray[$i]; - $aSelect.options[$aSelect.length] = new Option($cur[0], $cur[1]); - } +function array_to_select($anArray, $aSelect) { + var $initial_length = $aSelect.length; + + for (var $i = $initial_length - 1; $i >= 0; $i--) { + $aSelect.options[$i] = null; } - function select_compare($a, $b) - { - if ($a[0] < $b[0]) - return -1; - if ($a[0] > $b[0]) - return 1; - return 0; + for (var $i = 0; $i < $anArray.length; $i++) { + $cur = $anArray[$i]; + $aSelect.options[$aSelect.length] = new Option($cur[0], $cur[1]); } +} - function select_to_string($aSelect) - { - var $result = ''; - var $cur = null; +function select_compare($a, $b) { + if ( $a[0] < $b[0] ) { + return -1; + } - if (typeof($aSelect) != 'object') $aSelect = document.getElementById($aSelect); + if ( $a[0] > $b[0] ) { + return 1; + } - for (var $i = 0; $i < $aSelect.length; $i++) - { - $result += $aSelect.options[$i].value + '|'; - } + return 0; +} - return $result.length ? '|' + $result : ''; +function select_to_string($aSelect) { + var $result = ''; + var $cur = null; + + if ( typeof($aSelect) != 'object' ) $aSelect = document.getElementById($aSelect); + + for (var $i = 0; $i < $aSelect.length; $i++) { + $result += $aSelect.options[$i].value + '|'; } - function selected_to_string($aSelect) - { - var $result = ''; - var $cur = null; + return $result.length ? '|' + $result : ''; +} - if (typeof($aSelect) != 'object') $aSelect = document.getElementById($aSelect); +function selected_to_string($aSelect) { + var $result = ''; + var $cur = null; - for (var $i = 0; $i < $aSelect.length; $i++) - { - $cur = $aSelect.options[$i]; - if ($cur.selected && $cur.value != '') - { - $result += $cur.value + '|'; - } - } + if ( typeof($aSelect) != 'object' ) $aSelect = document.getElementById($aSelect); - return $result.length ? '|' + $result : ''; - } + for (var $i = 0; $i < $aSelect.length; $i++) { + $cur = $aSelect.options[$i]; - function string_to_selected($str, $aSelect) - { - var $cur = null; - for (var $i = 0; $i < $aSelect.length; $i++) - { - $cur = $aSelect.options[$i]; - $aSelect.options[$i].selected = $str.match('\\|' + $cur.value + '\\|') ? true : false; + if ( $cur.selected && $cur.value != '' ) { + $result += $cur.value + '|'; } } - function set_selected($selected_options, $aSelect) - { - if (!$selected_options.length) return false; + return $result.length ? '|' + $result : ''; +} - for (var $i = 0; $i < $aSelect.length; $i++) - { - for (var $k = 0; $k < $selected_options.length; $k++) - { - if ($aSelect.options[$i].value == $selected_options[$k]) - { - $aSelect.options[$i].selected = true; - } +function string_to_selected($str, $aSelect) { + var $cur = null; + + for (var $i = 0; $i < $aSelect.length; $i++) { + $cur = $aSelect.options[$i]; + $aSelect.options[$i].selected = $str.match('\\|' + $cur.value + '\\|') ? true : false; + } +} + +function set_selected($selected_options, $aSelect) { + if ( !$selected_options.length ) return false; + + for (var $i = 0; $i < $aSelect.length; $i++) { + for (var $k = 0; $k < $selected_options.length; $k++) { + if ( $aSelect.options[$i].value == $selected_options[$k] ) { + $aSelect.options[$i].selected = true; } } } +} - function get_selected_count($theList) - { - var $count = 0; - var $cur = null; - for (var $i = 0; $i < $theList.length; $i++) - { - $cur = $theList.options[$i]; - if ($cur.selected) $count++; +function get_selected_count($theList) { + var $count = 0; + var $cur = null; + + for (var $i = 0; $i < $theList.length; $i++) { + $cur = $theList.options[$i]; + + if ( $cur.selected ) { + $count++; } - return $count; } - function get_selected_index($aSelect, $typeIndex) - { - var $index = 0; - for (var $i = 0; $i < $aSelect.length; $i++) - { - if ($aSelect.options[$i].selected) - { - $index = $i; - if ($typeIndex == 'firstSelected') break; + return $count; +} + +function get_selected_index($aSelect, $typeIndex) { + var $index = 0; + + for (var $i = 0; $i < $aSelect.length; $i++) { + if ( $aSelect.options[$i].selected ) { + $index = $i; + if ( $typeIndex == 'firstSelected' ) { + break; } } - return $index; } - function has_selected_options($theList) - { - var $ret = false; - var $cur = null; + return $index; +} - for (var $i = 0; $i < $theList.length; $i++) - { - $cur = $theList.options[$i]; - if ($cur.selected) { - $ret = true; - break; - } +function has_selected_options($theList) { + var $ret = false; + var $cur = null; + + for (var $i = 0; $i < $theList.length; $i++) { + $cur = $theList.options[$i]; + + if ( $cur.selected ) { + $ret = true; + break; } - return $ret; } - function select_sort($aSelect) - { - if (typeof($aSelect) != 'object') $aSelect = document.getElementById($aSelect); + return $ret; +} - var $to_array = select_to_array($aSelect); - $to_array.sort(select_compare); - array_to_select($to_array, $aSelect); +function select_sort($aSelect) { + if ( typeof($aSelect) != 'object' ) { + $aSelect = document.getElementById($aSelect); } - function move_options_up($aSelect, $interval) - { - if (typeof($aSelect) != 'object') $aSelect = document.getElementById($aSelect); + var $to_array = select_to_array($aSelect); - if (has_selected_options($aSelect)) - { - var $selected_options = Array(); - var $first_selected = get_selected_index($aSelect, 'firstSelected'); + $to_array.sort(select_compare); + array_to_select($to_array, $aSelect); +} - for (var $i = 0; $i < $aSelect.length; $i++) - { - if ($aSelect.options[$i].selected && ($first_selected > 0) ) - { - swap_options($aSelect, $i, $i - $interval); - $selected_options[$selected_options.length] = $aSelect.options[$i - $interval].value; - } - else if ($first_selected == 0) - { - //alert('Begin of list'); - break; - } +function move_options_up($aSelect, $interval) { + if ( typeof($aSelect) != 'object' ) { + $aSelect = document.getElementById($aSelect); + } + + if ( has_selected_options($aSelect) ) { + var $selected_options = Array(); + var $first_selected = get_selected_index($aSelect, 'firstSelected'); + + for (var $i = 0; $i < $aSelect.length; $i++) { + if ( $aSelect.options[$i].selected && ($first_selected > 0) ) { + swap_options($aSelect, $i, $i - $interval); + $selected_options[$selected_options.length] = $aSelect.options[$i - $interval].value; } - set_selected($selected_options, $aSelect); + else if ( $first_selected == 0 ) { + //alert('Begin of list'); + break; + } } - else - { - //alert('Check items from moving'); - } + set_selected($selected_options, $aSelect); } + else { + //alert('Check items from moving'); + } +} - function move_options_down($aSelect, $interval) - { - if (typeof($aSelect) != 'object') $aSelect = document.getElementById($aSelect); +function move_options_down($aSelect, $interval) { + if ( typeof($aSelect) != 'object' ) { + $aSelect = document.getElementById($aSelect); + } - if (has_selected_options($aSelect)) - { - var $last_selected = get_selected_index($aSelect, 'lastSelected'); - var $selected_options = Array(); + if ( has_selected_options($aSelect) ) { + var $last_selected = get_selected_index($aSelect, 'lastSelected'); + var $selected_options = Array(); - for (var $i = $aSelect.length - 1; $i >= 0; $i--) - { - if ($aSelect.options[$i].selected && ($aSelect.length - ($last_selected + 1) > 0)) - { - swap_options($aSelect, $i, $i + $interval); - $selected_options[$selected_options.length] = $aSelect.options[$i + $interval].value; - } - else if ($last_selected + 1 == $aSelect.length) - { - //alert('End of list'); - break; - } + for (var $i = $aSelect.length - 1; $i >= 0; $i--) { + if ( $aSelect.options[$i].selected && ($aSelect.length - ($last_selected + 1) > 0) ) { + swap_options($aSelect, $i, $i + $interval); + $selected_options[$selected_options.length] = $aSelect.options[$i + $interval].value; } - set_selected($selected_options, $aSelect); + else if ( $last_selected + 1 == $aSelect.length ) { + //alert('End of list'); + break; + } } - else - { - //alert('Check items from moving'); - } + set_selected($selected_options, $aSelect); } + else { + //alert('Check items from moving'); + } +} - function swap_options($aSelect, $src_num, $dst_num) - { - var $src_html = $aSelect.options[$src_num].innerHTML; - var $dst_html = $aSelect.options[$dst_num].innerHTML; - var $src_value = $aSelect.options[$src_num].value; - var $dst_value = $aSelect.options[$dst_num].value; +function swap_options($aSelect, $src_num, $dst_num) { + var $src_html = $aSelect.options[$src_num].innerHTML; + var $dst_html = $aSelect.options[$dst_num].innerHTML; + var $src_value = $aSelect.options[$src_num].value; + var $dst_value = $aSelect.options[$dst_num].value; - var $src_option = document.createElement('OPTION'); - var $dst_option = document.createElement('OPTION'); + var $src_option = document.createElement('OPTION'); + var $dst_option = document.createElement('OPTION'); - $aSelect.remove($src_num); - $aSelect.options.add($dst_option, $src_num); - $dst_option.innerText = $dst_html; - $dst_option.value = $dst_value; - $dst_option.innerHTML = $dst_html; + $aSelect.remove($src_num); + $aSelect.options.add($dst_option, $src_num); + $dst_option.innerText = $dst_html; + $dst_option.value = $dst_value; + $dst_option.innerHTML = $dst_html; - $aSelect.remove($dst_num); - $aSelect.options.add($src_option, $dst_num); - $src_option.innerText = $src_html; - $src_option.value = $src_value; - $src_option.innerHTML = $src_html; + $aSelect.remove($dst_num); + $aSelect.options.add($src_option, $dst_num); + $src_option.innerText = $src_html; + $src_option.value = $src_value; + $src_option.innerHTML = $src_html; +} + +function getXMLHTTPObject(content_type) { + if ( !isset(content_type) ) { + content_type = 'text/plain'; } - function getXMLHTTPObject(content_type) - { - if (!isset(content_type)) content_type = 'text/plain'; - var http_request = false; - if (window.XMLHttpRequest) { // Mozilla, Safari,... - http_request = new XMLHttpRequest(); - if (http_request.overrideMimeType) { - http_request.overrideMimeType(content_type); - // See note below about this line - } - } else if (window.ActiveXObject) { // IE - try { - http_request = new ActiveXObject("Msxml2.XMLHTTP"); - } catch (e) { - try { - http_request = new ActiveXObject("Microsoft.XMLHTTP"); - } catch (e) {} - } - } - return http_request; - } + var http_request = false; - function str_repeat($symbol, $count) - { - var $i = 0; - var $ret = ''; - while($i < $count) { - $ret += $symbol; - $i++; - } - return $ret; - } + if ( window.XMLHttpRequest ) { // Mozilla, Safari,... + http_request = new XMLHttpRequest(); - function getDocumentFromXML(xml) - { - if (window.ActiveXObject) { - var doc = new ActiveXObject("Microsoft.XMLDOM"); - doc.async=false; - doc.loadXML(xml); + if ( http_request.overrideMimeType ) { + http_request.overrideMimeType(content_type); + // See note below about this line } - else { - var parser = new DOMParser(); - var doc = parser.parseFromString(xml,"text/xml"); + } else if ( window.ActiveXObject ) { // IE + try { + http_request = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + http_request = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (e) { + } } - return doc; } - function set_persistant_var($var_name, $var_value, $t, $form_action) - { - set_hidden_field('field', $var_name); - set_hidden_field('value', $var_value); - submit_event('u', 'OnSetPersistantVariable', $t, $form_action); - } + return http_request; +} - function setCookie($Name, $Value) - { - // set cookie - if (getCookie($Name) != $Value) { - document.cookie = $Name+'='+escape($Value); - } +function str_repeat($symbol, $count) { + var $i = 0; + var $ret = ''; + + while ($i < $count) { + $ret += $symbol; + $i++; } - function getCookie($Name) - { - // get cookie + return $ret; +} - var $cookieString = document.cookie; - var $index = $cookieString.indexOf($Name+'='); - if ($index == -1) { - return null; - } +function getDocumentFromXML(xml) { + if ( window.ActiveXObject ) { + var doc = new ActiveXObject("Microsoft.XMLDOM"); + doc.async = false; + doc.loadXML(xml); + } + else { + var parser = new DOMParser(); + var doc = parser.parseFromString(xml, "text/xml"); + } - $index = $cookieString.indexOf('=',$index)+1; - var $endstr = $cookieString.indexOf(';',$index); - if($endstr == -1) $endstr = $cookieString.length; + return doc; +} - return unescape($cookieString.substring($index, $endstr)); +function set_persistant_var($var_name, $var_value, $t, $form_action) { + set_hidden_field('field', $var_name); + set_hidden_field('value', $var_value); + submit_event('u', 'OnSetPersistantVariable', $t, $form_action); +} + +function setCookie($Name, $Value) { + // set cookie + if ( getCookie($Name) != $Value ) { + document.cookie = $Name + '=' + escape($Value); } +} - function deleteCookie($Name) - { - // deletes cookie - if (getCookie($Name)) { - var d = new Date(); - document.cookie = $Name + '=;expires=' + d.toGMTString() + ';' + ';'; - } +function getCookie($Name) { + // get cookie + var $cookieString = document.cookie; + var $index = $cookieString.indexOf($Name + '='); + + if ( $index == -1 ) { + return null; } - function addElement($dst_element, $tag_name) { - var $new_element = document.createElement($tag_name.toUpperCase()); - $dst_element.appendChild($new_element); - return $new_element; + $index = $cookieString.indexOf('=', $index) + 1; + + var $endstr = $cookieString.indexOf(';', $index); + + if ( $endstr == -1 ) { + $endstr = $cookieString.length; } - Math.sum = function($array) { - var $i = 0; - var $total = 0; - while ($i < $array.length) { - $total += $array[$i]; - $i++; - } - return $total; + return unescape($cookieString.substring($index, $endstr)); +} + +function deleteCookie($Name) { + // deletes cookie + if ( getCookie($Name) ) { + var d = new Date(); + + document.cookie = $Name + '=;expires=' + d.toGMTString() + ';' + ';'; } +} - Math.average = function($array) { - return Math.sum($array) / $array.length; +function addElement($dst_element, $tag_name) { + var $new_element = document.createElement($tag_name.toUpperCase()); + $dst_element.appendChild($new_element); + + return $new_element; +} + +Math.sum = function ($array) { + var $i = 0; + var $total = 0; + + while ($i < $array.length) { + $total += $array[$i]; + $i++; } - // remove spaces and underscores from a string, used for nls_menu - function rs(str, is_phrase) - { - if (isset(is_phrase) && is_phrase) { - str = RemoveTranslationLink(str, false); - } + return $total; +} - return str.replace(/[ _\']+/g, '.'); +Math.average = function ($array) { + return Math.sum($array) / $array.length; +} + +// remove spaces and underscores from a string, used for nls_menu +function rs(str, is_phrase) { + if ( isset(is_phrase) && is_phrase ) { + str = RemoveTranslationLink(str, false); } - function getFrame($name) - { - var $main_window = window; + return str.replace(/[ _\']+/g, '.'); +} - // 1. cycle through popups to get main window - try { - // will be error, when other site is opened in parent window - var $i = 0; - var $opener; +function getFrame($name) { + var $main_window = window; - do { - if ($i == 10) { - break; - } + // 1. cycle through popups to get main window + try { + // will be error, when other site is opened in parent window + var $i = 0; + var $opener; - // get popup opener - $opener = $main_window.opener; + do { + if ( $i == 10 ) { + break; + } - if (!$opener) { - // when no opener found, then try parent window - $opener = $main_window.parent; - } + // get popup opener + $opener = $main_window.opener; - if ($opener) { - $main_window = $opener; - } + if ( !$opener ) { + // when no opener found, then try parent window + $opener = $main_window.parent; + } - $i++; - } while ($opener); - } - catch (err) { - // catch Access/Permission Denied error + if ( $opener ) { + $main_window = $opener; + } + + $i++; + } while ($opener); + } + catch (err) { + // catch Access/Permission Denied error // alert('getFrame.Error: [' + err.description + ']'); - return window; - } + return window; + } - var $frameset = $main_window.parent.frames; - for ($i = 0; $i < $frameset.length; $i++) { - if ($frameset[$i].name == $name) { - return $frameset[$i]; - } + var $frameset = $main_window.parent.frames; + + for ($i = 0; $i < $frameset.length; $i++) { + if ( $frameset[$i].name == $name ) { + return $frameset[$i]; } - return $main_window.parent; } - function ClearBrowserSelection() - { - if (window.getSelection) { - // removeAllRanges will be supported by Opera from v 9+, do nothing by now - var selection = window.getSelection(); - if (selection.removeAllRanges) { // Mozilla & Opera 9+ -// alert('clearing FF') - window.getSelection().removeAllRanges(); - } - } else if (document.selection && !is.opera) { // IE -// alert('clearing IE') - document.selection.empty(); - } - } + return $main_window.parent; +} - function reset_form(prefix, event, msg) - { - if (confirm(RemoveTranslationLink(msg, true))) { - submit_event(prefix, event) +function ClearBrowserSelection() { + if ( window.getSelection ) { + // removeAllRanges will be supported by Opera from v 9+, do nothing by now + var selection = window.getSelection(); + + if ( selection.removeAllRanges ) { // Mozilla & Opera 9+ +// alert('clearing FF') + window.getSelection().removeAllRanges(); } + } else if ( document.selection && !is.opera ) { // IE +// alert('clearing IE') + document.selection.empty(); } +} - function cancel_edit(prefix, cancel_ev, save_ev, msg) - { - if ((!Form || (Form && Form.HasChanged)) && confirm(RemoveTranslationLink(msg, true))) { - submit_event(prefix, save_ev) - } - else { - submit_event(prefix, cancel_ev) - } +function reset_form(prefix, event, msg) { + if ( confirm(RemoveTranslationLink(msg, true)) ) { + submit_event(prefix, event) } +} +function cancel_edit(prefix, cancel_ev, save_ev, msg) { + if ( (!Form || (Form && Form.HasChanged)) && confirm(RemoveTranslationLink(msg, true)) ) { + submit_event(prefix, save_ev) + } + else { + submit_event(prefix, cancel_ev) + } +} -function execJS(node) -{ - var bSaf = (navigator.userAgent.indexOf('Safari') != -1); - var bOpera = (navigator.userAgent.indexOf('Opera') != -1); - var bMoz = (navigator.appName == 'Netscape'); +function execJS(node) { + var bSaf = (navigator.userAgent.indexOf('Safari') != -1); + var bOpera = (navigator.userAgent.indexOf('Opera') != -1); + var bMoz = (navigator.appName == 'Netscape'); - if (!node) return; + if ( !node ) { + return; + } - /* IE wants it uppercase */ - var st = node.getElementsByTagName('SCRIPT'); - var strExec; + /* IE wants it uppercase */ + var st = node.getElementsByTagName('SCRIPT'); + var strExec; - for(var i=0;i 1 ? this.DecimalSep + x[1] : ''; + var rgx = /(\d+)(\d{3})/; + while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + this.ThousandsSep + '$2'); } + return x1 + x2; } function getDimensions(obj) { var style - if (obj.currentStyle) { + + if ( obj.currentStyle ) { style = obj.currentStyle; } else { - style = getComputedStyle(obj,''); + style = getComputedStyle(obj, ''); } + padding = [parseInt(style.paddingTop), parseInt(style.paddingRight), parseInt(style.paddingBottom), parseInt(style.paddingLeft)] border = [parseInt(style.borderTopWidth), parseInt(style.borderRightWidth), parseInt(style.borderBottomWidth), parseInt(style.borderLeftWidth)] - for (var i = 0; i < padding.length; i++) if ( isNaN( padding[i] ) ) padding[i] = 0 - for (var i = 0; i < border.length; i++) if ( isNaN( border[i] ) ) border[i] = 0 + for (var i = 0; i < padding.length; i++) { + if ( isNaN(padding[i]) ) { + padding[i] = 0 + } + } + + for (var i = 0; i < border.length; i++) { + if ( isNaN(border[i]) ) { + border[i] = 0 + } + } + var result = new Object(); + result.innerHeight = obj.clientHeight - padding[0] - padding[2]; result.innerWidth = obj.clientWidth - padding[1] - padding[3]; result.padding = padding; @@ -1575,21 +1584,25 @@ function findPos(obj, with_scroll) { /*var $offset = $(obj).offset(); - return [$offset.left, $offset.top];*/ + return [$offset.left, $offset.top];*/ - if (!with_scroll) var with_scroll = false; + if ( !with_scroll ) { + var with_scroll = false; + } + var curleft = curtop = 0; - if (obj.offsetParent) { + if ( obj.offsetParent ) { curleft = obj.offsetLeft - (with_scroll ? obj.scrollLeft : 0) curtop = obj.offsetTop - (with_scroll ? obj.scrollTop : 0) + while (obj = obj.offsetParent) { curleft += obj.offsetLeft - (with_scroll ? obj.scrollLeft : 0) curtop += obj.offsetTop - (with_scroll ? obj.scrollTop : 0) } } - return [curleft,curtop]; + return [curleft, curtop]; } function scrollbarWidth() { @@ -1604,7 +1617,7 @@ width -= document.body.clientWidth; // Der IE im Standardmode - if (!width) { + if ( !width ) { width = document.body.offsetWidth - document.body.clientWidth; } @@ -1615,30 +1628,30 @@ } function maximizeElement($selector, $max_height) { - if ($max_height === undefined) { + if ( $max_height === undefined ) { $max_height = false; } var $element = $($selector); - if ($element.length == 0) { - return ; + if ( $element.length == 0 ) { + return; } $element.width('100%'); var $container_id = $element.attr('id') + '_container'; - var $container = $( jq('#' + $container_id) ); + var $container = $(jq('#' + $container_id)); - if ($container.length == 0) { + if ( $container.length == 0 ) { // don't create same container twice // all