📄 sugar_3.js
字号:
} if (pageTotal >= 0) sugarListView.update_count(pageTotal); else if(value) sugarListView.update_count(count, true); else sugarListView.update_count(-1 * count, true);}sugarListView.check_all = sugarListView.prototype.check_all;sugarListView.confirm_action = sugarListView.prototype.confirm_action;sugarListView.prototype.check_boxes = function() { var inputsCount = 0; var checkedCount = 0; var existing_onload = window.onload; var theForm = document.MassUpdate; inputs_array = theForm.elements; if(typeof theForm.uid.value != 'undefined' && theForm.uid.value != "") { checked_items = theForm.uid.value.split(","); if (theForm.select_entire_list.value == 1) document.MassUpdate.massall.disabled = true; for(wp = 0 ; wp < inputs_array.length; wp++) { if(inputs_array[wp].name == "mass[]") { inputsCount++; if (theForm.select_entire_list.value == 1) { inputs_array[wp].checked = true; inputs_array[wp].disabled = true; checkedCount++; } else { for(i in checked_items) { if(inputs_array[wp].value == checked_items[i]) { checkedCount++; inputs_array[wp].checked = true; } } } } } if (theForm.select_entire_list.value == 0) sugarListView.update_count(checked_items.length); else sugarListView.update_count(0, true); } else { for(wp = 0 ; wp < inputs_array.length; wp++) { if(inputs_array[wp].name == "mass[]") { inputs_array[wp].checked = false; inputs_array[wp].disabled = false; } } if (document.MassUpdate.massall) { document.MassUpdate.massall.checked = false; document.MassUpdate.massall.disabled = false; } sugarListView.update_count(0) } if(checkedCount > 0 && checkedCount == inputsCount) document.MassUpdate.massall.checked = true;}sugarListView.prototype.send_mass_update = function(mode, no_record_txt, del) { formValid = check_form('MassUpdate'); if(!formValid) return false; if(!sugarListView.confirm_action(del)) return false; if (document.MassUpdate.select_entire_list && document.MassUpdate.select_entire_list.value == 1) mode = 'entire'; else if (document.MassUpdate.massall.checked == true) mode = 'page'; else mode = 'selected'; var ar = new Array(); if(del == 1) { var deleteInput = document.createElement('input'); deleteInput.name = 'Delete'; deleteInput.type = 'hidden'; deleteInput.value = true; document.MassUpdate.appendChild(deleteInput); } switch(mode) { case 'page': document.MassUpdate.uid.value = ''; for(wp = 0; wp < document.MassUpdate.elements.length; wp++) { if(typeof document.MassUpdate.elements[wp].name != 'undefined' && document.MassUpdate.elements[wp].name == 'mass[]' && document.MassUpdate.elements[wp].checked) { ar.push(document.MassUpdate.elements[wp].value); } } document.MassUpdate.uid.value = ar.join(','); if(document.MassUpdate.uid.value == '') { alert(no_record_txt); return false; } break; case 'selected': for(wp = 0; wp < document.MassUpdate.elements.length; wp++) { if(typeof document.MassUpdate.elements[wp].name != 'undefined' && document.MassUpdate.elements[wp].name == 'mass[]' && document.MassUpdate.elements[wp].checked) { ar.push(document.MassUpdate.elements[wp].value); } } if(document.MassUpdate.uid.value != '') document.MassUpdate.uid.value += ','; document.MassUpdate.uid.value += ar.join(','); if(document.MassUpdate.uid.value == '') { alert(no_record_txt); return false; } break; case 'entire': var entireInput = document.createElement('input'); entireInput.name = 'entire'; entireInput.type = 'hidden'; entireInput.value = 'index'; document.MassUpdate.appendChild(entireInput); //confirm(no_record_txt); break; } document.MassUpdate.submit(); return false;}sugarListView.prototype.clear_all = function() { document.MassUpdate.uid.value = ''; document.MassUpdate.select_entire_list.value = 0; sugarListView.check_all(document.MassUpdate, 'mass[]', false); document.MassUpdate.massall.checked = false; document.MassUpdate.massall.disabled = false; sugarListView.update_count(0);}sListView = new sugarListView();// -- end sugarListView class// format and unformat numbersfunction unformatNumber(n, num_grp_sep, dec_sep) { var x=unformatNumberNoParse(n, num_grp_sep, dec_sep); x=x.toString(); if(x.length > 0) { return parseFloat(x); } return '';}function unformatNumberNoParse(n, num_grp_sep, dec_sep) { if(typeof num_grp_sep == 'undefined' || typeof dec_sep == 'undefined') return n; n = n.toString(); if(n.length > 0) { n = n.replace(new RegExp(RegExp.escape(num_grp_sep), 'g'), '').replace(new RegExp(RegExp.escape(dec_sep)), '.'); return n; } return '';}// round parameter can be negative for decimal, precision has to be postivefunction formatNumber(n, num_grp_sep, dec_sep, round, precision) { if(typeof num_grp_sep == 'undefined' || typeof dec_sep == 'undefined') return n; n = n.toString(); if(n.split) n = n.split('.'); else return n; if(n.length > 2) return n.join('.'); // that's not a num! // round if(typeof round != 'undefined') { if(round > 0 && n.length > 1) { // round to decimal n[1] = parseFloat('0.' + n[1]); n[1] = Math.round(n[1] * Math.pow(10, round)) / Math.pow(10, round); n[1] = n[1].toString().split('.')[1]; } if(round <= 0) { // round to whole number n[0] = Math.round(parseInt(n[0]) * Math.pow(10, round)) / Math.pow(10, round); n[1] = ''; } } if(typeof precision != 'undefined' && precision >= 0) { if(n.length > 1 && typeof n[1] != 'undefined') n[1] = n[1].substring(0, precision); // cut off precision else n[1] = ''; if(n[1].length < precision) { for(var wp = n[1].length; wp < precision; wp++) n[1] += '0'; } } regex = /(\d+)(\d{3})/; while(regex.test(n[0])) n[0] = n[0].replace(regex, '$1' + num_grp_sep + '$2'); return n[0] + (n.length > 1 && n[1] != '' ? dec_sep + n[1] : '');}// --- begin ajax status classSUGAR.ajaxStatusClass = function() {};SUGAR.ajaxStatusClass.prototype.statusDiv = null;SUGAR.ajaxStatusClass.prototype.oldOnScroll = null;SUGAR.ajaxStatusClass.prototype.shown = false; // state of the status window// reposition the status div, top and centeredSUGAR.ajaxStatusClass.prototype.positionStatus = function() { this.statusDiv.style.top = document.body.scrollTop + 8 + 'px'; statusDivRegion = YAHOO.util.Dom.getRegion(this.statusDiv); statusDivWidth = statusDivRegion.right - statusDivRegion.left; this.statusDiv.style.left = YAHOO.util.Dom.getViewportWidth() / 2 - statusDivWidth / 2 + 'px';}// private func, create the status divSUGAR.ajaxStatusClass.prototype.createStatus = function(text) { statusDiv = document.createElement('div'); statusDiv.className = 'dataLabel'; statusDiv.style.background = '#ffffff'; statusDiv.style.color = '#c60c30'; statusDiv.style.position = 'absolute'; statusDiv.style.opacity = .8; statusDiv.style.filter = 'alpha(opacity=80)'; statusDiv.id = 'ajaxStatusDiv'; document.body.appendChild(statusDiv); this.statusDiv = document.getElementById('ajaxStatusDiv');}// public - show the status div with textSUGAR.ajaxStatusClass.prototype.showStatus = function(text) { if(!this.statusDiv) { this.createStatus(text); } else { this.statusDiv.style.display = ''; } this.statusDiv.innerHTML = ' <b>' + text + '</b> '; this.positionStatus(); if(!this.shown) { this.shown = true; this.statusDiv.style.display = ''; if(window.onscroll) this.oldOnScroll = window.onscroll; // save onScroll window.onscroll = this.positionStatus; }}// public - hide itSUGAR.ajaxStatusClass.prototype.hideStatus = function(text) { if(!this.shown) return; this.shown = false; if(this.oldOnScroll) window.onscroll = this.oldOnScroll; else window.onscroll = ''; this.statusDiv.style.display = 'none';}SUGAR.ajaxStatusClass.prototype.flashStatus = function(text, time){ this.showStatus(text); window.setTimeout('ajaxStatus.hideStatus();', time);}var ajaxStatus = new SUGAR.ajaxStatusClass();// --- end ajax status class/** * Unified Search Advanced - for global search */SUGAR.unifiedSearchAdvanced = function() { var usa_div; var usa_img; var usa_open; var usa_content; var anim_open; var anim_close; return { init: function() { SUGAR.unifiedSearchAdvanced.usa_div = document.getElementById('unified_search_advanced_div'); SUGAR.unifiedSearchAdvanced.usa_img = document.getElementById('unified_search_advanced_img'); if(!SUGAR.unifiedSearchAdvanced.usa_div || !SUGAR.unifiedSearchAdvanced.usa_img) return; SUGAR.unifiedSearchAdvanced.anim_open = new YAHOO.util.Anim('unified_search_advanced_div', { height: {to: 300} } ); SUGAR.unifiedSearchAdvanced.anim_open.duration = 0.75; SUGAR.unifiedSearchAdvanced.anim_close = new YAHOO.util.Anim('unified_search_advanced_div', { height: {to: 1} } ); SUGAR.unifiedSearchAdvanced.anim_close.duration = 0.75; SUGAR.unifiedSearchAdvanced.anim_close.onComplete.subscribe(function() {SUGAR.unifiedSearchAdvanced.usa_div.style.display = 'none'}); SUGAR.unifiedSearchAdvanced.usa_img._x = YAHOO.util.Dom.getX(SUGAR.unifiedSearchAdvanced.usa_img); SUGAR.unifiedSearchAdvanced.usa_img._y = YAHOO.util.Dom.getY(SUGAR.unifiedSearchAdvanced.usa_img); SUGAR.unifiedSearchAdvanced.usa_open = false; SUGAR.unifiedSearchAdvanced.usa_content = null; YAHOO.util.Event.addListener('unified_search_advanced_img', 'click', SUGAR.unifiedSearchAdvanced.get_content); }, get_content: function(e) { if(SUGAR.unifiedSearchAdvanced.usa_content == null) { ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_LOADING')); var cObj = YAHOO.util.Connect.asyncRequest('GET','index.php?to_pdf=1&module=Home&action=UnifiedSearch&usa_form=true', {success: SUGAR.unifiedSearchAdvanced.animate, failure: SUGAR.unifiedSearchAdvanced.animate}, null); } else SUGAR.unifiedSearchAdvanced.animate(); }, animate: function(data) { ajaxStatus.hideStatus(); if(data) { SUGAR.unifiedSearchAdvanced.usa_content = data.responseText; SUGAR.unifiedSearchAdvanced.usa_div.innerHTML = SUGAR.unifiedSearchAdvanced.usa_content; } if(SUGAR.unifiedSearchAdvanced.usa_open) { document.UnifiedSearch.advanced.value = 'false'; SUGAR.unifiedSearchAdvanced.anim_close.animate(); } else { document.UnifiedSearch.advanced.value = 'true'; SUGAR.unifiedSearchAdvanced.usa_div.style.display = ''; YAHOO.util.Dom.setX(SUGAR.unifiedSearchAdvanced.usa_div, SUGAR.unifiedSearchAdvanced.usa_img._x - 90); YAHOO.util.Dom.setY(SUGAR.unifiedSearchAdvanced.usa_div, SUGAR.unifiedSearchAdvanced.usa_img._y + 15); SUGAR.unifiedSearchAdvanced.anim_open.animate(); } SUGAR.unifiedSearchAdvanced.usa_open = !SUGAR.unifiedSearchAdvanced.usa_open; return false; }, checkUsaAdvanced: function() { if(document.UnifiedSearch.advanced.value == 'true') { document.UnifiedSearchAdvanced.query_string.value = document.UnifiedSearch.query_string.value; document.UnifiedSearchAdvanced.submit(); return false; } return true; }};}();if(typeof YAHOO != 'undefined') YAHOO.util.Event.addListener(window, 'load', SUGAR.unifiedSearchAdvanced.init);SUGAR.ui = { /** * Toggles the header */ toggleHeader : function() { var h = document.getElementById('header'); if(h != null) { if(h != null) { if(h.style.display == 'none') { h.style.display = ''; } else { h.style.display = 'none'; } } } else { alert(SUGAR.language.get("app_strings", "ERR_NO_HEADER_ID")); } }};/** * General Sugar Utils */SUGAR.util = function () { var additionalDetailsCache; var additionalDetailsCalls; var additionalDetailsRpcCall; return { evalScript:function(text){ var objRegex = /<\s*script([^>]*)>((.|\s|\v|\0)*?)<\s*\/script\s*>/igm; var lastIndex = -1; var result = objRegex.exec(text); while(result && result.index > lastIndex){ lastIndex = result.index try{ var script = document.createElement('script'); script.type= 'text/javascript'; if(result[1].indexOf("src=") > -1){ var srcRegex = /.*src=['"]([a-zA-Z0-9\&\/\.\?=]*)['"].*/igm; var srcResult = result[1].replace(srcRegex, '$1'); script.src = srcResult; }else{ script.text = result[2]; } document.body.appendChild(script) } catch(e) { } result = objRegex.exec(text); } }, /** * Gets the sidebar object * @return object pointer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -