📄 subpaneltiles.js
字号:
originalLayout = SUGAR.subpanelUtils.getLayout(true, true); }, // called when subpanel is dropped onDrop: function(e, id) { newLayout = SUGAR.subpanelUtils.getLayout(true, true); if(originalLayout != newLayout) { // only save if the layout has changed SUGAR.subpanelUtils.saveLayout(newLayout); } }, // save the layout of the subpanels saveLayout: function(order) { ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_SAVING_LAYOUT')); if(typeof SUGAR.subpanelUtils.currentSubpanelGroup != 'undefined') { var orderList = SUGAR.subpanelUtils.getLayout(false, true); var currentGroup = SUGAR.subpanelUtils.currentSubpanelGroup; } var success = function(data) { ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_SAVED_LAYOUT')); window.setTimeout('ajaxStatus.hideStatus()', 2000); if(typeof SUGAR.subpanelUtils.currentSubpanelGroup != 'undefined') { SUGAR.subpanelUtils.reorderSubpanelSubtabs(currentGroup, orderList); } } url = 'index.php?module=Home&action=SaveSubpanelLayout&layout=' + order + '&layoutModule=' + currentModule; if(typeof SUGAR.subpanelUtils.currentSubpanelGroup != 'undefined') { url = url + '&layoutGroup=' + SUGAR.subpanelUtils.currentSubpanelGroup; } var cObj = YAHOO.util.Connect.asyncRequest('GET', url, {success: success, failure: success}); }, // call for a after a inline create is saved inlineSave: function(theForm, subpanel) { ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_SAVING')); var success = function(data) { if(subpanel == 'projects') subpanel = 'project'; SUGAR.subpanelUtils.cancelCreate('subpanel_' + subpanel); var module = get_module_name(); var id = get_record_id(); var layout_def_key = get_layout_def_key(); try { eval('result = ' + data.responseText); } catch (err) { } if (typeof(result) != 'undefined' && result != null && typeof(result['status']) != 'undefined' && result['status'] !=null && result['status'] == 'dupe') { document.location.href = "index.php?" + result['get'].replace(/&/gi,'&'); return; } else { showSubPanel(subpanel, null, true); ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_SAVED')); window.setTimeout('ajaxStatus.hideStatus()', 1000); if(reloadpage) window.location.reload(false); } } // reload page if we are setting status to Held var reloadpage = false; if(subpanel == 'activities' && document.getElementById(theForm).status[document.getElementById(theForm).status.selectedIndex].value == 'Held') { reloadpage = true; } YAHOO.util.Connect.setForm(theForm, true, true); var cObj = YAHOO.util.Connect.asyncRequest('POST', 'index.php', {success: success, failure: success, upload:success}); return false; }, sendAndRetrieve: function(theForm, theDiv, loadingStr, subpanel) { function success(data) { theDivObj = document.getElementById(theDiv); subpanelContents[theDiv] = new Array(); subpanelContents[theDiv]['list'] = theDivObj; subpanelContents[theDiv]['newDiv'] = document.createElement('div'); subpanelContents[theDiv]['newDiv'].innerHTML = data.responseText; // fill the div theDivObj.style.display = 'none'; theDivObj.parentNode.insertBefore(subpanelContents[theDiv]['newDiv'], theDivObj); // if IE, evaluate the script on return if(isIE) SUGAR.util.evalScript(data.responseText); subpanelLocked[theDiv] = false; ajaxStatus.hideStatus(); } if(typeof subpanelLocked[theDiv] != 'undefined' && subpanelLocked[theDiv]) return false; subpanelLocked[theDiv] = true; if(typeof loadingStr == 'undefined') loadingStr = SUGAR.language.get('app_strings', 'LBL_LOADING'); ajaxStatus.showStatus(loadingStr); YAHOO.util.Connect.setForm(theForm); var cObj = YAHOO.util.Connect.asyncRequest('POST', 'index.php', {success: success, failure: success}); return false; }, cancelCreate: function(theDiv) { subpanelContents[theDiv]['newDiv'].parentNode.removeChild(subpanelContents[theDiv]['newDiv']); subpanelContents[theDiv]['list'].style.display = ''; return false; }, loadSubpanelGroupFromMore: function(group){ SUGAR.subpanelUtils.updateSubpanelMoreTab(group); SUGAR.subpanelUtils.loadSubpanelGroup(group); }, updateSubpanelMoreTab: function(group){ // Update Tab var moreTab = document.getElementById(SUGAR.subpanelUtils.subpanelMoreTab + '_sp_tab'); moreTab.id = group + '_sp_tab'; moreTab.getElementsByTagName('a')[0].innerHTML = group; moreTab.getElementsByTagName('a')[0].href = "javascript:SUGAR.subpanelUtils.loadSubpanelGroup('"+group+"');"; // Update Menu var menuLink = document.getElementById(group+'_sp_mm'); menuLink.id = SUGAR.subpanelUtils.subpanelMoreTab+'_sp_mm'; menuLink.href = "javascript:SUGAR.subpanelUtils.loadSubpanelGroupFromMore('"+SUGAR.subpanelUtils.subpanelMoreTab+"');"; menuLink.innerHTML = SUGAR.subpanelUtils.subpanelMoreTab; SUGAR.subpanelUtils.subpanelMoreTab = group; }, /* loadSubpanels: /* construct set of needed subpanels */ /* if we have not yet loaded this subpanel group, */ /* set loadedGroups[group] */ /* for each subpanel in subpanelGroups[group] */ /* if document.getElementById('whole_subpanel_'+subpanel) doesn't exist */ /* then add subpanel to set of needed subpanels */ /* if we need to load any subpanels, send a request for them */ /* with updateSubpanels as the callback. */ /* otherwise call updateSubpanels */ /* call setGroupCookie */ loadSubpanelGroup: function(group){ if(group == SUGAR.subpanelUtils.currentSubpanelGroup) return; if(SUGAR.subpanelUtils.loadedGroups[group]){ SUGAR.subpanelUtils.updateSubpanel(group); }else{ SUGAR.subpanelUtils.loadedGroups.push(group); var needed = Array(); for(group_sp in SUGAR.subpanelUtils.subpanelGroups[group]){ if(!document.getElementById('whole_subpanel_'+SUGAR.subpanelUtils.subpanelGroups[group][group_sp])){ needed.push(SUGAR.subpanelUtils.subpanelGroups[group][group_sp]); } } var success = function(){ SUGAR.subpanelUtils.updateSubpanelEventHandlers(needed); SUGAR.subpanelUtils.updateSubpanels(group); }; /* needed to retrieve each of the specified subpanels and install them ...*/ /* load them in bulk, insert via innerHTML, then sort nodes later. */ if(needed.length){ ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_LOADING')); SUGAR.util.retrieveAndFill(SUGAR.subpanelUtils.requestUrl + needed.join(','),'subpanel_list', null, success, null, true); }else{ SUGAR.subpanelUtils.updateSubpanels(group); } } SUGAR.subpanelUtils.setGroupCookie(group); }, /* updateSubpanels: /* for each child node of subpanel_list */ /* let subpanel name be id.match(/whole_subpanel_(\w*)/) */ /* if the subpanel name is in the list of subpanels for the current group, show it */ /* otherwise hide it */ /* swap nodes to suit user's order */ /* call updateSubpanelTabs */ updateSubpanels: function(group){ var sp_list = document.getElementById('subpanel_list'); for(sp in sp_list.childNodes){ if(sp_list.childNodes[sp].id){ sp_list.childNodes[sp].style.display = 'none'; } } for(group_sp in SUGAR.subpanelUtils.subpanelGroups[group]){ var cur = document.getElementById('whole_subpanel_'+SUGAR.subpanelUtils.subpanelGroups[group][group_sp]); cur.style.display = 'block'; /* use YDD swapNodes this and first, second, etc. */ try{ YAHOO.util.DDM.swapNode(cur, sp_list.getElementsByTagName('LI')[group_sp]); }catch(e){ } } SUGAR.subpanelUtils.updateSubpanelTabs(group); }, updateSubpanelTabs: function(group){ if(SUGAR.subpanelUtils.showLinks){ SUGAR.subpanelUtils.updateSubpanelSubtabs(group); document.getElementById('subpanelSubTabs').innerHTML = SUGAR.subpanelUtils.subpanelSubTabs[group]; } oldTab = document.getElementById(SUGAR.subpanelUtils.currentSubpanelGroup+'_sp_tab'); if(oldTab){ oldTab.className = ''; oldTab.getElementsByTagName('a')[0].className = ''; } mainTab = document.getElementById(group+'_sp_tab'); mainTab.className = 'active'; mainTab.getElementsByTagName('a')[0].className = 'current'; SUGAR.subpanelUtils.currentSubpanelGroup = group; ajaxStatus.hideStatus(); }, updateSubpanelEventHandlers: function(){ if(SubpanelInitTabNames){ SubpanelInitTabNames(SUGAR.subpanelUtils.getLayout(false)); } }, reorderSubpanelSubtabs: function(group, order){ SUGAR.subpanelUtils.subpanelGroups[group] = order; if(SUGAR.subpanelUtils.showLinks==1){ SUGAR.subpanelUtils.updateSubpanelSubtabs(group); if(SUGAR.subpanelUtils.currentSubpanelGroup == group){ document.getElementById('subpanelSubTabs').innerHTML = SUGAR.subpanelUtils.subpanelSubTabs[group]; } } }, // Re-renders the contents of subpanelSubTabs[group]. // Does not immediately affect what's on the screen. updateSubpanelSubtabs: function(group){ var notFirst = 0; var preMore = SUGAR.subpanelUtils.subpanelGroups[group].slice(0, SUGAR.subpanelUtils.subpanelMaxSubtabs); SUGAR.subpanelUtils.subpanelSubTabs[group] = '<table border="0" cellpadding="0" cellspacing="0" height="20" width="100%" class="subTabs"><tr>'; for(var sp_key = 0; sp_key < preMore.length; sp_key++){ if(notFirst != 0){ SUGAR.subpanelUtils.subpanelSubTabs[group] += '<td width="1"> | </td>'; }else{ notFirst = 1; } SUGAR.subpanelUtils.subpanelSubTabs[group] += '<td nowrap="nowrap"><a href="#'+preMore[sp_key]+'" class="subTabLink">'+SUGAR.subpanelUtils.subpanelTitles[preMore[sp_key]]+'</a></td>'; } if(document.getElementById('MoreSub'+group+'PanelMenu')){ SUGAR.subpanelUtils.subpanelSubTabs[group] += '<td nowrap="nowrap"> | <span class="subTabMore" id="MoreSub'+group+'PanelHandle" style="margin-left:2px; cursor: pointer; cursor: hand;" align="absmiddle" onmouseover="SUGAR.subpanelUtils.menu.tbspButtonMouseOver(this.id,\'\',\'\',0);">>></span></td>'; } SUGAR.subpanelUtils.subpanelSubTabs[group] += '<td width="100%"> </td></tr></table>'; // Update the more menu for the current group var postMore = SUGAR.subpanelUtils.subpanelGroups[group].slice(SUGAR.subpanelUtils.subpanelMaxSubtabs); var subpanelMenu = document.getElementById('MoreSub'+group+'PanelMenu'); if(postMore && subpanelMenu){ subpanelMenu.innerHTML = ''; for(var sp_key = 0; sp_key < postMore.length; sp_key++){ subpanelMenu.innerHTML += '<a href="#'+postMore[sp_key]+'" class="menuItem" parentid="MoreSub'+group+'PanelMenu" onmouseover="hiliteItem(this,\'yes\'); closeSubMenus(this);" onmouseout="unhiliteItem(this);">'+SUGAR.subpanelUtils.subpanelTitles[postMore[sp_key]]+'</a>'; } subpanelMenu += '</div>'; } }, setGroupCookie: function(group){ Set_Cookie(SUGAR.subpanelUtils.tabCookieName, group, 3000, false, false,false); } };}();SUGAR.subpanelUtils.menu = function(){ return { tbspButtonMouseOver : function(id,top,left,leftOffset){ //*// closeMenusDelay = eraseTimeout(closeMenusDelay); if (openMenusDelay == null){ openMenusDelay = window.setTimeout("SUGAR.subpanelUtils.menu.spShowMenu('"+id+"','"+top+"','"+left+"','"+leftOffset+"')", delayTime); } }, spShowMenu : function(id,top,left,leftOffset){ //*// openMenusDelay = eraseTimeout(openMenusDelay); var menuName = id.replace(/Handle/i,'Menu'); var menu = getLayer(menuName); //if (menu) menu.className = 'tbButtonMouseOverUp'; if (currentMenu){ closeAllMenus(); } SUGAR.subpanelUtils.menu.spPopupMenu(id, menu, top,left,leftOffset); }, spPopupMenu : function(handleID, menu, top, left, leftOffset){ //*// var bw = checkBrowserWidth(); var menuName = handleID.replace(/Handle/i,'Menu'); var menuWidth = 120; var imgWidth = document.getElementById(handleID).width; if (menu){ var menuHandle = getLayer(handleID); var p=menuHandle; if (left == "") { var left = 0; while(p&&p.tagName.toUpperCase()!='BODY'){ left+=p.offsetLeft; p=p.offsetParent; } left+=parseInt(leftOffset); } if (top == "") { var top = 0; p=menuHandle; top+=p.offsetHeight; while(p&&p.tagName.toUpperCase()!='BODY'){ top+=p.offsetTop; p=p.offsetParent; } } if (left+menuWidth>bw) { left = left-menuWidth+imgWidth; } setMenuVisible(menu, left, top, false); } } };}();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -