/ * TransModal.dialog()方法 *有四个可选参数: * * dlgPrompt:提示HTML代码 * dlgButtonSet:按钮设置 * dlgDefaultButton:默认焦点 * dlgListener:调用函数 * / TransModal.dialog = function(dlgPrompt, dlgButtonSet, dlgDefaultButton, dlgListener ){$ / $ / *设置缺少参数的默认值。 * / if(typeof dlgPrompt!= ''string''){ dlgPrompt =''< p> TransModal v。''。concat( TransModal.reportVersion(),''< / p>''); } if(typeof dlgButtonSet!=''number''){ dlgButtonSet = 0; } if((typeof dlgDefaultButton!=''number'')|| (dlgDefaultButton> = TransModal。 buttonSet [dlgButtonSet] .length)){ dlgDefaultButton = 0; } if(typeof dlgListener!=''function''){ TransModal.notifyObserver = TransModal.loopHole; } else { TransModal.notifyObserver = dlgListener; } / *存储的中间变量 * clientWidth和clientHeight值。 * / var w = document.documentElement.clientWidth; var h = document.documentElement.clientHeight ; / *设置封面。 * / var cover = = new Function(''id'',''return document.getElementById(id)'');} /* It would be nice to have button labels on* user''s preferred language and not English* only.* navigator.userLanguage (IE) and* navigator.language (some other UAs) values* may have different meanings: OS language,* or browser interface language, or the preferred* language in the browser settings. Either way* IMHO it still allows to make a good guess what* language the current user would like to see.* If the detected language is not implemented yet* then English is used by default.* For such basic lexicon as "Yes", "No", "Cancel" etc.* we may disregard country-specific variations, so we* are taking only two first letters from the language* code - so say "en", "en_US", "en_GB" will be "en".**? Objections?*/ if (''userLanguage'' in navigator) {var lang = navigator.userLanguage.substring(0,2);}else if (''language'' in navigator) {var lang = navigator.language.substring(0,2);}else {var lang = ''en'';} TransModal.lang = (lang in TransModal.buttonLabelSet) ?lang : ''en''; /* Creating and adding dialog window template.* Additional dialog styling may be applied* over DIV#TransModalDialog CSS rule set.*/ var wndDialog = document.createElement(''DIV''); wndDialog.id = ''TransModalDialog''; /* Some complex styling of a completely empty element* may make IE to act strange. To avoid that we are* setting the default content to NO-BREAK SPACE*/wndDialog.innerHTML = ''<span>\u00A0</span>''; with (wndDialog.style) {position = ''absolute'';zIndex = ''1002'';left = ''0px'';top = ''0px'';cursor = ''default'';visibility = ''hidden'';} document.body.appendChild(wndDialog); /* Creating and adding the cover sheet.* The cover sheet is NOT supposed to* be styled by external CSS rules. All* what it needs is being made by script.*/ var wndCover = document.createElement(''DIV''); wndCover.id = ''TransModalVeil''; wndCover.innerHTML = ''<span>\u00A0</span>''; with (wndCover.style) {position = ''absolute'';zIndex = ''1001'';left = ''0px'';top = ''0px'';margin = ''0px 0px'';padding = ''0px 0px'';borderStyle = ''none'';cursor = ''not-allowed'';visibility = ''hidden'';} /* Pre-apply alpha filter for IE.*/if (TransModal.isIE) {wndCover.style.filter = ''''.concat(''progid:DXImageTransform.Microsoft.Alpha(Opacity='' ,Math.floor(TransModal.coverOpacity * 100), '',Style=0)'');} document.body.appendChild(wndCover);} /************** TransModal methods **************/ /* TransModal.dialog() method that* takes four optional arguments:** dlgPrompt : prompt HTML code* dlgButtonSet : button set* dlgDefaultButton : default focus* dlgListener : function to call*/ TransModal.dialog = function(dlgPrompt,dlgButtonSet,dlgDefaultButton,dlgListener) { /* Setting defaults for missing arguments.*/ if (typeof dlgPrompt != ''string'') {dlgPrompt = ''<p>TransModal v.''.concat(TransModal.reportVersion(), ''</p>'');} if (typeof dlgButtonSet != ''number'') {dlgButtonSet = 0;} if ((typeof dlgDefaultButton != ''number'') ||(dlgDefaultButton >= TransModal.buttonSet[dlgButtonSet].length)) {dlgDefaultButton = 0;} if (typeof dlgListener != ''function'') {TransModal.notifyObserver = TransModal.loopHole;}else {TransModal.notifyObserver = dlgListener;} /* Intermediary variables to store* clientWidth and clientHeight values.*/ var w = document.documentElement.clientWidth;var h = document.documentElement.clientHeight; /* Setting the cover.*/ var cover = 这篇关于TransModal模态对话项目:beta测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-22 22:12