@script name="PopupMgr" also="Events Fields" hide="y">
Implements the %STUDIO% popup manager
(c) SAP AG 2003-2006. All rights reserved.
#DEPENDENCIES[
lib:Xml.js
]
#INCLUDE[env:global_hotkeys.inc]
<@func name="CONTEXT_MENU">
Opens a context-sensitive menu
The context menu items
The target object, next to which the context menu will be opened
Alignment of the context menu with respect to the target object, according to: [BOTTOM|TOP] [RIGHT|LEFT] [FITWDITH] [SCREEN]
Horizontal offset of the context menu relative to %1, or to the screen left if %1 is ~null
Vertical offset of the context menu relative to %1, or to the screen top if %1 is ~null
The context menu items
A function to invoke when a context menu item is selected
Alignment of the context menu (always SCREEN)
Horizontal position of the context menu relative to the screen left
Vertical position of the context menu relative to the screen top
function CONTEXT_MENU(data, target, align, dx, dy) {
__POPUP.openPopup(0, data, target, align||'BOTTOM LEFT', dx, dy);
}
<@func name="DROPDOWN_LIST">
Opens a dropdown selection list under a given target
The dropdown list enumeration
The target object, under which the dropdown list will be opened
function DROPDOWN_LIST(enumData, target, maxrows, hfactor, minW) {
if (!enumData || !enumData.$ORDER) return;
var pop=__POPUP.createPopup('DROPDOWN_LIST', target, __POPUP.setField);
// build popup html
var maxW = 0;
if (!minW) minW = 100;
var textHelper = $CTL.getHelper('TEXT');
var selItem = null;
var trimValue = textHelper.getTextAndWidth(target.value).text;
for (var i=0, A=enumData.$ORDER, B=[], len=A.length; i'+b+'';
// try to match between this item and the selected value;
// match by clean text of by icon alone where the value shows no text:
var trimItem = data.text;
if (trimItem == trimValue ||
(target.dt == 'icon' && trimValue == '' && target.value != '' && b.indexOf(target.value) != -1))
selItem = {value:trimItem, index:i};
maxW = MAX(data.width, maxW);
}
pop.document.body.innerHTML = ''+JOIN(B)+'
';
var cs=target.currentStyle, dw=1, dh=POS(hfactor,14);
if ('borderSize' in cs) dw=INT(cs.borderSize)-1;
var x = -dw;
var y = target.offsetHeight+dw-1;
var w = target.offsetWidth+2*dw;
w = MAX(w, MIN(minW, maxW));
var rows = MIN(len, maxrows||10);
var h = rows*dh+2;
if (event.screenY+y+h >= window.screen.availHeight) {
// showing popup above the target or changing it's height
if (event.screenY-y < h) {
// changing popup's height
for (var i=rows-1; i>=10; i--) {
h = i*dh+2;
if (event.screenY+y+h < window.screen.availHeight) break;
if (event.screenY-y > h) {
y = -h;
break;
}
}
} else {// showing popup above the target
y = -h;
}
}
pop.show(x, y, w, h, target);
// mark the item identical to the selected value:
if(selItem) SELECT_ITEM(selItem);
}
<@func name="TRANS_LIST">
Opens a dropdown selection list under a given target. selection of a singel option in the List
will select all elements from the first option to the selected one.
The dropdown list
The target object, under which the dropdown list will be opened
A function to invoke when a context menu item is selected
function TRANS_LIST(transList,type,transName, target, func) {
if (!transList) return;
var pop=__POPUP.createPopup(type, target,func);
// build popup html
var maxLen = 0;
for (var i=0, A=transList, B=[], len=A.length; i maxLen) maxLen = a.length
B[i] = ''+a+'
';
}
B[transList.length] = ''
pop.document.body.innerHTML = ''+JOIN(B)+'
';
var cs=target.currentStyle, dw=1, dh=14;
if ('borderSize' in cs) dw=INT(cs.borderSize);
var x = -dw-19;
var y = target.offsetHeight+dw-1;
var w = target.offsetWidth+2*dw;
maxLen *=7;
w = (maxLen<150?150:(maxLen>400?400:maxLen));
var h = MIN(len+1, 12)*dh+2;
pop.show(x, y, w, h, target);
}
<@func name="POPUP_LIST">
Opens a popup selection list in a specified position
The dropdown list enumeration
A function to invoke when a popup list item is selected
Horizontal position of the popup list relative to the screen left
Vertical position of the popup list relative to the screen top
Width of the popup list
Background color of the popup list
function POPUP_LIST(enumData, target, x, y, w, rgb) {
if (!enumData || !enumData.$ORDER) return;
var pop=__POPUP.createPopup('POPUP_LIST', target, __POPUP.sendSignal);
var textHelper = $CTL.getHelper('TEXT');
var maxW = 0;
// build popup html
for (var i=0, A=enumData.$ORDER, B=[], len=A.length; i'+b+'';
}
pop.document.body.innerHTML = ''+JOIN(B)+'
';
pop.show(x, y, w||maxW, MIN(len*14+2, 150), null);
}
<@func name="AUTO_COMPLETE_LIST">
Opens a popup selection list in a specified position for auto complete feature
The dropdown list enumeration
A function to invoke when a popup list item is selected
Horizontal position of the popup list relative to the screen left
Vertical position of the popup list relative to the screen top
Width of the popup list
Background color of the popup list
function AUTO_COMPLETE_LIST(enumData, target, x, y, w, rgb) {
if (!enumData || !enumData.$ORDER) return;
var pop=__POPUP.createPopup('AUTO_COMPLETE_LIST', target, __POPUP.sendSignal);
// build popup html
for (var i=0, A=enumData.$ORDER, B=[], len=A.length; i'+b+'';
}
// Handle the SPC DIV - must be one DIV per list
else if (a == "SPC") {
B[i] = '';
}
else {
B[i] = ''+b+'
';
}
}
pop.document.body.innerHTML = ''+JOIN(B)+'
';
pop.show(x, y, w||100, MIN(len*14+2, 150), null);
}
<@func name="POPUP_COLORS">
Opens a colors chooser popup
The target object, next to which the colors chooser will be opened
Horizontal offset of the popup menu relative to %0, or to the screen left if %0 is ~null
Vertical offset of the popup menu relative to %0, or to the screen top if %0 is ~null
A function to invoke when a popup menu item is selected
Horizontal offset of the popup menu relative to the screen left
Vertical offset of the popup menu relative to the screen top
function POPUP_COLORS(target, dx, dy) {
var html=null, A=[];
if (!('POPUP_COLORS' in __POPUP.allPopups)) {
if (typeof WEB_PALETTE == 'undefined') {
PROMPT('Unable to open colors popup');
return;
}
var pal = WEB_PALETTE();
for (var j=0; j<7; j++) {
for (var i=0; i<19; i++) {
var rgb = '#'+pal[j].substring(i*7, i*7+6);
A.push('');
}
}
html = ''+JOIN(A)+'
';
}
var pop=__POPUP.createPopup('POPUP_COLORS', target, __POPUP.setField);
if (html) pop.document.body.innerHTML = html;
if (target && typeof target != 'function') {
pop.show(target.offsetWidth-183+POS(dx), target.offsetHeight+POS(dy), 183, 71, target);
} else {
pop.show(POS(dx), POS(dy), 183, 71);
}
}
<@func name="POPUP_HTML">
Opens a popup for displaying a given HTML document
function POPUP_HTML(html, css, x, y, w, h, target) {
if (!('POPUP_HTML' in __POPUP.allPopups)) {
__POPUP.allPopups['POPUP_HTML'] = createPopup();
}
var popWin = __POPUP.allPopups['POPUP_HTML'];
var popWin = window.createPopup();
var popDoc = popWin.document;
var popBody = popDoc.body;
var popCss = popDoc.createStyleSheet();
popCss.cssText = css;
popBody.style.backgroundColor = "#[WHT]";
popBody.style.border = "none";
popBody.style.overflow = "auto";
popBody.innerHTML = html;
popWin.show(x||0, y||0, w||200, h||20, target || null);
return popWin;
}
<@func name="HIDE_POPUP" also="POPUP_ISOPEN">
Hides a popup window
The type of popup window to hide; if omitted, all popup windows will be hidden
function HIDE_POPUP(type) {
return __POPUP.hidePopup(type);
}
<@func name="POPUP_ISOPEN" also="HIDE_POPUP">
Tests whether a popup window is currently open
The type of popup window to test
Returns ~true if the specified popup window is open; otherwise, returns ~false
function POPUP_ISOPEN(type) {
if (type == 'CONTEXT_MENU') type += '0';
if (!type) {
for (var k in __POPUP.allPopups) {
if (__POPUP.allPopups[k].isOpen) return true;
}
return false;
} else {
var pop=__POPUP.allPopups[type];
return pop ? pop.isOpen : false;
}
}
<@enum name="POPUP_TYPES">
An enumeration of the available popup window types
CONTEXT_MENU | Context-sensitive menus
DROPDOWN_LIST | Dropdown lists
POPUP_LIST | Popup lists
AUTO_COMPLETE_LIST | Auto Complete lists
POPUP_COLORS | Color choosers
<@struct name="POPUP_DATA">
Holds the items of a popup menu
The structure is an array listing the popup menu items in display order:
Name | Type | Description
text | String | The menu item display text
signal | String | Signal to send when the menu item is selected
icon | String | The icon to display for the menu item
key | String | The keyboard shortcut to display for the menu item
//////////////////////////////////////////////////////////////////////////////////////////////////
// INTERNAL
var __POPUP = {level:0, allPopups:{}, nestedPopups:[], timer:null, lastLevel:-1, levelX:{}};
__POPUP.global = __POPUP;
__POPUP.createPopup = function(type, target, callback, level) {
var qtype = type + (type == 'CONTEXT_MENU' ? level : '');
if (!(qtype in __POPUP.allPopups)) {
var pop = createPopup();
var doc = pop.document;
var win = doc.parentWindow;
var css = doc.createStyleSheet();
__POPUP.allPopups[qtype] = pop;
css.cssText = __POPUP.popupStyles[(type+'').toUpperCase()];
win.doSignal = callback;
win.$CTL = $CTL;
win.WRITE = WRITE;
win.SIGNAL = SIGNAL;
win.OFFSET_TO_CLIENT = OFFSET_TO_CLIENT;
win.ESCAPEXML = ESCAPEXML;
win.DESELECT_ITEM = (type == "DROPDOWN_LIST" ? DESELECT_ITEM : null);
if (type == 'CONTEXT_MENU') {
__POPUP.nestedPopups.push(pop);
win.__POPUP = {
level: level,
global: __POPUP.global,
allPopups: __POPUP.allPopups,
nestedPopups: __POPUP.nestedPopups,
timer: null,
popupStyles: __POPUP.popupStyles,
menuHandlers: __POPUP.menuHandlers
};
if($CTL) {
for (var k in $CTL.modules) {
win[k] = $CTL.modules[k];
}
}
for (var k in __POPUP.menuHandlers) {
win.execScript(k + ' = ' + __POPUP.menuHandlers[k]);
}
for (var k in __POPUP) {
if (typeof __POPUP[k] == 'function') {
win.execScript('__POPUP.'+ k + ' = ' + __POPUP[k]);
}
}
}else if ((type == 'UNDO_MENU')||(type == 'REDO_MENU')){
for (var k in __POPUP.transHandlers) {
win.execScript(k + ' = ' + __POPUP.transHandlers[k]);
}
}
else {
for (var k in __POPUP.popupHandlers) {
win.execScript(k + ' = ' + __POPUP.popupHandlers[k]);
}
}
}
var pop = __POPUP.allPopups[qtype];
var win = pop.document.parentWindow;
win.targetObject = target;
win.popupObject = pop;
function clean (){
if($CTL) {
for (var k in $CTL.modules) {
//win[k] = undefined;
};
}
win.detachEvent('onunload',clean);
}
(function (){win.attachEvent('onunload',clean);})();
return pop;
}
__POPUP.openPopup = function(level, data, target, align, dx, dy, descr) {
if(level==0 && __POPUP.callback != undefined) __POPUP.callback =null;
__POPUP.hideLevel(level+1);
// get popup data
var def;
if (data) {
if (typeof data == 'string' && typeof target != 'function') {
for (var e=target; e && !e.fnMenu; e=e.parentElement);
if (e) def = e.fnMenu(data, target);
if (!def) def=$ENV.getUserMenubar(data);
} else if (typeof data == 'object') {
def = data;
__POPUP.callback = target;
}
}
if (!def || def.length == 0) return __POPUP.hidePopup('CONTEXT_MENU');
// build popup
var pop = __POPUP.createPopup('CONTEXT_MENU', target, __POPUP.sendSignal, level);
var textHelper = $CTL.getHelper('TEXT');
for (var i=0, A=[], rows=def.length, w1=0, w2=0, h=4; i= rows-1) continue; // avoid spacer at end
var d2=def[i+1];
if (!d2 || !d2.text) continue; // avoid consecutive spacers
A.push('');
h += 5;
continue;
}
var sig = d.signal || d.id;
var lbl = d.text||'';
var key = d.key || '';
var mnu = d.menu ? ' menu="'+i+'"' : '';
var dis = __POPUP.testCond(d, 'disable');
var img = d.icon||'', imgStyle='';
var title = (d.tooltip? ' title="' + d.tooltip + '" ': '');
if (typeof sig != 'string') sig='';
if (!sig && !mnu) dis=true;
if (__POPUP.testCond(d, 'check')) img = '#URL[~skin:images.menu-check.gif]';
if (__POPUP.testCond(d, 'radio')) img = '#URL[~skin:images.menu-radio.gif]';
if (__POPUP.testCond(d, 'toggle')) { imgStyle += ' style="border:solid #[BR1] 1; background:#[WHT];"'; h += 2; }
if (dis) imgStyle += ' style="filter:alpha(opacity=50) gray();"';
img = '';
w1 = Math.max(w1,textHelper.getTextAndWidth(lbl, 'ITEM').width);
if (mnu) {
w2 = Math.max(w2,20);
key = '4';
} else if (key) {
w2 = Math.max(w2,textHelper.getTextAndWidth(lbl, 'ITEM').width);
key = ''+key+'';
}
h += 20;
A.push(''+key+img+lbl+'
');
}
var W=w1+w2+40, H=Math.min(h,408), X=parseInt(dx)||0, Y=parseInt(dy)||0;
var html='';
W+=3; H+=3;
var trgIsFunc = (typeof target == 'function');
if (target && !trgIsFunc) {
var offW = Math.max(parseInt(target.offsetWidth)||0,0);
var offH = Math.max(parseInt(target.offsetHeight)||0,0);
align = ((align || 'SCREEN')+'').toUpperCase();
if (align.indexOf('FITWIDTH') >= 0) W = offW - X;
if (align.indexOf('BOTTOM') >= 0) Y += offH;
if (align.indexOf('TOP') >= 0) Y -= H;
if (align.indexOf('RIGHT') >= 0) X += offW-W;
}
// open popup using a timer (to avoid screen flicker)
if (__POPUP.timer) clearTimeout(__POPUP.timer);
__POPUP.timer = setTimeout(function () {
var body = pop.document.body;
var obj = ((trgIsFunc || align == 'SCREEN') ? null : target);
body.innerHTML = html;
body.data = def ;
var point = trgIsFunc ? {x:X, y:Y} : OFFSET_TO_CLIENT(target, {x:X, y:Y});
var parentX = 0;
if(level > 0) { // nested popup
// point.x gives the left offset from the parent popup.
// consider the parent x when checking for available screen width.
// open the popup to the left of its parent if there isn't enough space:
parentX += __POPUP.global.levelX[level-1];
if (parentX + point.x + W >= window.screen.availWidth) {
X = -W + 3;
}
}
else {
if (point.x + W >= window.screen.availWidth) X -= W;
if (point.y + H >= window.screen.availHeight) Y -= H;
}
// save the x value of this popup:
__POPUP.global.levelX[level] = parentX + X;
pop.show(X, Y, W, H, obj);
__POPUP.timer=null;
}, 0);
return pop;
}
__POPUP.hidePopup = function(type) {
if (!type) {
for (var k in __POPUP.allPopups) __POPUP.allPopups[k].hide();
} else {
var pop=__POPUP.allPopups[type];
if (pop) pop.hide();
}
return null;
}
__POPUP.hideLevel= function(level) {
var P=__POPUP.nestedPopups;
if (P.length > level && P[level].isOpen) P[level].hide();
}
__POPUP.popupHandlers = {
'document.onmouseover': function() {
if (DESELECT_ITEM) DESELECT_ITEM();
var src = event.srcElement;
if (src.tagName != 'DIV') src=src.parentElement;
if (src.tagName != 'DIV') src=src.parentElement;
if (src && src.className == 'ITEM' && !src.disabled) src.className = 'OVER';
},
'document.onmouseout': function() {
var src = event.srcElement;
if (src.tagName != 'DIV') src=src.parentElement;
if (src.tagName != 'DIV') src=src.parentElement;
if (src && src.className == 'OVER' && !src.disabled) src.className = 'ITEM';
},
'document.body.onmouseleave': function() {
popupObject.hide();
},
'document.onclick': function() {
popupObject.hide();
var src=event.srcElement;
if (src.tagName != 'DIV') src=src.parentElement;
if (src.tagName != 'DIV') src=src.parentElement;
if (!src || src.disabled) return;
if ('DIV' == src.tagName && 'LIST' == src.className) {
var children = src.childNodes;
var child = null;
for (var i = 0, len = children.length; i < len; i++) {
child = children[i];
if (child && child.className == 'OVER') {
src = child;
break;
}
}
}
setTimeout(function() { doSignal(src, targetObject); }, 0);
},
'document.onkeydown': function() {
// Receives all the items in the popup list
var popDoc = popupObject.document;
var src = event.srcElement;
var divElements = popDoc.activeElement && popDoc.activeElement.children[0].children;
var evt = event;
switch(evt.keyCode) {
case #[UP]:
selectDiv(-1, divElements);
break;
case #[DOWN]:
selectDiv(1, divElements);
break;
case #[ENTER]:
popupObject.hide();
var selection = false;
for (var i in divElements) {
if (divElements[i].className == 'OVER') {
src = divElements[i];
selection = true;
break;
}
}
if (!src || src.disabled) return;
setTimeout(function() { doSignal(src, targetObject, !selection); }, 0);
break;
default:
// Hides the auto complete popup when hitting other keys
if (popDoc.body.all["autoSuggest"]) {
popupObject.hide();
}
break;
}
// Handles the UP and DOWN key events by selecting the right item in list
// The inc holds the increment of the marker +1 or -1
function selectDiv(inc, divElements) {
// Search for the selected item in the list
var pointer = -1;
var elmLen = divElements && divElements.length || 0;
for (var i = 0, len = elmLen; i < len; i++) {
if (divElements[i].className == 'OVER') {
pointer = i;
break;
}
}
// Clearing current selection
divElements[pointer>0 ? pointer : 0].className = 'ITEM';
var wantedIdx = (inc && (pointer + inc)) || 0;
// UP in the start of the list - gets the selection to the bottom
if (wantedIdx < 0) {
markSelectedDiv(divElements[elmLen-1]);
}
// DOWN in the end of the list - gets the selection to the top
else if (wantedIdx >= elmLen) {
markSelectedDiv(divElements[0]);
}
else {
// Skipping Space DIV
if (divElements[wantedIdx].className == 'SPC') {
wantedIdx += inc;
}
// Marks the item in the list after the key had been pressed
markSelectedDiv(divElements[wantedIdx]);
}
// Marks the item and scroll to it when scroll bar is enabled
function markSelectedDiv(val) {
val.className = 'OVER';
val.scrollIntoView();
}
}
},
'document.oncontextmenu': function() { return false; },
'document.onselectstart': function() { return false; }
}
__POPUP.transHandlers = {
'document.onmouseover': function() {
var src = event.srcElement;
if (src.tagName != 'DIV') src=src.parentElement;
if (src.tagName != 'DIV') src=src.parentElement;
if ((src.className != 'ITEM') && (src.className != 'OVER') ) return;
var parnt = src.parentElement;
var selected = parseInt(src.index);
var children = parnt.children;
if (selected == children.length-1) return //selected is the description
var child = null
for (var i = 0 ; i <= selected; i++)
{
child = children[i];
if (child ) child.className = 'OVER';
}
for (var i = selected+1, len = children.length; i < len ; i++)
{
child = children[i];
if(child) child.className = 'ITEM';
}
var description = children[children.length-1];
var text = '';
if(description.transName=='Undo')
{
text = (selected==0 ?
'#TEXT[XMIT_TRANS_OPERATION_UNDO]' :
'#TEXT[XMIT_TRANS_OPERATIONS_UNDO]'.replace('{0}', (selected+1)));
}
else
{
text = (selected==0 ?
'#TEXT[XMIT_TRANS_OPERATION_REDO]' :
'#TEXT[XMIT_TRANS_OPERATIONS_REDO]'.replace('{0}', (selected+1)));
}
description.innerText = text;
},
'document.body.onmouseleave': function() {
popupObject.hide();
},
'document.onclick': function() {
popupObject.hide();
var src=event.srcElement;
if (src.tagName != 'DIV') src=src.parentElement;
if (src.tagName != 'DIV') src=src.parentElement;
if (!src || src.disabled) return;
if ('DIV' == src.tagName && 'LIST' == src.className) {
var children = src.childNodes;
var child = null;
for (var i = children.length; i >= 0; i--) {
child = children[i];
if (child && child.className == 'OVER') {
src = child;
break;
}
}
}
var selected = parseInt(src.index);
setTimeout(function() { doSignal(selected+1); }, 0);
},
'document.oncontextmenu': function() { return false; },
'document.onselectstart': function() { return false; }
}
__POPUP.menuHandlers = {
'document.onmouseover': function() {
var src = event.srcElement;
if (event.fromElement && src.contains(event.fromElement)) return;
if (src.tagName != 'DIV') src=src.parentElement;
if (!src || !src.isItem || src.disabled) return;
if (src.className == 'ITEM') {
if (__POPUP.global.activeItem) __POPUP.global.activeItem.className = 'ITEM';
src.className = 'OVER';
__POPUP.global.activeItem = src;
} else {
if (__POPUP.level == __POPUP.global.lastLevel) return;
}
var level = __POPUP.level;
__POPUP.hideLevel(level+1);
if (src.menu !== undefined) {
var def = src.ownerDocument.body.data[parseInt(src.menu)];
var menu = def.menu;
if (typeof menu == 'function') menu = menu(def);
__POPUP.openPopup(level+1, menu, src, 'BOTTOM LEFT', src.offsetWidth-2, -src.offsetHeight-2, src.descr+'-');
}
},
'document.onmouseout': function() {
var src = event.srcElement;
if (event.toElement && src.contains(event.toElement)) return;
if (src.tagName != 'DIV') return;
if (!src || !src.isItem || src.disabled) return;
if (src.className == 'OVER') {
src.className = 'ITEM';
__POPUP.global.activeItem = null;
} else {
if (__POPUP.level == __POPUP.global.lastLevel) return;
}
},
'document.body.onmouseenter': function() {
__POPUP.global.lastLevel = __POPUP.level
},
'document.body.onmouseleave': function() {
if (__POPUP.level == __POPUP.global.lastLevel) {
__POPUP.hideLevel(0);
__POPUP.global.lastLevel = -1;
__POPUP.global.activeItem = null;
SIGNAL('BOARD->cancel');
}
},
'document.onclick': function() {
var src=event.srcElement;
if (src.tagName != 'DIV') src=src.parentElement;
if (!src || src.disabled || !src.index) return; // Yariv - check that src.index is valid (it isn't if its a seperator)
// if submenu don't signal a click: i040512
// and don't close the submenu (CSN#2823919)
var menu = src.document.body.data[src.index].menu;
if (menu) {
if (typeof menu == 'function') menu = menu(def);
__POPUP.openPopup(__POPUP.level+1, menu, src, 'BOTTOM LEFT', src.offsetWidth-2, -src.offsetHeight-2, src.descr+'-');
return;
}
__POPUP.hideLevel(0);
__POPUP.global.lastLevel = -1;
__POPUP.global.activeItem = null;
setTimeout(function() { doSignal(src, targetObject); }, 0);
},
'document.oncontextmenu': function() { return false; },
'document.onselectstart': function() { return false; }
}
__POPUP.sendSignal = function(src, trg, selEmpty) {
if (src.tagName != 'DIV') src=src.parentElement;
src.className = 'ITEM';
if (src.signal) {
if (typeof trg == 'function') {
try { trg(src.signal, POS(src.index), src.descr); }
catch(e) { #LOG[4, 'Error raising signal: '+e.description]; }
} else {
var data = src.document.body.data;
var cb = data[src.index] && data[src.index].callback ;
if (typeof cb == 'function'){
cb(src.signal);
} else if(__POPUP.global.callback && typeof __POPUP.global.callback == 'function') {
__POPUP.global.callback(src.signal, null, src.descr);
}else{
SIGNAL(src.signal);
}
}
}
__POPUP.hidePopup();
}
__POPUP.setField = function(src, trg, selEmpty) {
if (selEmpty) {
// when the ENTER key was pressed with no value selected from the list:
// since some controls has both editable text and list, we take the
// updated value from the text part.
// this is not relevant when trg is a function since in that case a
// value could be only taken from the list.
if (typeof trg != 'function') {
var val = trg.value;
if (val)
SET_INPUT(trg, val, true);
}
}
else {
src.className = 'ITEM';
if (typeof trg == 'function') {
try { trg(src.value); } catch(e) {}
}
else {
SET_INPUT(trg, src.value, true);
}
}
__POPUP.hidePopup();
}
__POPUP.testCond = function(def, attr) {
try {
var cond = def[attr];
if (cond === undefined || cond === null || cond === '') return cond;
if (typeof cond == 'function') return cond(def);
if (typeof cond == 'boolean') return cond;
if (typeof cond != 'string') return false;
cond = TRIM(cond);
if (cond.search(/^(true|false|yes|no|y|n)$/) == 0) return BOOL(cond);
return eval(cond);
} catch(e) {
WRITE('Error in popup item "'+def.sig+'" '+attr+' condition: '+e.message);
return false;
}
}
__POPUP.popupStyles = {
CONTEXT_MENU : "\
.MENU { position:absolute; left:0; top:0; width:100%; height:100%;\
background:#[WHT] repeat-y url(#URL[~skin:images.menu-bg.gif]); color:#[FG1]; border:solid #[BR1] 1;\
filter:progid:DXImageTransform.Microsoft.Shadow(color=#[BR1],strength:3, direction=135);\
overflow-x:hidden; overflow-y:auto; white-space:nowrap;\
font:normal 11px tahoma; padding:1 0 0 0; cursor:default; #[SCROLLBAR]; }\
.ITEM { padding:1 5 1 3; height:16; margin:0 1; }\
.OVER { padding:1 5 1 3; height:16; margin:0 1; background:#[SEL]; }\
.SPC { border-bottom:dashed #AAAAAA 1; padding:0; margin:2 1 2 1; font-size:1; }\
.KEY { float:right; margin-top:2; color:#[DIS]; }\
IMG { width:16; height:16; margin:1 9 1 1; }",
DROPDOWN_LIST : "\
.LIST { position:absolute; left:0; top:0; width:100%; height:100%;\
background:#[WHT]; color:#[BLK]; border:solid #[BR1] 1;\
overflow-x:hidden; overflow-y:auto; white-space:nowrap;\
font:normal 11px tahoma; padding:0; cursor:default; #[SCROLLBAR]; }\
.ITEM { padding:0 2; height:14; }\
.OVER { background:#[SEL]; padding:0 2; height:14; }",
POPUP_LIST : "\
.LIST { position:absolute; left:0; top:0; width:100%; height:100%;\
background:#[WHT]; color:#[BLK]; border:solid #[BR1] 1;\
overflow-x:hidden; overflow-y:auto; white-space:nowrap;\
font:normal 11px tahoma; padding:0; cursor:default; #[SCROLLBAR]; }\
.ITEM { padding:0 2; height:14; }\
.OVER { background:#[SEL]; padding:0 2; height:14; }",
AUTO_COMPLETE_LIST : "\
.LIST { width:100%; height:100%;\
background:#[WHT]; color:#[BLK]; border:solid #[BR1] 1;\
overflow-x:hidden; overflow-y:auto; white-space:nowrap;\
font:normal 11px tahoma; padding:0; cursor:default; #[SCROLLBAR]; }\
.INFO { width:100%; height:100%;\
background:#[WHT]; color:#[BLK]; cursor:default;\
font:normal 9px tahoma; padding:0;text-align: right;}\
.SPC { border:dashed #AAAAAA 1; padding:0; margin:2 1 2 1; font-size:1; }\
.ITEM { padding:0 2; height:14; }\
.OVER { background:#[SEL]; padding:0 2; height:14; }",
UNDO_MENU : "\
.LIST { position:absolute; left:0; top:0; width:100%; height:100%;\
background:#[WHT]; color:#[BLK]; border:solid #[BR1] 1;\
overflow-x:hidden; overflow-y:auto; white-space:nowrap;\
font:normal 11px tahoma; padding:0; cursor:default; #[SCROLLBAR]; }\
.ITEM { padding:0 2; height:14; }\
.DESC { height:14; }\
.OVER { background:#[SEL]; padding:0 2; height:14; }",
REDO_MENU : "\
.LIST { position:absolute; left:0; top:0; width:100%; height:100%;\
background:#[WHT]; color:#[BLK]; border:solid #[BR1] 1;\
overflow-x:hidden; overflow-y:auto; white-space:nowrap;\
font:normal 11px tahoma; padding:0; cursor:default; #[SCROLLBAR]; }\
.ITEM { padding:0 2; height:14; }\
.OVER { background:#[SEL]; padding:0 2; height:14; }",
POPUP_COLORS : "\
.LIST { position:absolute; left:0; top:0; width:100%; height:100%;\
background:#[WHT]; color:#[BLK]; border:solid #[BR1] 1; border-top:none; \
font:normal 11px tahoma; padding:0; overflow:hidden; cursor:default; }\
.ITEM { display:inline; border:solid #[WHT] 1; padding:0; height:10; width:10; font-size:1; }\
.OVER { display:inline; border:solid #[BR1] 1; padding:0; height:10; width:10; font-size:1; }"
}