From 65c761bd2e5964c9d48df51e3219611b3ab7c10b Mon Sep 17 00:00:00 2001 From: Catouse Date: Tue, 29 May 2018 09:44:16 +0800 Subject: [PATCH] * refactor codes. --- module/bug/js/view.js | 4 - www/js/my.full.js | 883 ++++-------------------------------------- 2 files changed, 80 insertions(+), 807 deletions(-) diff --git a/module/bug/js/view.js b/module/bug/js/view.js index c86a31e59b..e69de29bb2 100644 --- a/module/bug/js/view.js +++ b/module/bug/js/view.js @@ -1,4 +0,0 @@ -function setModal4List(colorboxClass, replaceID) -{ - if(config.onlybody != 'yes') $('.iframe').modalTrigger({width:900, type:'iframe', afterHide:function(){location.href=location.href;}}) -} diff --git a/www/js/my.full.js b/www/js/my.full.js index 1854bbc05f..b857efa528 100644 --- a/www/js/my.full.js +++ b/www/js/my.full.js @@ -1,81 +1,3 @@ -// /** -// * Bind Event for searchbox -// * -// */ -// function setSearchBox() -// { -// $('#searchTypeMenu a').click(function() -// { -// $('#searchTypeMenu li.selected').removeClass('selected'); -// var $this = $(this); -// $this.closest('li').addClass('selected'); -// $("#searchType").val($this.data('value')); -// $("#searchTypeName").text($this.text()); -// }); -// } - -// /** -// * Go to the view page of one object. -// * -// * @access public -// * @return void -// */ -// function shortcut() -// { -// objectType = $('#searchType').attr('value'); -// objectValue = $("input#searchInput").attr('value'); -// if(objectType && objectValue) -// { -// method = objectType == 'testsuite' ? 'library' : 'view'; -// location.href=createLink(objectType, method, "id=" + objectValue); -// } -// } - -/** - * Show search drop menu. - * - * @param string $objectType product|project - * @param int $objectID - * @param string $module - * @param string $method - * @param string $extra - * @access public - * @return void - */ -function showSearchMenu(objectType, objectID, module, method, extra) -{ - var $toggle = $(objectType == 'branch' ? '#currentBranch' : (objectType == 'tree' ? '#currentModule' : '#currentItem')).closest('.btn-group').toggleClass('open'); - if(!$toggle.hasClass('open')) return; - var $menu = $toggle.find('#dropMenu'); - var uuid = $.zui.uuid(); - if(!$.cookie('ajax_quickJump')) - { - $.cookie('ajax_quickJump', 'on', {expires: config.cookieLife, path: config.webRoot}); - $.get(createLink('score', 'ajax', "method=quickJump")); - } - - if(!$menu.data('initData')) - { - var remoteUrl = createLink(objectType, 'ajaxGetDropMenu', "objectID=" + objectID + "&module=" + module + "&method=" + method + "&extra=" + extra); - $.get(remoteUrl, function(data){ $menu.html(data); }); - $menu.data('initData', true); - $toggle.on('click', function(e){e.stopPropagation();}); - } -} - -/** - * Show or hide more items. - * - * @access public - * @return void - */ -function switchMore() -{ - $('#search').width($('#search').width()).focus(); - $('#moreMenu').width($('#defaultMenu').outerWidth()); - $('#searchResult').toggleClass('show-more'); -} - /** * Switch doc library. * @@ -117,38 +39,6 @@ function setPing() $('#hiddenwin').attr('src', createLink('misc', 'ping')); } -/** - * Set required fields, add star class to them. - * - * @access public - * @return void - */ -function setRequiredFields() -{ - if(config.requiredFields) - { - requiredFields = config.requiredFields.split(','); - for(i = 0; i < requiredFields.length; i++) - { - var $ctlEle = $('#' + requiredFields[i]); - var $ctlParent = $ctlEle.parent(); - if($ctlParent.hasClass('input-group') && $ctlParent.find('input').length > 1) - { - var $requiredDiv = $('
'); - $ctlEle.after($requiredDiv); - $requiredDiv.find('.required').append($ctlEle); - if($ctlEle.is('select')) $requiredDiv.addClass('fix-pd-right'); - } - else - { - $ctlEle.closest('td,th').prepend("
"); - var $colEle = $ctlEle.closest('[class*="col-"]'); - if($colEle.parent().hasClass('form-group')) $colEle.addClass('required'); - } - } - } - $('.required').closest('td,th').next().css('padding-left', '15px'); -} // /** // * Set the help links of forum's items. @@ -195,84 +85,19 @@ function setPlaceholder() } } -/** - * Toggle the help links. - * - * @access public - * @return void - */ -function toggleHelpLink() -{ - $('.helplink').toggle(); - if($.cookie('help') == 'off') return $.cookie('help', 'on', {expires:config.cookieLife, path:config.webRoot}); - if($.cookie('help') == 'on') return $.cookie('help', 'off', {expires:config.cookieLife, path:config.webRoot}); -} +// /** +// * Toggle the help links. +// * +// * @access public +// * @return void +// */ +// function toggleHelpLink() +// { +// $('.helplink').toggle(); +// if($.cookie('help') == 'off') return $.cookie('help', 'on', {expires:config.cookieLife, path:config.webRoot}); +// if($.cookie('help') == 'on') return $.cookie('help', 'off', {expires:config.cookieLife, path:config.webRoot}); +// } -/** - * Hide tree box - * - * @param string $treeType - * @access public - * @return void - */ -function hideTreeBox(treeType) -{ - $.cookie(treeType, 'hide', {expires:config.cookieLife, path:config.webRoot}); - $('.outer').addClass('hide-side'); - var direction = $('.side-handle .icon-caret-left').size() > 0 ? 'left' : 'right'; - $('.side-handle .icon-caret-' + direction).removeClass('icon-caret-' + direction).addClass('icon-caret-' + (direction == 'left' ? 'right' : 'left')); -} - -/** - * Show tree box - * - * @param string $treeType - * @access public - * @return void - */ -function showTreeBox(treeType) -{ - $.cookie(treeType, 'show', {expires:config.cookieLife, path:config.webRoot}); - $('.outer').removeClass('hide-side'); - var direction = $('.side-handle .icon-caret-left').size() > 0 ? 'left' : 'right'; - $('.side-handle .icon-caret-' + direction).removeClass('icon-caret-' + direction).addClass('icon-caret-' + (direction == 'left' ? 'right' : 'left')); -} - -/** - * set tree menu. - - * @access public - * @return void - */ -function setTreeBox() -{ - var $handle = $('.side-handle'); - if($handle.data('setted')) return; - - var treeType = $handle.data('id'); - if(treeType) - { - if($.cookie(treeType) == 'hide') hideTreeBox(treeType); - - $handle.toggle - ( - function() - { - if($.cookie(treeType) == 'hide') return showTreeBox(treeType); - hideTreeBox(treeType); - }, - function() - { - if($.cookie(treeType) == 'show') return hideTreeBox(treeType); - showTreeBox(treeType); - } - ).data('setted', true); - } - - if($('.outer > .side').length) $('.outer').addClass('with-side'); - setTimeout(function(){$('.outer.with-side').addClass('with-transition')}, 1000); - adjustOuterSize(); -} /** * Set language. @@ -328,34 +153,6 @@ function removeAnchor(url) // $.cookie('windowHeight', height) // } -/** - * Adjust Outer box's width and height. - * - * @access public - * @return void - */ -function adjustOuterSize() -{ - var side = $('#wrap .outer > .side'); - var sideH = side.length ? (side.outerHeight() + $('#featurebar').outerHeight() + 20) : 0; - var height = Math.max(sideH, $(window).height() - $('#header').outerHeight() - ($('#footer').outerHeight() || 0) - 20); - if(navigator.userAgent.indexOf("MSIE 8.0") >= 0) height -= 40; - $('#wrap .outer').css('min-height', height); -} - -/** - * Set Outer box's width and height. - * - * @access public - * @return void - */ -function setOuterBox() -{ - var side = $('#wrap .outer > .side'); - side.resize(adjustOuterSize); - $(window).resize(adjustOuterSize); - adjustOuterSize(); -} /** * Disable the submit button when submit form. @@ -365,7 +162,7 @@ function setOuterBox() */ function setForm() { - // if(config.debug) alert('[Zentao-ZUI 通知] setForm 方法已被弃用,为表单元素 form 添加 [type="ajax"] 或者 .ajax-form 来自动配置 Ajax 表单。'); + if(config.debug) alert('[Zentao-ZUI 通知] setForm 方法已被弃用,为表单元素 form 添加 [type="ajax"] 或者 .ajax-form 来自动配置 Ajax 表单。'); var formClicked = false; $('form').submit(function() @@ -412,7 +209,7 @@ function setForm() */ function setFormAction(actionLink, hiddenwin, obj) { - // if(config.debug) alert('[Zentao-ZUI 通知] setFormAction 方法已被弃用,在表单中使用如下格式会自动初始化表单提交按钮:\n编辑'); + if(config.debug) alert('[Zentao-ZUI 通知] setFormAction 方法已被弃用,在表单中使用如下格式会自动初始化表单提交按钮:\n编辑'); $form = typeof(obj) == 'undefined' ? $('form') : $(obj).closest('form'); if(hiddenwin) $form.attr('target', hiddenwin); @@ -499,189 +296,15 @@ function ajaxGetContacts(obj) link = createLink('user', 'ajaxGetContactList'); $.get(link, function(contacts) { - if(!contacts) return false; + if(!contacts) return false; - $inputgroup = $(obj).closest('.input-group'); - $inputgroup.find('.input-group-btn').remove(); - $inputgroup.append(contacts); - $inputgroup.find('select:last').chosen(defaultChosenOptions).fixInputGroup(); + $inputgroup = $(obj).closest('.input-group'); + $inputgroup.find('.input-group-btn').remove(); + $inputgroup.append(contacts); + $inputgroup.find('select:last').chosen(defaultChosenOptions).fixInputGroup(); }); } -/** - * Set comment. - * - * @access public - * @return void - */ -function setComment() -{ - $('#commentBox').toggle(); - $('.ke-container').css('width', '100%'); - setTimeout(function() { $('#commentBox textarea').focus(); }, 50); -} - -/** - * Make table checkable by click row - * - * @param $table - * @access public - * @return void - */ -function checkTable($table) -{ - $(document).off('change.checktable').on('change.checktable', '.rows-selector:checkbox', function() - { - var $checkbox = $(this); - var $datatable = $checkbox.closest('.datatable'); - if($datatable.length) - { - var $checkAll = $datatable.find('.check-all.check-btn:first').trigger('click'); - $checkbox.prop('checked', $checkAll.hasClass('checked')) - return; - } - var scope = $checkbox.data('scope'); - var $target = scope ? $('#' + scope) : $checkbox.closest('.table'); - var isChecked = $checkbox.prop('checked'); - $target.find('tbody > tr').toggleClass('active', isChecked).find('td :checkbox').prop('checked', isChecked); - }); - - $table = $table || $('.table-selectable,table[checkable="true"]'); - - if(!$table.length) return; - - if(!$table.find(':checkbox').length) - { - $table.on('click', 'tbody > tr', function() - { - $table.find('tr.active').removeClass('active'); - $(this).addClass('active'); - }); - return; - } - - var checkRow = function(checked) - { - if(document.activeElement.type != 'select-one' && document.activeElement.type != 'text') - { - var $this = $(this); - var $tr = $this.closest('tr'); - var $checkbox = $tr.find(':checkbox'); - if($checkbox.size() == 0) return; - - var isChecked = $checkbox.prop('checked'); - if(!$this.is(':checkbox')) - { - if(!$.cookie('ajax_dragSelected') && $checkbox.size() > 2) - { - $.cookie('ajax_dragSelected', 'on', {expires: config.cookieLife, path: config.webRoot}); - $.get(createLink('score', 'ajax', "method=dragSelected")); - } - isChecked = checked === true || checked === false ? checked : !isChecked; - $checkbox.prop('checked', isChecked); - } - if(!$tr.hasClass('.active-disabled')) { - $tr.toggleClass('active', isChecked); - } - $tr.closest('.table').find('.rows-selector').prop('checked', false); - } - }; - var isSelectableTable = $table.hasClass('table-selectable'); - - $table.selectable( - { - selector: 'tbody > tr', - trigger: 'tbody', - ignoreVal: 10, - start: function(e) - { - if($(e.target).is(':checkbox,a')) return false; - var that = this; - that.selections = {}; - that.$.find('tbody > tr').each(function(idx) - { - var $tr = $(this); - if($tr.hasClass(that.options.selectClass)) - { - that.selections[$tr.data('id')] = idx + 1; - } - }); - }, - clickBehavior: 'multi', - startDrag: function(e) - { - if(!this.multiKey && isSelectableTable && !$(e.target).closest('.cell-id').length) return false; - }, - select: function(e) - { - checkRow.call(e.target, true); - }, - unselect: function(e) - { - checkRow.call(e.target, false); - } - }).on('click', 'tbody > tr :checkbox', function(e){checkRow.call(this); e.stopPropagation();}).on('click mousedown mousemove mouseup', 'tbody a,tbody select,tbody input', function(e) {e.stopPropagation();}); -} - -/** - * Toogle the search form. - * - * @access public - * @return void - */ -// function toggleSearch() -// { -// $("#bysearchTab").toggle -// ( -// function() -// { -// if(typeof(browseType) == 'undefined' || browseType == 'bymodule') -// { -// $('#bymoduleTab').removeClass('btn-active-text'); -// } -// else -// { -// $('#' + browseType + 'Tab').removeClass('btn-active-text'); -// } -// $('#bysearchTab').addClass('btn-active-text'); -// ajaxGetSearchForm(); -// $('#queryBox').addClass('show'); -// }, -// function() -// { -// if(typeof(browseType) == 'undefined' || browseType == 'bymodule') -// { -// $('#bymoduleTab').addClass('btn-active-text'); -// } -// else -// { -// $('#' + browseType +'Tab').addClass('btn-active-text'); -// } -// $('#bysearchTab').removeClass('btn-active-text'); -// $('#queryBox').removeClass('show'); -// } -// ); -// } - -/** - * Ajax get search form - * - * @access public - * @return void - */ -function ajaxGetSearchForm(querybox) -{ - var $querybox = $(querybox || '#queryBox'); - if($querybox.html() == '') - { - $.get(createLink('search', 'buildForm'), function(data) - { - $querybox.html(data); - $querybox.addClass('show'); - }); - } -} - /** * add one option of a select to another select. * @@ -862,126 +485,6 @@ function isNum(s) return false; } -/** - * Set modal for list page. - * - * Open operation pages in modal for list pages, after the modal window close, reload the list content and repace the replaceID. - * - * @param string triggerClass the class for colorbox binding. - * @param string replaceID the html object to be replaced. - * @access public - * @return void - */ -function setModal4List(triggerClass, replaceID, callback, width) -{ - // if(config.debug) return alert('[Zentao-ZUI 通知] setModal4List 方法已被禁用,如果要为表格列表启用表格内触发打开的对话框关闭后动态更新列表有如下两种方式:\n1. 使用 hot 选项初始化 table 插件:
\n2. 在对话框表单POST请求后返回内容中设置 selfClose cookie 值为 1:'); - if(typeof(width) == 'undefined') width = 900; - $('.' + triggerClass).modalTrigger( - { - width: width, - type: 'iframe', - - afterHide:function() - { - var selfClose = $.cookie('selfClose'); - if(selfClose != 1) return; - saveWindowSize(); - - if(typeof(replaceID) == 'string' && replaceID.length > 0) - { - $.cancelReloadCloseModal(); - - var link = self.location.href; - var idQuery = '#' + replaceID; - $(idQuery).wrap("
"); - $('#tmpDiv').load(link + ' ' + idQuery, function() - { - $('#tmpDiv').replaceWith($('#tmpDiv').html()); - setTimeout(function(){setModal4List(triggerClass, replaceID, callback, width);},150); - - var $list = $(idQuery), $datatable = $('#datatable-' + $list.attr('id')); - if($list.hasClass('datatable') && $datatable.length && $.fn.datatable) - { - $list.hide(); - $datatable.data('zui.datatable').load(idQuery); - } - - $list.find('[data-toggle=modal], a.iframe').modalTrigger(); - try - { - $('.date').datetimepicker(datepickerOptions); - } - catch(err){} - - if($list.is('.table-selectable:not(.table-datatable)')) checkTable($list); - else $list.find('tbody tr:not(.active-disabled) td').click(function(){$(this).closest('tr').toggleClass('active');}); - - if($.isFunction(callback)) callback($list); - $.cookie('selfClose', 0); - }); - } - else if($.isFunction(callback)) callback(); - } - }); -} - -// /** -// * Set checked in cookie. -// * -// * @access public -// * @return void -// */ -// function setCheckedCookie() -// { -// var checkeds = ''; -// $(':checkbox').each(function() -// { -// if($(this).attr('checked')) -// { -// if(!isNaN($(this).val())) -// { -// var checkedVal = parseInt($(this).val()); -// if(checkedVal != 0) checkeds = checkeds + checkedVal + ','; -// } -// } -// }) -// if(checkeds != '') checkeds = checkeds.substring(0, checkeds.length - 1); -// $.cookie('checkedItem', checkeds, {expires:config.cookieLife, path:config.webRoot}); -// } - -/** - * Set table behavior - * - * @access public - * @return void - */ -function setTableBehavior() -{ - $('#wrap .outer > .table, #wrap .outer > form > .table, #wrap .outer > .mian > .table, #wrap .outer > .mian > form > .table, #wrap .outer > .container > .table').not('.table-data, .table-form, .table-custom').addClass('table table-condensed table-hover table-striped tablesorter').each(function() - { - var $tbody = $(this).children('tbody'); - if(!$tbody.children().length) $tbody.remove(); - }); - - $(document).on('click', 'tr[data-url]', function() - { - var url = $(this).data('url'); - if(url) window.location.href = url; - }); -} - -/** - * Fix style - * - * @access public - * @return void - */ -function fixStyle() -{ - var $actions = $('#titlebar > .actions'); - if($actions.length) $('#titlebar > .heading').css('padding-right', $actions.width()); -} - /** * Start cron. * @@ -1058,100 +561,11 @@ function checkOnlybodyPage() } } -/** - * Fixed tfoot action like productplan,release. - * - * @param string $formID - * @access public - * @return void - */ -function fixedTfootAction(formID) -{ - var $form = $(formID); - if(!$form.length) return false; - var $table = $form.find('table:last'); - var $tfoot = $table.find('tfoot'); - if($table.hasClass('table-datatable')) - { - $table = $form.find('.datatable-rows'); - $tfoot = $form.find('.datatable-footer tfoot'); - } - if(!$tfoot.length) return false; - - var $tbody = $table.find('tbody'), - $inputGroup = $tfoot.find('.table-actions').children('.input-group'), - pageFooterHeight = $('#footer').height(), - tableWidth, - tableOffset, - hasFixed; - if(!$tbody.length) return false; - if(typeof(ssoRedirect) != "undefined") pageFooterHeight = 0; - function fixTfoot() - { - var $table = $form.find('table:last'); - var $tfoot = $table.find('tfoot'); - if($table.hasClass('table-datatable')) - { - $table = $form.find('.datatable-rows'); - $tfoot = $form.find('.datatable-footer tfoot'); - } - - $tbody = $table.find('tbody'), - $inputGroup = $tfoot.find('.table-actions').children('.input-group'), - pageFooterHeight = $('#footer').height(), - - tableWidth = $table.width(); - hasFixed = $tfoot.hasClass('fixedTfootAction'); - offsetHeight = $(window).height() + $(window).scrollTop() - pageFooterHeight/2; - tableOffset = $tbody.offset().top + $tbody.height() + $tfoot.height(); - - if(!hasFixed && offsetHeight <= tableOffset) - { - $tfoot.addClass('fixedTfootAction') - .width(tableWidth) - .find('td').width(tableWidth); - if($inputGroup.size() > 0) $inputGroup.width($inputGroup.width()); - } - if(hasFixed && (offsetHeight > tableOffset || $(document).height() == offsetHeight)) - { - $tfoot.removeClass('fixedTfootAction') - .removeAttr('style') - .find('td').removeAttr('style'); - } - } - function fixTfootInit() - { - if($tfoot.hasClass('fixedTfootAction')) $tfoot.removeClass('fixedTfootAction'); - fixTfoot(); - } - - fixTfootInit(); - var scrollCallTask; - $(window).scroll(function() - { - // Fix table foot when scrolling. - fixTfoot(); - - var $table = $form.find('table:last'); - var $tfoot = $table.find('tfoot'); - if($table.hasClass('table-datatable')) - { - $table = $form.find('.datatable-rows'); - $tfoot = $form.find('.datatable-footer tfoot'); - } - - $tfoot.addClass('scrolling scrolled'); - clearTimeout(scrollCallTask); - scrollCallTask = setTimeout(function(){$tfoot.removeClass('scrolling');}, 200) - }).resize(fixTfoot); - $('.side-handle').click(function(){setTimeout(fixTfootInit, 300);}); // Fix table foot if module tree is hidden or displayed. -} - /** * Fixed table head in div box. * * @param string $boxObj - * @access public + * @access public * @return void */ function fixedTableHead(boxObj) @@ -1215,54 +629,6 @@ function fixedTheadOfList(tableID) } } -/** - * Init prioprity selectors - * @return void - */ -function initPrioritySelector() -{ - $('.dropdown-pris').each(function() - { - var $dropdown = $(this); - var prefix = $dropdown.data('prefix') || 'pri'; - var $select = $dropdown.find('select'); - var selectVal = parseInt($select.hide().val()); - var $menu = $dropdown.children('.dropdown-menu'); - if(!$menu.length) - { - $menu = $(''); - $dropdown.append($menu); - } - if(!$menu.children('li').length) - { - var set = $select.children('option').map(function() {return parseInt($(this).val());}).get(); - if(!set || !set.length) - { - set = $dropdown.data('set'); - set = set ? set.split(',') : [0,1,2,3,4]; - } - set.sort(function(a,b){return a - b}); - for(var i = 0; i < set.length; ++i) - { - var v = set[i]; - $menu.append('
  • ' + (v ? v : '') + '
  • '); - } - } - $menu.find('a[data-pri="' + selectVal + '"]').parent().addClass('active'); - $dropdown.find('.pri-text').html('' + (selectVal ? selectVal : '') + ''); - - $dropdown.on('click', '.dropdown-menu > li > a', function() - { - var $a = $(this); - $menu.children('li.active').removeClass('active'); - $a.parent().addClass('active'); - selectVal = $a.data('pri'); - $select.val(selectVal); - $dropdown.find('.pri-text').html('' + (selectVal ? selectVal : '') + ''); - }); - }); -} - /** * Apply cs style to page * @return void @@ -1353,118 +719,76 @@ function removeCookieByKey(cookieKey) } // /** -// * Bind hotkey event +// * Init help link for user to open zentao help website in iframe // * @access public // * @return void // */ -// function initHotKey() +// function initHelpLink() // { -// $(document).bind('keydown.ctrl_g', function(e) +// var zentaoUrl = 'http://www.zentao.net/book/zentaopmshelp.html?fullScreen=zentao'; +// if(config.clientLang == 'en') zentaoUrl = 'http://www.zentao.pm/book/zentaomanual/8.html?fullScreen=zentao'; +// var $mainNav = $('#mainmenu > .nav').first(); +// var showLoadingError; +// var timeout = 10000; + +// var clearLoadingError = function() // { -// /* CTRL+g, auto focus on the search box. */ -// $('#searchQuery').val('').focus(); +// clearTimeout(showLoadingError); +// $('#helpContent').removeClass('show-error'); +// }; + +// var openHelp = function() +// { +// clearLoadingError(); +// var $oldActiveItem = $mainNav.children('li.active:not(#helpMenuItem)').removeClass('active').addClass('close-help-tab'); +// var $helpMenuItem = $('#helpMenuItem').addClass('active'); +// var $help = $('#helpContent'); +// if(!$help.length) +// { +// $help = $('

    ' + lang.timeout + '

    ' + zentaoUrl + '

    '); +// $('#header').after($help); +// var frame = $('#helpIframe').get(0); +// showLoadingError = setTimeout(function() +// { +// $('#helpContent').addClass('show-error'); +// }, timeout); +// frame.onload = frame.onreadystatechange = function() +// { +// if(this.readyState && this.readyState != 'complete') return; +// clearLoadingError(); +// } +// } else if($('body').hasClass('show-help-tab')) +// { +// $('#helpIframe').get(0).contentWindow.location.replace(zentaoUrl); +// return; +// } +// $('body').addClass('show-help-tab'); +// }; + +// var closeHelp = function() +// { +// $('body').removeClass('show-help-tab'); +// $('#helpMenuItem').removeClass('active'); +// $mainNav.find('li.close-help-tab').removeClass('close-help-tab').addClass('active'); +// }; + +// $(document).on('click', '.open-help-tab', function() +// { +// var $helpMenuItem = $('#helpMenuItem'); +// if(!$helpMenuItem.length) +// { +// $helpMenuItem = $('
  • ' + $(this).text() + '
  • '); +// $mainNav.find('.custom-item').before($helpMenuItem); +// } +// openHelp(); +// }).on('click', '.close-help-tab', function(e) +// { +// closeHelp(); // e.stopPropagation(); // e.preventDefault(); -// return false; -// }).bind('keydown.Alt+up', function() -// { -// /* Alt+up, go back to the previous page. */ -// var backLink = $('#back').attr('href'); -// if(backLink) location.href = backLink; -// }).bind('keydown.left', function() -// { -// /* left, go to pre object. */ -// var preLink = $('#pre').attr('href'); -// if(!$.cookie('ajax_lastNext')) -// { -// $.cookie('ajax_lastNext', 'on', {expires: config.cookieLife, path: config.webRoot}); -// $.get(createLink('score', 'ajax', "method=lastNext")); -// } -// if(preLink) location.href = preLink; -// }).bind('keydown.right', function() -// { -// /* right, go to next object. */ -// var nextLink = $('#next').attr('href'); -// if(!$.cookie('ajax_lastNext')) -// { -// $.cookie('ajax_lastNext', 'on', {expires: config.cookieLife, path: config.webRoot}); -// $.get(createLink('score', 'ajax', "method=lastNext")); -// } -// if(nextLink) location.href = nextLink; // }); // } -/** - * Init help link for user to open zentao help website in iframe - * @access public - * @return void - */ -function initHelpLink() -{ - var zentaoUrl = 'http://www.zentao.net/book/zentaopmshelp.html?fullScreen=zentao'; - if(config.clientLang == 'en') zentaoUrl = 'http://www.zentao.pm/book/zentaomanual/8.html?fullScreen=zentao'; - var $mainNav = $('#mainmenu > .nav').first(); - var showLoadingError; - var timeout = 10000; - - var clearLoadingError = function() - { - clearTimeout(showLoadingError); - $('#helpContent').removeClass('show-error'); - }; - - var openHelp = function() - { - clearLoadingError(); - var $oldActiveItem = $mainNav.children('li.active:not(#helpMenuItem)').removeClass('active').addClass('close-help-tab'); - var $helpMenuItem = $('#helpMenuItem').addClass('active'); - var $help = $('#helpContent'); - if(!$help.length) - { - $help = $('

    ' + lang.timeout + '

    ' + zentaoUrl + '

    '); - $('#header').after($help); - var frame = $('#helpIframe').get(0); - showLoadingError = setTimeout(function() - { - $('#helpContent').addClass('show-error'); - }, timeout); - frame.onload = frame.onreadystatechange = function() - { - if(this.readyState && this.readyState != 'complete') return; - clearLoadingError(); - } - } else if($('body').hasClass('show-help-tab')) - { - $('#helpIframe').get(0).contentWindow.location.replace(zentaoUrl); - return; - } - $('body').addClass('show-help-tab'); - }; - - var closeHelp = function() - { - $('body').removeClass('show-help-tab'); - $('#helpMenuItem').removeClass('active'); - $mainNav.find('li.close-help-tab').removeClass('close-help-tab').addClass('active'); - }; - - $(document).on('click', '.open-help-tab', function() - { - var $helpMenuItem = $('#helpMenuItem'); - if(!$helpMenuItem.length) - { - $helpMenuItem = $('
  • ' + $(this).text() + '
  • '); - $mainNav.find('.custom-item').before($helpMenuItem); - } - openHelp(); - }).on('click', '.close-help-tab', function(e) - { - closeHelp(); - e.stopPropagation(); - e.preventDefault(); - }); -} - /** * Set homepage. * @@ -1623,57 +947,10 @@ needPing = true; /* When body's ready, execute these. */ $(document).ready(function() { - // setTableBehavior(); - // setForm(); - // saveWindowSize(); - // setSearchBox(); - // setOuterBox(); - - //setRequiredFields(); setPlaceholder(); - // setModalTriggerLink(); - - // checkTable(); - // toggleSearch(); - - // fixStyle(); - - // $(window).resize(saveWindowSize); // When window resized, call it again. - if(needPing) setTimeout('setPing()', 1000 * 60 * 10); // After 10 minutes, begin ping. - // initPrioritySelector(); - // initHotKey(); - // initHelpLink(); checkTutorial(); revertModuleCookie(); - - /* Adjust for dropdown position. */ - // $('li.dropdown-submenu').mouseover(function() - // { - // $('li.dropdown-submenu > .dropdown-menu').each(function() - // { - // if($(this).css('display') == 'block') - // { - // var topPosition = $(this).offset().top; - // if(topPosition < 0) $(this).css('bottom', Number($(this).css('bottom').replace('px', '')) + topPosition); - // } - // }) - // }) - - // $.extend({'closeModal':function(callback, location) - // { - // $ajaxModal = $('.modal-iframe'); - // $ajaxModal.on('hidden.zui.modal', function() - // { - // if(location && (!$ajaxModal.data('cancel-reload'))) - // { - // if(location == 'this') window.location.reload(); - // else window.location = location; - // } - // if(callback && $.isFunction(callback)) callback(); - // }); - // $ajaxModal.modal('hide'); - // }}); });