| Conditions | 1 |
| Paths | 1 |
| Total Lines | 95 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | define(function(require) { |
||
| 2 | 'use strict'; |
||
| 3 | |||
| 4 | var BaseController = require('oroui/js/app/controllers/base/controller'); |
||
| 5 | var PageView = require('oroui/js/app/views/page-view'); |
||
| 6 | var module = require('module'); |
||
| 7 | var _ = require('underscore'); |
||
| 8 | |||
| 9 | var config = module.config(); |
||
| 10 | config = _.extend({ |
||
| 11 | showLoadingMaskOnStartup: false, |
||
| 12 | showLoadingBarOnStartup: false |
||
| 13 | }, config); |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Init PageView |
||
| 17 | */ |
||
| 18 | BaseController.addToReuse('page', PageView, { |
||
| 19 | el: 'body', |
||
| 20 | keepElement: true, |
||
| 21 | regions: { |
||
| 22 | mainContainer: '#container', |
||
| 23 | messages: '#flash-messages' |
||
| 24 | } |
||
| 25 | }); |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Init PageMessagesView |
||
| 29 | */ |
||
| 30 | BaseController.loadBeforeAction([ |
||
| 31 | 'oroui/js/app/views/page/messages-view' |
||
| 32 | ], function(PageMessagesView) { |
||
| 33 | BaseController.addToReuse('messages', PageMessagesView, { |
||
| 34 | el: 'region:messages' |
||
| 35 | }); |
||
| 36 | }); |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Init PageContentView |
||
| 40 | */ |
||
| 41 | BaseController.loadBeforeAction([ |
||
| 42 | 'oroui/js/app/views/page/content-view' |
||
| 43 | ], function(PageContentView) { |
||
| 44 | BaseController.addToReuse('content', PageContentView, { |
||
| 45 | el: 'region:mainContainer' |
||
| 46 | }); |
||
| 47 | }); |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Init PageLoadingMaskView |
||
| 51 | */ |
||
| 52 | BaseController.loadBeforeAction([ |
||
| 53 | 'oroui/js/mediator', |
||
| 54 | 'oroui/js/app/views/loading-mask-view' |
||
| 55 | ], function(mediator, LoadingMaskView) { |
||
| 56 | BaseController.addToReuse('loadingMask', { |
||
| 57 | compose: function() { |
||
| 58 | this.view = new LoadingMaskView({ |
||
| 59 | container: 'body', |
||
| 60 | hideDelay: 25 |
||
| 61 | }); |
||
| 62 | mediator.setHandler('showLoading', this.view.show, this.view); |
||
| 63 | mediator.setHandler('hideLoading', this.view.hide, this.view); |
||
| 64 | mediator.on('page:beforeChange', this.view.show, this.view); |
||
| 65 | mediator.on('page:afterChange', this.view.hide, this.view); |
||
| 66 | if (config.showLoadingMaskOnStartup) { |
||
| 67 | this.view.show(); |
||
| 68 | } |
||
| 69 | } |
||
| 70 | }); |
||
| 71 | }); |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Init PageLoadingBarView |
||
| 75 | */ |
||
| 76 | BaseController.loadBeforeAction([ |
||
| 77 | 'oroui/js/mediator', |
||
| 78 | 'oroui/js/app/views/loading-bar-view' |
||
| 79 | ], function(mediator, LoadingBarView) { |
||
| 80 | BaseController.addToReuse('loadingBar', { |
||
| 81 | compose: function() { |
||
| 82 | this.view = new LoadingBarView({ |
||
| 83 | ajaxLoading: true |
||
| 84 | }); |
||
| 85 | mediator.setHandler('showLoadingBar', this.view.showLoader, this.view); |
||
| 86 | mediator.setHandler('hideLoadingBar', this.view.hideLoader, this.view); |
||
| 87 | mediator.on('page:beforeChange', this.view.showLoader, this.view); |
||
| 88 | mediator.on('page:afterChange', this.view.hideLoader, this.view); |
||
| 89 | if (config.showLoadingBarOnStartup) { |
||
| 90 | this.view.showLoader(); |
||
| 91 | } |
||
| 92 | } |
||
| 93 | }); |
||
| 94 | }); |
||
| 95 | }); |
||
| 96 |