From f7d35cef9e8dc9fbbbdf80136440fe53b4fba0dc Mon Sep 17 00:00:00 2001 From: tengfei Date: Thu, 8 Dec 2016 13:24:17 +0800 Subject: [PATCH] *planning->plan --- module/action/lang/en.php | 12 +- module/block/lang/en.php | 6 +- module/bug/lang/en.php | 4 +- module/common/lang/en.php | 4 +- module/convert/lang/en.php | 2 +- module/dev/lang/en.php | 2 +- module/productplan/lang/en.php | 2 +- module/story/lang/en.php | 20 +- www/js/my.min.js | 1918 +++++++++++++++++++++++++++++++- 9 files changed, 1943 insertions(+), 27 deletions(-) diff --git a/module/action/lang/en.php b/module/action/lang/en.php index 4c2bd698f9..04f401471f 100755 --- a/module/action/lang/en.php +++ b/module/action/lang/en.php @@ -45,7 +45,7 @@ $lang->action->dynamic->search = 'Search'; $lang->action->objectTypes['product'] = $lang->productCommon; $lang->action->objectTypes['story'] = 'Story'; -$lang->action->objectTypes['productplan'] = 'Planning'; +$lang->action->objectTypes['productplan'] = 'Plan'; $lang->action->objectTypes['release'] = 'Release'; $lang->action->objectTypes['project'] = $lang->projectCommon; $lang->action->objectTypes['task'] = 'Task'; @@ -131,8 +131,8 @@ $lang->action->label->frombug = 'Converted from Bug'; $lang->action->label->totask = 'Convert to Task'; $lang->action->label->svncommited = 'SVN Commit'; $lang->action->label->gitcommited = 'Git Commit'; -$lang->action->label->linked2plan = 'Link to Planning'; -$lang->action->label->unlinkedfromplan = 'Unlink from Planning'; +$lang->action->label->linked2plan = 'Link to Plan'; +$lang->action->label->unlinkedfromplan = 'Unlink from Plan'; $lang->action->label->changestatus = 'Change Status'; $lang->action->label->marked = 'Marked'; $lang->action->label->linked2project = "Link {$lang->projectCommon}"; @@ -147,7 +147,7 @@ $lang->action->label->subdividestory = "Decompose Story"; $lang->action->label->unlinkchildstory = "Unlink decomposed Story"; $lang->action->label->started = 'Initiated'; $lang->action->label->restarted = 'Continued'; -$lang->action->label->recordestimate = 'Historyed Man-Hour'; +$lang->action->label->recordestimate = 'Recorded Man-Hour'; $lang->action->label->editestimate = 'Edited Man-Hour'; $lang->action->label->canceled = 'Cancelled'; $lang->action->label->finished = 'Finished'; @@ -160,7 +160,7 @@ $lang->action->label->deleteestimate = "Deleted Man-Hour"; /* 用来生成相应对象的链接。*/ $lang->action->label->product = $lang->productCommon . '|product|view|productID=%s'; -$lang->action->label->productplan = 'Planning|productplan|view|productID=%s'; +$lang->action->label->productplan = 'Plan|productplan|view|productID=%s'; $lang->action->label->release = 'Release|release|view|productID=%s'; $lang->action->label->story = 'Story|story|view|storyID=%s'; $lang->action->label->project = "{$lang->projectCommon}|project|view|projectID=%s"; @@ -192,7 +192,7 @@ $lang->action->search->objectTypeList['doclib'] = 'Doc Lib'; $lang->action->search->objectTypeList['todo'] = 'To-Dos'; $lang->action->search->objectTypeList['build'] = 'Build'; $lang->action->search->objectTypeList['release'] = 'Release'; -$lang->action->search->objectTypeList['productplan'] = 'Planning'; +$lang->action->search->objectTypeList['productplan'] = 'Plan'; $lang->action->search->objectTypeList['branch'] = 'Branch'; /* 用来在动态显示中显示动作 */ diff --git a/module/block/lang/en.php b/module/block/lang/en.php index 98ec028841..156802f926 100644 --- a/module/block/lang/en.php +++ b/module/block/lang/en.php @@ -129,7 +129,7 @@ $lang->block->availableBlocks->case = 'My Cases'; $lang->block->availableBlocks->story = 'My Stories'; $lang->block->availableBlocks->product = $lang->productCommon . 'List'; $lang->block->availableBlocks->project = $lang->projectCommon . 'List'; -$lang->block->availableBlocks->plan = 'Planning List'; +$lang->block->availableBlocks->plan = 'Plans'; $lang->block->availableBlocks->release = 'Release List'; $lang->block->availableBlocks->build = 'Builds'; $lang->block->availableBlocks->testtask = 'Test Builds'; @@ -143,7 +143,7 @@ $lang->block->modules['product'] = new stdclass(); $lang->block->modules['product']->availableBlocks = new stdclass(); $lang->block->modules['product']->availableBlocks->list = $lang->productCommon . 'List'; $lang->block->modules['product']->availableBlocks->story = 'Stories'; -$lang->block->modules['product']->availableBlocks->plan = 'Planning List'; +$lang->block->modules['product']->availableBlocks->plan = 'Plans'; $lang->block->modules['product']->availableBlocks->release = 'Release List'; $lang->block->modules['project'] = new stdclass(); $lang->block->modules['project']->availableBlocks = new stdclass(); @@ -248,7 +248,7 @@ $lang->block->modules['common']->moreLinkList->dynamic = 'company|dynamic|'; $lang->block->flowchart = array(); $lang->block->flowchart[] = array('Administration', 'Manage a Company', 'Add Users', 'Maintain Privileges'); -$lang->block->flowchart[] = array('Product Manager', 'Add Products', 'Maintain Modules', 'Maintain Planning', 'Maintain Stories', 'Create Release'); +$lang->block->flowchart[] = array('Product Manager', 'Add Products', 'Maintain Modules', 'Maintain Plans', 'Maintain Stories', 'Create Release'); $lang->block->flowchart[] = array('Project Manager', 'Add Projects', 'Maintain Teams', 'Link Products', 'Link Stories', 'Decompose Tasks'); $lang->block->flowchart[] = array('DEV Team', 'Claim TaskS/BugS', 'Update Status', 'Finish Tasks/Bugs'); $lang->block->flowchart[] = array('Testing Team', 'Write Cases', 'Implement Cases', 'Submit Bugs', 'Fix Bugs', 'Close Bugs'); diff --git a/module/bug/lang/en.php b/module/bug/lang/en.php index bd92d763de..38e99b0c6d 100644 --- a/module/bug/lang/en.php +++ b/module/bug/lang/en.php @@ -334,8 +334,8 @@ $lang->bug->action = new stdclass(); $lang->bug->action->resolved = array('main' => '$date, solved by $actor and the solution is $extra $appendLink.', 'extra' => 'resolutionList'); $lang->bug->action->tostory = array('main' => '$date, transferred by $actor to Story with ID $extra.'); $lang->bug->action->totask = array('main' => '$date, imported by $actor as Task with ID $extra.'); -$lang->bug->action->linked2plan = array('main' => '$date, linked by $actor to Planning $extra.'); -$lang->bug->action->unlinkedfromplan = array('main' => '$date, deleted by $actor from Planning $extra.'); +$lang->bug->action->linked2plan = array('main' => '$date, linked by $actor to Plan $extra.'); +$lang->bug->action->unlinkedfromplan = array('main' => '$date, deleted by $actor from Plan $extra.'); $lang->bug->action->linked2build = array('main' => '$date, linked by $actor to Build $extra.'); $lang->bug->action->unlinkedfrombuild = array('main' => '$date, removed by $actor from Build $extra.'); $lang->bug->action->linked2release = array('main' => '$date, linked by $actor to Release $extra.'); diff --git a/module/common/lang/en.php b/module/common/lang/en.php index 8318187534..6aea1019a7 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -118,7 +118,7 @@ $lang->searchObjects['product'] = $lang->productCommon; $lang->searchObjects['user'] = 'User'; $lang->searchObjects['build'] = 'Build'; $lang->searchObjects['release'] = 'Release'; -$lang->searchObjects['productplan'] = $lang->productCommon . 'Planning'; +$lang->searchObjects['productplan'] = $lang->productCommon . 'Plan'; $lang->searchObjects['testtask'] = 'Testing Build'; $lang->searchObjects['doc'] = 'Document'; $lang->searchTips = 'ID (ctrl+g)'; @@ -181,7 +181,7 @@ $lang->product->menu = new stdclass(); $lang->product->menu->list = array('link' => '%s', 'fixed' => true); $lang->product->menu->story = array('link' => 'Story|product|browse|productID=%s', 'alias' => 'batchedit', 'subModule' => 'story'); $lang->product->menu->dynamic = 'Dynamic|product|dynamic|productID=%s'; -$lang->product->menu->plan = array('link' => 'Planning|productplan|browse|productID=%s', 'subModule' => 'productplan'); +$lang->product->menu->plan = array('link' => 'Plan|productplan|browse|productID=%s', 'subModule' => 'productplan'); $lang->product->menu->release = array('link' => 'Release|release|browse|productID=%s', 'subModule' => 'release'); $lang->product->menu->roadmap = 'Roadmap|product|roadmap|productID=%s'; $lang->product->menu->doc = array('link' => 'Document|product|doc|productID=%s', 'subModule' => 'doc'); diff --git a/module/convert/lang/en.php b/module/convert/lang/en.php index bfc8de170f..30b2196f8e 100644 --- a/module/convert/lang/en.php +++ b/module/convert/lang/en.php @@ -82,7 +82,7 @@ $lang->convert->redmine->projects = $lang->projectCommon; $lang->convert->redmine->stories = 'Story'; $lang->convert->redmine->tasks = 'Task'; $lang->convert->redmine->bugs = 'Bug'; -$lang->convert->redmine->productPlans = $lang->productCommon . 'Planning'; +$lang->convert->redmine->productPlans = $lang->productCommon . 'Plan'; $lang->convert->redmine->teams = 'Team'; $lang->convert->redmine->releases = 'Release'; $lang->convert->redmine->builds = 'Build'; diff --git a/module/dev/lang/en.php b/module/dev/lang/en.php index 78da058d65..a0d58dc329 100644 --- a/module/dev/lang/en.php +++ b/module/dev/lang/en.php @@ -40,7 +40,7 @@ $lang->dev->tableList['history'] = 'History'; $lang->dev->tableList['lang'] = 'Language'; $lang->dev->tableList['module'] = 'Module'; $lang->dev->tableList['product'] = $lang->productCommon; -$lang->dev->tableList['productplan'] = $lang->productCommon . 'Planning'; +$lang->dev->tableList['productplan'] = $lang->productCommon . 'Plan'; $lang->dev->tableList['project'] = $lang->projectCommon; $lang->dev->tableList['projectproduct'] = $lang->projectCommon . $lang->productCommon; $lang->dev->tableList['projectstory'] = $lang->projectCommon . 'Story'; diff --git a/module/productplan/lang/en.php b/module/productplan/lang/en.php index 9bcea7bc98..979dc5d9ab 100644 --- a/module/productplan/lang/en.php +++ b/module/productplan/lang/en.php @@ -9,7 +9,7 @@ * @version $Id: en.php 4659 2013-04-17 06:45:08Z chencongzhi520@gmail.com $ * @link http://www.zentao.net */ -$lang->productplan->common = $lang->productCommon . 'Planning'; +$lang->productplan->common = $lang->productCommon . 'Plan'; $lang->productplan->browse = "View"; $lang->productplan->index = "List"; $lang->productplan->create = "Create"; diff --git a/module/story/lang/en.php b/module/story/lang/en.php index 2374a91c5f..bef173869e 100644 --- a/module/story/lang/en.php +++ b/module/story/lang/en.php @@ -38,11 +38,11 @@ $lang->story->export = "Export Data"; $lang->story->zeroCase = "Zero Case"; $lang->story->zeroTask = "Zero Task"; $lang->story->reportChart = "Report"; -$lang->story->batchChangePlan = "Batch Change Planning"; -$lang->story->batchChangeBranch = "Batch Change Branch"; -$lang->story->batchChangeStage = "Batch Change Stage"; +$lang->story->batchChangePlan = "Batch Change Plans"; +$lang->story->batchChangeBranch = "Batch Change Branches"; +$lang->story->batchChangeStage = "Batch Change Stages"; $lang->story->batchAssignTo = "Batch Assign"; -$lang->story->batchChangeModule = "Batch Change Module"; +$lang->story->batchChangeModule = "Batch Change Modules"; $lang->story->common = 'Story'; $lang->story->id = 'ID'; @@ -76,7 +76,7 @@ $lang->story->rejectedReason = 'RejectED Reason'; $lang->story->reviewedBy = 'Reviewed By'; $lang->story->reviewedDate = 'Reviewed on'; $lang->story->version = 'Version'; -$lang->story->plan = 'Planning'; +$lang->story->plan = 'Plan'; $lang->story->planAB = 'Plan'; $lang->story->comment = 'Comment'; $lang->story->linkStories = 'Linke Story'; @@ -194,8 +194,8 @@ $lang->story->form->file = 'Files. If there are Story related files, please $lang->story->action = new stdclass(); $lang->story->action->reviewed = array('main' => '$date, recorded by $actor. Review result is $extra.', 'extra' => 'reviewResultList'); $lang->story->action->closed = array('main' => '$date, closed by $actor. The reasion is $extra $appendLink.', 'extra' => 'reasonList'); -$lang->story->action->linked2plan = array('main' => '$date, linked by $actor to Planning $extra'); -$lang->story->action->unlinkedfromplan = array('main' => '$date, removed by $actor from Planning $extra.'); +$lang->story->action->linked2plan = array('main' => '$date, linked by $actor to Plan $extra'); +$lang->story->action->unlinkedfromplan = array('main' => '$date, removed by $actor from Plan $extra.'); $lang->story->action->linked2project = array('main' => '$date, linked by $actor to ' . $lang->projectCommon . ' $extra.'); $lang->story->action->unlinkedfromproject = array('main' => '$date, removed by $actor from ' . $lang->projectCommon . ' $extra.'); $lang->story->action->linked2build = array('main' => '$date, linked by $actor to Build $extra'); @@ -217,7 +217,7 @@ $lang->story->report->value = 'Story Count'; $lang->story->report->charts['storysPerProduct'] = $lang->productCommon . 'Story Count'; $lang->story->report->charts['storysPerModule'] = 'Story per Module'; $lang->story->report->charts['storysPerSource'] = 'Story per Source'; -$lang->story->report->charts['storysPerPlan'] = 'Story per Planning'; +$lang->story->report->charts['storysPerPlan'] = 'Story per Plan'; $lang->story->report->charts['storysPerStatus'] = 'Story per Status'; $lang->story->report->charts['storysPerStage'] = 'Story per Stage'; $lang->story->report->charts['storysPerPri'] = 'Story per Priority'; @@ -249,7 +249,7 @@ $lang->story->report->storysPerChange = new stdclass(); $lang->story->report->storysPerProduct->item = $lang->productCommon; $lang->story->report->storysPerModule->item = 'Module'; $lang->story->report->storysPerSource->item = 'Source'; -$lang->story->report->storysPerPlan->item = 'Planning'; +$lang->story->report->storysPerPlan->item = 'Plan'; $lang->story->report->storysPerStatus->item = 'Status'; $lang->story->report->storysPerStage->item = 'Stage'; $lang->story->report->storysPerPri->item = 'Priority'; @@ -275,7 +275,7 @@ $lang->story->report->storysPerChange->graph = new stdclass(); $lang->story->report->storysPerProduct->graph->xAxisName = $lang->productCommon; $lang->story->report->storysPerModule->graph->xAxisName = 'Module'; $lang->story->report->storysPerSource->graph->xAxisName = 'Source'; -$lang->story->report->storysPerPlan->graph->xAxisName = 'Planning'; +$lang->story->report->storysPerPlan->graph->xAxisName = 'Plan'; $lang->story->report->storysPerStatus->graph->xAxisName = 'Status'; $lang->story->report->storysPerStage->graph->xAxisName = 'Stage'; $lang->story->report->storysPerPri->graph->xAxisName = 'Priority'; diff --git a/www/js/my.min.js b/www/js/my.min.js index 7298533e4a..ff98d3f4be 120000 --- a/www/js/my.min.js +++ b/www/js/my.min.js @@ -1 +1,1917 @@ -my.full.js \ No newline at end of file +/** + * Create link. + * + * @param string $moduleName + * @param string $methodName + * @param string $vars + * @param string $viewType + * @access public + * @return string + */ +function createLink(moduleName, methodName, vars, viewType, isOnlyBody) +{ + if(!viewType) viewType = config.defaultView; + if(!isOnlyBody) isOnlyBody = false; + if(vars) + { + vars = vars.split('&'); + for(i = 0; i < vars.length; i ++) vars[i] = vars[i].split('='); + } + if(config.requestType != 'GET') + { + if(config.requestType == 'PATH_INFO') link = config.webRoot + moduleName + config.requestFix + methodName; + if(config.requestType == 'PATH_INFO2') link = config.webRoot + 'index.php/' + moduleName + config.requestFix + methodName; + if(vars) + { + for(i = 0; i < vars.length; i ++) link += config.requestFix + vars[i][1]; + } + link += '.' + viewType; + } + else + { + link = config.router + '?' + config.moduleVar + '=' + moduleName + '&' + config.methodVar + '=' + methodName + '&' + config.viewVar + '=' + viewType; + if(vars) for(i = 0; i < vars.length; i ++) link += '&' + vars[i][0] + '=' + vars[i][1]; + } + + /* if page has onlybody param then add this param in all link. the param hide header and footer. */ + if((typeof(config.onlybody) != 'undefined' && config.onlybody == 'yes') || isOnlyBody) + { + var onlybody = config.requestType != 'GET' ? "?onlybody=yes" : '&onlybody=yes'; + link = link + onlybody; + } + return link; +} + +/** + * Bind Event for searchbox + * + */ +function setSearchBox() +{ + $('#typeSelector a').click(function() + { + $('#typeSelector li.active').removeClass('active'); + var $this = $(this); + $this.closest('li').addClass('active'); + $("#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 = $('#searchQuery').attr('value'); + if(objectType && objectValue) + { + location.href=createLink(objectType, 'view', "id=" + objectValue); + } +} + +/** + * Show drop menu. + * + * @param string $objectType product|project + * @param int $objectID + * @param string $module + * @param string $method + * @param string $extra + * @access public + * @return void + */ +function showDropMenu(objectType, objectID, module, method, extra) +{ + var itemID = objectType == 'branch' ? '#currentBranch' : '#currentItem'; + var li = $(itemID).closest('li'); + if(li.hasClass('show')) {li.removeClass('show'); return;} + + var $dropMenu = li.find('#dropMenu'); + if(!li.data('showagain')) + { + li.data('showagain', true); + $(document).click(function() {li.removeClass('show');}); + li.click(function(e){e.stopPropagation();}); + + $dropMenu.on('keydown', '#search', function(e) + { + var code = e.which; + var $this = $dropMenu.find('#searchResult > .search-list > ul > li.active'); + if(code === 38) // up + { + $this.removeClass('active'); + if($this.length) + { + var $prev = $this.prev('li'); + while($prev.length && $prev.hasClass('heading')) + { + $prev = $prev.prev('li'); + } + if($prev.length) + { + $prev.addClass('active'); + return; + } + } + $dropMenu.find('#searchResult > .search-list > ul > li:not(.heading):last').addClass('active'); + } + else if(code === 40) // down + { + $this.removeClass('active'); + if($this.length) + { + var $next = $this.next('li'); + while($next.length && $next.hasClass('heading')) + { + $next = $next.next('li'); + } + if($next.length) + { + $next.addClass('active'); + return; + } + } + $dropMenu.find('#searchResult > .search-list > ul > li:not(.heading):first').addClass('active'); + } + else if(code === 13) // enter + { + if($this.length) window.location.href = $this.children('a').attr('href'); + } + }).on('change keyup paste input propertychange', '#search', function() + { + var $search = $(this); + var searchKey = $search.val(); + if(searchKey === $dropMenu.data('lastSearchKey')) return; + + clearTimeout($dropMenu.data('lastSearch')); + $dropMenu.data('lastSearch', setTimeout(function() + { + $dropMenu.data('lastSearchKey', searchKey); + searchItems(searchKey, objectType, objectID, module, method, extra); + }, 200)); + }).on('mouseenter', '#searchResult .search-list > ul > li', function(){ + $dropMenu.find('#searchResult > .search-list > ul > li.active').removeClass('active'); + $(this).addClass('active'); + }); + } + $.get(createLink(objectType, 'ajaxGetDropMenu', "objectID=" + objectID + "&module=" + module + "&method=" + method + "&extra=" + extra), function(data) + { + $dropMenu.html(data).find('#search').focus(); + $dropMenu.find('#searchResult > .search-list > ul > li:not(.heading)').removeClass('active').first().addClass('active'); + }); + + li.addClass('show'); +} + +/** + * Show drop result. + * + * @param objectType $objectType + * @param objectID $objectID + * @param module $module + * @param method $method + * @param extra $extra + * @access public + * @return void + */ +function showDropResult(objectType, objectID, module, method, extra) +{ + var itemID = objectType == 'branch' ? '#currentBranch' : '#currentItem'; + var li = $(itemID).closest('li'); + var $dropMenu = li.find('#dropMenu'); + $.get(createLink(objectType, 'ajaxGetDropMenu', "objectID=" + objectID + "&module=" + module + "&method=" + method + "&extra=" + extra), function(data) + { + $dropMenu.html(data); + setTimeout(function(){$dropMenu.find("#search").focus();}, 200); + $dropMenu.find('#searchResult > .search-list > ul > li:not(.heading)').removeClass('active').first().addClass('active'); + }); +} + +/** + * Search items. + * + * @param string $keywords + * @param string $objectType + * @param int $objectID + * @param string $module + * @param string $method + * @param string $extra + * @access public + * @return void + */ +function searchItems(keywords, objectType, objectID, module, method, extra) +{ + if(keywords == '') + { + showMenu = 0; + showDropResult(objectType, objectID, module, method, extra); + } + else + { + var itemID = objectType == 'branch' ? '#currentBranch' : '#currentItem'; + var li = $(itemID).closest('li'); + var $dropMenu = li.find('#dropMenu'); + keywords = encodeURI(keywords); + if(keywords != '-') $.get(createLink(objectType, 'ajaxGetMatchedItems', "keywords=" + keywords + "&module=" + module + "&method=" + method + "&extra=" + extra + "&objectID=" + objectID), function(data) + { + $dropMenu.find('#searchResult').html(data).find('.search-list > ul > li:not(.heading)').removeClass('active').first().addClass('active'); + }); + } +} + +/** + * 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. + * + * @param int $libID + * @param string $module + * @param string $method + * @param string $extra + * @access public + * @return void + */ +function switchDocLib(libID, module, method, extra) +{ + if(module == 'doc') + { + if(method != 'view' && method != 'edit') + { + link = createLink(module, method, 'rootID=' + libID); + } + else + { + link = createLink('doc', 'browse'); + } + } + else if(module == 'tree') + { + link = createLink(module, method, 'rootID=' + libID + '&type=' + extra); + } + location.href = link; +} + +/** + * Set the ping url. + * + * @access public + * @return void + */ +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++) + { + $('#' + requiredFields[i]).closest('td,th').prepend("
"); + var colEle = $('#' + requiredFields[i]).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. + * + * @access public + * @return void + */ +function setHelpLink() +{ + if(!$.cookie('help')) $.cookie('help', 'off', {expires:config.cookieLife, path:config.webRoot}); + className = $.cookie('help') == 'off' ? 'hidden' : ''; + + $('form input[id], form select[id], form textarea[id]').each(function() + { + if($(this).attr('type') == 'hidden' || $(this).attr('type') == 'file') return; + currentFieldName = $(this).attr('name') ? $(this).attr('name') : $(this).attr('id'); + if(currentFieldName == 'submit' || currentFieldName == 'reset') return; + if(currentFieldName.indexOf('[') > 0) currentFieldName = currentFieldName.substr(0, currentFieldName.indexOf('[')); + currentFieldName = currentFieldName.toLowerCase(); + helpLink = createLink('help', 'field', 'module=' + config.currentModule + '&method=' + config.currentMethod + '&field=' + currentFieldName); + $(this).after(' ? '); + }); + + $("a.helplink").modalTrigger({width:600, type:'iframe'}); +} + +/** + * Set paceholder. + * + * @access public + * @return void + */ +function setPlaceholder() +{ + if(typeof(holders) != 'undefined') + { + for(var key in holders) + { + if($('#' + key).prop('tagName') == 'INPUT') + { + $("#" + key).attr('placeholder', holders[key]); + } + } + } +} + +/** + * 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'); + $('.side-handle .icon-caret-left').removeClass('icon-caret-left').addClass('icon-caret-right'); +} + +/** + * 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'); + $('.side-handle .icon-caret-right').removeClass('icon-caret-right').addClass('icon-caret-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. + * + * @access public + * @return void + */ +function selectLang(lang) +{ + $.cookie('lang', lang, {expires:config.cookieLife, path:config.webRoot}); + location.href = removeAnchor(location.href); +} + +/** + * Set theme. + * + * @access public + * @return void + */ +function selectTheme(theme) +{ + $.cookie('theme', theme, {expires:config.cookieLife, path:config.webRoot}); + location.href = removeAnchor(location.href); +} + +/** + * Remove anchor from the url. + * + * @param string $url + * @access public + * @return string + */ +function removeAnchor(url) +{ + pos = url.indexOf('#'); + if(pos > 0) return url.substring(0, pos); + return url; +} + +/** + * Get the window size and save to cookie. + * + * @access public + * @return void + */ +function saveWindowSize() +{ + width = $(window).width(); + height = $(window).height(); + $.cookie('windowWidth', width) + $.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. + * + * @access public + * @return void + */ +function setForm() +{ + var formClicked = false; + $('form').submit(function() + { + submitObj = $(this).find(':submit'); + if($(submitObj).size() >= 1) + { + var isBtn = submitObj.prop('tagName') == "BUTTON"; + submitLabel = isBtn ? $(submitObj).html() : $(submitObj).attr('value'); + $(submitObj).attr('disabled', 'disabled'); + var submitting = submitObj.attr('data-submitting') || lang.submitting; + if(isBtn) submitObj.text(submitting); + else $(submitObj).attr('value', submitting); + formClicked = true; + } + }); + + $("body").click(function() + { + if(formClicked) + { + $(submitObj).removeAttr('disabled'); + if(submitObj.prop('tagName') == "BUTTON") + { + submitObj.text(submitLabel); + } + else + { + $(submitObj).attr('value', submitLabel); + } + $(submitObj).removeClass('button-d'); + } + formClicked = false; + }); +} + +/** + * Set form action and submit. + * + * @param url $actionLink + * @param string $hiddenwin 'hiddenwin' + * @access public + * @return void + */ +function setFormAction(actionLink, hiddenwin, obj) +{ + $form = typeof(obj) == 'undefined' ? $('form') : $(obj).closest('form'); + if(hiddenwin) $form.attr('target', hiddenwin); + else $form.removeAttr('target'); + + $form.attr('action', actionLink).submit(); +} + +/** + * Set the max with of image. + * + * @access public + * @return void + */ +function setImageSize(image, maxWidth) +{ + /* If not set maxWidth, set it auto. */ + if(!maxWidth) + { + bodyWidth = $('body').width(); + maxWidth = bodyWidth - 470; // The side bar's width is 336, and add some margins. + } + + if($(image).width() > maxWidth) $(image).attr('width', maxWidth); + $(image).wrap(''); +} + +/** + * Set the modal trigger to link. + * + * @access public + * @return void + */ +function setModalTriggerLink() +{ + $('.repolink').modalTrigger({width:960, type:'iframe'}); + $(".export").modalTrigger({width:650, type:'iframe'}); +} + +/** + * Set mailto list from a contact list.. + * + * @param string $mailto + * @param int $contactListID + * @access public + * @return void + */ +function setMailto(mailto, contactListID) +{ + link = createLink('user', 'ajaxGetContactUsers', 'listID=' + contactListID); + $.get(link, function(users) + { + $('#' + mailto).replaceWith(users); + $('#' + mailto + '_chosen').remove(); + $('#' + mailto).chosen(defaultChosenOptions); + }); +} + +/** + * Ajax get contacts. + * + * @param obj $obj + * @access public + * @return void + */ +function ajaxGetContacts(obj) +{ + link = createLink('user', 'ajaxGetContactList'); + $.get(link, function(contacts) + { + if(!contacts) return false; + + $inputgroup = $(obj).closest('.input-group'); + $inputgroup.find('.input-group-btn').remove(); + $inputgroup.append(contacts); + $inputgroup.find('select:last').chosen(defaultChosenOptions); + }); +} + +/** + * 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'); + + if(!$table.length) 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')) + { + 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(browseType == 'bymodule') + { + $('#bymoduleTab').removeClass('active'); + } + else + { + $('#' + browseType + 'Tab').removeClass('active'); + } + $('#bysearchTab').addClass('active'); + ajaxGetSearchForm(); + $('#querybox').addClass('show'); + }, + function() + { + if(browseType == 'bymodule') + { + $('#bymoduleTab').addClass('active'); + } + else + { + $('#' + browseType +'Tab').addClass('active'); + } + $('#bysearchTab').removeClass('active'); + $('#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); + }); + } +} + +/** + * add one option of a select to another select. + * + * @param string $SelectID + * @param string $TargetID + * @access public + * @return void + */ +function addItem(SelectID,TargetID) +{ + ItemList = document.getElementById(SelectID); + Target = document.getElementById(TargetID); + for(var x = 0; x < ItemList.length; x++) + { + var opt = ItemList.options[x]; + if (opt.selected) + { + flag = true; + for (var y=0;y=0;x--) + { + var opt = ItemList.options[x]; + if (opt.selected) + { + ItemList.options[x] = null; + } + } +} + +/** + * move one selected option up from a select. + * + * @param string $SelectID + * @access public + * @return void + */ +function upItem(SelectID) +{ + ItemList = document.getElementById(SelectID); + for(var x=1;x=0;x--) + { + var opt = ItemList.options[x]; + opt.selected = true; + } +} + +/** + * Delete item use ajax. + * + * @param string url + * @param string replaceID + * @param string notice + * @access public + * @return void + */ +function ajaxDelete(url, replaceID, notice) +{ + if(confirm(notice)) + { + $.ajax( + { + type: 'GET', + url: url, + dataType: 'json', + success: function(data) + { + if(data.result == 'success') + { + $.get(document.location.href, function(data) + { + $('#' + replaceID).html($(data).find('#' + replaceID).html()); + if(typeof sortTable == 'function') sortTable(); + $('#' + replaceID).find('[data-toggle=modal], a.iframe').modalTrigger(); + $('#' + replaceID).find('table.datatable').datatable(); + }); + } + } + }); + } +} + +/** + * Judge the string is a integer number + * + * @access public + * @return bool + */ +function isNum(s) +{ + if(s!=null) + { + var r, re; + re = /\d*/i; + r = s.match(re); + return (r == s) ? true : false; + } + return false; +} + +/** + * Set modal load content with ajax or iframe + * + * @access public + * @return void + */ +function setModal() +{ + jQuery.fn.modalTrigger = function(setting) + { + return $(this).each(function() + { + var $this = $(this); + $this.off('click.modalTrigger.zui'); + + $this.on('click.modalTrigger.zui', function(event) + { + var $e = $(this); + if($e.closest('.body-modal').length) return; + + if($e.hasClass('disabled')) return false; + + var url = (setting ? setting.url : false) || $e.attr('href') || $e.data('url'); + var type = (setting ? setting.type : false) || ($e.hasClass('iframe') ? 'iframe' : ($e.data('type') || 'ajax')); + if(type == 'iframe') + { + var options = $.extend( + { + url: url, + title: $e.attr('title') || $e.text(), + cssClass: $e.data('class'), + icon: '?', + center: true + }, setting, $e.data()); + + if(options.icon == '?') + { + var i = $e.find("[class^='icon-']"); + options.icon = i.length ? i.attr('class').substring(5) : 'file-text'; + } + + showIframeModal(options); + } + else + { + initModalFrame(); + $.get(url, function(data) + { + var options = $.extend( + { + width: 800, + title: $e.attr('title') || $e.text(), + icon: '?', + backdrop: 'static', + show: true + }, setting, $e.data()); + + var ajaxModal = $('#ajaxModal'); + if(data.indexOf('modal-dialog') < 0) + { + data = "".format($.extend({content: data}, options)); + } + ajaxModal.html(data); + + /* Set the width of modal dialog. */ + if(options.width) + { + var modalWidth = parseInt(options.width); + $ajaxModal.data('width', modalWidth).find('.modal-dialog').css('width', modalWidth); + ajustModalPosition(); + } + ajaxModal.modal(options); + }); + } + + /* Save the href to rel attribute thus we can save it. */ + $('#ajaxModal').attr('rel', url); + + event.preventDefault(); + return false; + }); + }); + } + + function showIframeModal(settings) + { + var options = + { + width: 800, + height: 'auto', + icon: '?', + title: '', + name: 'modalIframe', + cssClass: '', + headerless: false, + waittime: 0, + center: true, + backdrop: 'static', + show: true + }; + + if(typeof(settings) == 'string') + { + options.url = settings; + } + else + { + options = $.extend(options, settings); + } + + initModalFrame(options); + + if(isNum(options.height.toString())) options.height += 'px'; + if(isNum(options.width.toString())) options.width += 'px'; + if(options.size == 'fullscreen') + { + var $w = $(window); + options.width = $w.width(); + options.height = $w.height(); + options.cssClass += ' fullscreen'; + } + if(options.headerless) + { + options.cssClass += ' hide-header'; + } + if(typeof(options.url) == 'undefined' || !options.url) return false; + + var modal = $('#ajaxModal').addClass('modal-loading').data('first', true); + + modal.html("
".format(options)); + + var modalBody = modal.find('.modal-body'), dialog = modal.find('.modal-dialog'); + if(options.cssClass) + { + dialog.addClass(options.cssClass); + } + + if(options.waittime > 0) + { + options.waitingFuc = setTimeout(function(){showModal(options, modal, modalBody, dialog);}, options.waittime ); + } + + var frame = document.getElementById(options.name); + frame.onload = frame.onreadystatechange = function() + { + if(this.readyState && this.readyState != 'complete') return; + if(modal.data('first') && (!modal.hasClass('modal-loading'))) return; + if(!modal.data('first')) modal.addClass('modal-loading'); + + if(options.waittime > 0) + { + clearTimeout(options.waitingFuc); + } + showModal(options, modal, modalBody, dialog); + } + modal.modal(options); + } + + function showModal(options, modal, modalBody, dialog) + { + modalBody.css('height', options.height - modal.find('.modal-header').outerHeight()); + try + { + var frame$ = window.frames[options.name].$; + if(frame$('#titlebar').length) + { + modal.addClass('with-titlebar'); + if(options.size == 'fullscreen') + { + modalBody.css('height', options.height); + } + } + if(options.height == 'auto') + { + var $framebody = frame$('body'); + setTimeout(function() + { + modal.removeClass('fade'); + var fbH = $framebody.addClass('body-modal').outerHeight(); + frame$('#titlebar > .heading a').each(function() + { + var $a = frame$(this); + $a.replaceWith("" + $a.text() + ""); + }); + if(typeof fbH == 'object') fbH = $framebody.height(); + modalBody.css('height', fbH); + ajustModalPosition(); + if(modal.data('first')) modal.data('first', false); + modal.removeClass('modal-loading').addClass('fade'); + }, 100); + + $framebody.resize(function() + { + var fbH = $framebody.outerHeight(); + if(typeof fbH == 'object') fbH = $framebody.height(); + modalBody.css('height', fbH); + ajustModalPosition(); + }); + } + else + { + modal.removeClass('modal-loading'); + } + + if(frame$) + { + frame$.extend({'closeModal': $.closeModal}); + } + } + catch(e) + { + modal.removeClass('modal-loading'); + } + } + + function initModalFrame(setting) + { + if($('#ajaxModal').length) + { + /* unbind all events */ + $('#ajaxModal').attr('class', 'modal fade').off('show.zui.modal shown.zui.modal hide.zui.modal hidden.zui.modal'); + } + else + { + /* Addpend modal div. */ + $('').appendTo('body'); + } + + $ajaxModal = $('#ajaxModal'); + $ajaxModal.data('cancel-reload', false); + + $.extend({'closeModal':function(callback, location) + { + $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'); + }, 'cancelReloadCloseModal': function(){$ajaxModal.data('cancel-reload', true);}}); + + /* rebind events */ + if(!setting) return; + if(setting.afterShow && $.isFunction(setting.afterShow)) $ajaxModal.on('show.zui.modal', setting.afterShow); + if(setting.afterShown && $.isFunction(setting.afterShown)) $ajaxModal.on('shown.zui.modal', setting.afterShown); + if(setting.afterHide && $.isFunction(setting.afterHide)) $ajaxModal.on('hide.zui.modal', setting.afterHide); + if(setting.afterHidden && $.isFunction(setting.afterHidden)) $ajaxModal.on('hidden.zui.modal', setting.afterHidden); + } + + function ajustModalPosition(position, dialog) + { + position = position || 'fit'; + if(!dialog) dialog = $('#ajaxModal .modal-dialog'); + if(position) + { + var half = Math.max(0, ($(window).height() - dialog.outerHeight())/2); + var pos = position == 'fit' ? (half*2/3) : (position == 'center' ? half : position); + dialog.css('margin-top', pos); + } + } + + $.extend({ajustModalPosition: ajustModalPosition, modalTrigger: showIframeModal, colorbox: function(setting) + { + if((typeof setting == 'object') && setting.iframe) + { + $.modalTrigger({type: 'iframe', width: setting['width'], afterHide: setting['onCleanup'], url: setting['href']}); + } + }}); + + $('[data-toggle=modal], a.iframe').modalTrigger(); + + jQuery.fn.colorbox = function(setting) + { + if((typeof setting == 'object') && setting.iframe) + { + $(this).modalTrigger({type: 'iframe', width: setting['width'], afterHide: setting['onCleanup'], url: setting['href']}); + } + } +} + +/** + * 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(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 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. + * + * @access public + * @return void + */ +function startCron() +{ + $.ajax({type:"GET", timeout:100, url:createLink('cron', 'ajaxExec')}); +} + +function computePasswordStrength(password) +{ + if(password.length == 0) return 0; + + var strength = 0; + var length = password.length; + + var uniqueChars = ''; + var complexity = new Array(); + for(i = 0; i < length; i++) + { + letter = password.charAt(i); + var asc = letter.charCodeAt(); + if(asc >= 48 && asc <= 57) + { + complexity[2] = 2; + } + else if((asc >= 65 && asc <= 90)) + { + complexity[1] = 2; + } + else if(asc >= 97 && asc <= 122) + { + complexity[0] = 1; + } + else + { + complexity[3] = 3; + } + if(uniqueChars.indexOf(letter) == -1) uniqueChars += letter; + } + + if(uniqueChars.length > 4) strength += uniqueChars.length - 4; + var sumComplexity = 0; + var complexitySize = 0; + for(i in complexity) + { + complexitySize += 1; + sumComplexity += complexity[i]; + } + strength += sumComplexity + (2 * (complexitySize - 1)); + if(length < 6 && strength >= 10) strength = 9; + + strength = strength > 29 ? 29 : strength; + strength = Math.floor(strength / 10); + + return strength; +} + +/** + * Check onlybody page when it is not open in modal then location to on onlybody page. + * + * @access public + * @return void + */ +function checkOnlybodyPage() +{ + if(location.href == top.location.href) + { + href = location.href.replace('?onlybody=yes', ''); + location.href = href.replace('&onlybody=yes', ''); + } +} + +/** + * Fixed tfoot action like productplan,release. + * + * @param string $formID + * @access public + * @return void + */ +function fixedTfootAction(formID) +{ + if($(formID).size() == 0) return false; + if($(formID).find('table:last').find('tfoot').size() == 0) return false; + + fixTfootInit(); + $(window).scroll(fixTfoot).resize(fixTfoot);//Fix table foot when scrolling. + $('.side-handle').click(function(){setTimeout(fixTfootInit, 300);});//Fix table foot if module tree is hidden or displayed. + + var $table, $tfoot, $inputGroup, tableWidth, tableOffset, hasFixed; + function fixTfoot() + { + $table = $(formID).find('table:last'); + $tfoot = $table.find('tfoot'); + tableWidth = $table.width(); + hasFixed = $tfoot.hasClass('fixedTfootAction'); + offsetHeight = $(window).height() + $(window).scrollTop(); + tableOffset = $table.offset().top + $table.height() - $tfoot.height() / 5; + $inputGroup = $tfoot.find('.table-actions').children('.input-group'); + + if(!hasFixed && offsetHeight <= tableOffset) + { + $tfoot.addClass('fixedTfootAction'); + $tfoot.width(tableWidth); + $tfoot.find('td').width(tableWidth); + if($inputGroup.size() > 0) $inputGroup.width($inputGroup.width()); + } + if(hasFixed && (offsetHeight > tableOffset || $(document).height() == offsetHeight)) + { + $tfoot.removeClass('fixedTfootAction'); + $tfoot.removeAttr('style'); + $tfoot.find('td').removeAttr('style'); + } + } + function fixTfootInit() + { + $tfoot = $(formID).find('table:last').find('tfoot') + if($tfoot.hasClass('fixedTfootAction')) $tfoot.removeClass('fixedTfootAction'); + fixTfoot(); + } +} + +/** + * Fixed table head in div box. + * + * @param string $boxObj + * @access public + * @return void + */ +function fixedTableHead(boxObj) +{ + $(boxObj).scroll(function() + { + var hasFixed = $(this).find('.fixedHead').size() > 0; + if(!hasFixed) + { + $(this).css('position', 'relative'); + if($(this).find('table').size() == 1) + { + var fixed = "" + $(this).find('table thead').html() + '
'; + $(this).prepend(fixed); + var $fixTable = $(this).find('table.fixedHead'); + $fixTable.addClass($(this).find('table:last').attr('class')); + var $dataTable = $(this).find('table:last thead th'); + $fixTable.find('thead th').each(function(i){$fixTable.find('thead th').eq(i).width($dataTable.eq(i).width());}) + } + } + $(this).find('table.fixedHead').css('top',$(this).scrollTop()); + }); +} + +/** + * Fixed table head in list when scrolling. + * + * @param string $tableID + * @access public + * @return void + */ +function fixedTheadOfList(tableID) +{ + if($(tableID).size() == 0) return false; + if($(tableID).css('display') == 'none') return false; + if($(tableID).find('thead').size() == 0) return false; + + fixTheadInit(); + $(window).scroll(fixThead);//Fix table head when scrolling. + $('.side-handle').click(function(){setTimeout(fixTheadInit, 300);});//Fix table head if module tree is hidden or displayed. + + var tableWidth, theadOffset, fixedThead, $fixedThead; + function fixThead() + { + theadOffset = $(tableID).find('thead').offset().top; + $fixedThead = $(tableID).parent().find('.fixedTheadOfList'); + if($fixedThead.size() <= 0 &&theadOffset < $(window).scrollTop()) + { + tableWidth = $(tableID).width(); + fixedThead = "" + $(tableID).find('thead').html() + '
'; + $(tableID).before(fixedThead); + $('.fixedTheadOfList').addClass($(tableID).attr('class')).width(tableWidth); + } + if($fixedThead.size() > 0 && theadOffset >= $(window).scrollTop()) $fixedThead.remove(); + } + function fixTheadInit() + { + $fixedThead = $(tableID).parent().find('.fixedTheadOfList'); + if($fixedThead.size() > 0) $fixedThead.remove(); + fixThead(); + } +} + +/** + * 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 + */ +function applyCssStyle(css, tag) +{ + tag = tag || 'default'; + var name = 'applyStyle-' + tag; + var $style = $('style#' + name); + if(!$style.length) + { + $style = $('