parent
ae238df77e
commit
4c0f54443c
@ -1,82 +0,0 @@ |
||||
# Select2 |
||||
|
||||
## select2 (jQuery) |
||||
|
||||
``` |
||||
<div style="min-height: 100px"> |
||||
<select id="select2-example"> |
||||
<option>one</option> |
||||
<option>two</option> |
||||
<option>three</option> |
||||
</select> |
||||
</div> |
||||
``` |
||||
|
||||
``` |
||||
@javascript |
||||
|
||||
jQuery(function($) { |
||||
$('#select2-example').select2(); |
||||
}); |
||||
``` |
||||
|
||||
## ui-select (Angular) |
||||
|
||||
``` |
||||
<div ng-controller="UiSelectExample" style="min-height: 100px"> |
||||
<ui-select ng-model="person.selected" theme="select2" ng-disabled="disabled" style="min-width: 300px;"> |
||||
<ui-select-match placeholder="Select a person in the list or search their name">{{$select.selected.name}}</ui-select-match> |
||||
<ui-select-choices repeat="person in people | filter: $select.search"> |
||||
<div ng-bind-html="person.name | highlight: $select.search"></div> |
||||
<small> |
||||
email: {{person.email}} |
||||
</small> |
||||
</ui-select-choices> |
||||
</ui-select> |
||||
</div> |
||||
``` |
||||
|
||||
## ui-select (Angular): multiple |
||||
|
||||
``` |
||||
<div ng-controller="UiSelectExample" style="min-height: 100px"> |
||||
<ui-select multiple ng-model="selectedPeople" theme="select2" ng-disabled="disabled" style="min-width: 300px;"> |
||||
<ui-select-match placeholder="Select a person in the list or search their name">{{$item.name}}</ui-select-match> |
||||
<ui-select-choices repeat="person in people | filter: $select.search"> |
||||
<div ng-bind-html="person.name | highlight: $select.search"></div> |
||||
<small> |
||||
email: {{person.email}} |
||||
</small> |
||||
</ui-select-choices> |
||||
</ui-select> |
||||
</div> |
||||
``` |
||||
|
||||
``` |
||||
@javascript |
||||
|
||||
angular.module('openproject').controller('UiSelectExample', ['$scope', function($scope) { |
||||
$scope.disabled = undefined; |
||||
|
||||
$scope.enable = function() { |
||||
$scope.disabled = false; |
||||
}; |
||||
|
||||
$scope.disable = function() { |
||||
$scope.disabled = true; |
||||
}; |
||||
|
||||
$scope.person = {}; |
||||
$scope.people = [ |
||||
{ name: 'Adam', email: 'adam@email.com' }, |
||||
{ name: 'Amalie', email: 'amalie@email.com' }, |
||||
{ name: 'Wladimir', email: 'wladimir@email.com' }, |
||||
{ name: 'Samantha', email: 'samantha@email.com' }, |
||||
{ name: 'Estefanía', email: 'estefanía@email.com' }, |
||||
{ name: 'Natasha', email: 'natasha@email.com' }, |
||||
{ name: 'Nicole', email: 'nicole@email.com' }, |
||||
{ name: 'Adrian', email: 'adrian@email.com' } |
||||
]; |
||||
$scope.selectedPeople = [$scope.people[5], $scope.people[4]]; |
||||
}]); |
||||
``` |
@ -1,150 +0,0 @@ |
||||
//-- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See doc/COPYRIGHT.rdoc for more details.
|
||||
//++
|
||||
|
||||
// import * as angular from 'angular';
|
||||
//
|
||||
// // global
|
||||
// export const opUiComponentsModule = angular.module('openproject.uiComponents',
|
||||
// ['ui.select', 'ui.router', 'ui.router.upgrade', 'openproject.workPackages.services'])
|
||||
// .run(['$rootScope', function ($rootScope:ng.IRootScopeService) {
|
||||
// ($rootScope as any)['I18n'] = I18n;
|
||||
// }]);
|
||||
// export const animationsModule = angular.module('openproject.animations', [
|
||||
// 'ngAnimate'
|
||||
// ]);
|
||||
// export const opConfigModule = angular.module('openproject.config', []);
|
||||
// export const opServicesModule = angular.module('openproject.services', [
|
||||
// 'openproject.uiComponents',
|
||||
// 'openproject.config',
|
||||
// 'openproject.helpers',
|
||||
// 'openproject.workPackages.config',
|
||||
// 'openproject.workPackages.helpers',
|
||||
// 'openproject.api'
|
||||
// ]);
|
||||
// angular.module('openproject.helpers', ['openproject.services']);
|
||||
//
|
||||
// // work packages
|
||||
// export const opWorkPackagesModule = angular.module('openproject.workPackages', [
|
||||
// 'openproject.workPackages.activities',
|
||||
// 'openproject.workPackages.controllers',
|
||||
// 'openproject.workPackages.filters',
|
||||
// 'openproject.workPackages.directives',
|
||||
// 'openproject.workPackages.tabs',
|
||||
// 'openproject.uiComponents',
|
||||
// 'ngFileUpload'
|
||||
// ]);
|
||||
// export const wpServicesModule = angular.module('openproject.workPackages.services', [
|
||||
// 'openproject.inplace-edit'
|
||||
// ]);
|
||||
// angular.module(
|
||||
// 'openproject.workPackages.helpers', [
|
||||
// 'openproject.helpers',
|
||||
// 'openproject.workPackages.services'
|
||||
// ]);
|
||||
// angular.module('openproject.workPackages.filters', [
|
||||
// 'openproject.workPackages.helpers'
|
||||
// ]);
|
||||
// angular.module('openproject.workPackages.config', []);
|
||||
// export const wpControllersModule = angular.module('openproject.workPackages.controllers', [
|
||||
// 'openproject.workPackages.helpers',
|
||||
// 'openproject.services',
|
||||
// 'openproject.workPackages.config',
|
||||
// 'openproject.layout'
|
||||
// ]);
|
||||
// angular.module('openproject.workPackages.models', []);
|
||||
// export const wpDirectivesModule = angular.module('openproject.workPackages.directives', [
|
||||
// 'openproject.uiComponents',
|
||||
// 'openproject.services',
|
||||
// 'openproject.workPackages.services',
|
||||
// 'openproject.workPackages.models'
|
||||
// ]);
|
||||
// export const wpTabsModule = angular.module('openproject.workPackages.tabs', []);
|
||||
// angular.module('openproject.workPackages.activities', []);
|
||||
//
|
||||
// // messages
|
||||
// angular.module('openproject.messages', [
|
||||
// 'openproject.messages.controllers'
|
||||
// ]);
|
||||
// angular.module('openproject.messages.controllers', []);
|
||||
//
|
||||
// // time entries
|
||||
// angular.module('openproject.timeEntries', [
|
||||
// 'openproject.timeEntries.controllers'
|
||||
// ]);
|
||||
// angular.module('openproject.timeEntries.controllers', []);
|
||||
//
|
||||
// angular.module('openproject.layout', [
|
||||
// 'openproject.layout.controllers',
|
||||
// 'ui.router',
|
||||
// 'ui.router.upgrade'
|
||||
// ]);
|
||||
// angular.module('openproject.layout.controllers', []);
|
||||
//
|
||||
// export const opApiModule = angular.module('openproject.api', [
|
||||
// 'openproject.workPackages',
|
||||
// 'openproject.services'
|
||||
// ]);
|
||||
//
|
||||
// export const opTemplatesModule = angular.module('openproject.templates', []);
|
||||
//
|
||||
// export const opNotificationsModule = angular.module('openproject.notifications', [
|
||||
// 'openproject.config'
|
||||
// ]);
|
||||
//
|
||||
// // refactoring
|
||||
// angular.module('openproject.inplace-edit', []);
|
||||
// angular.module('openproject.responsive', []);
|
||||
//
|
||||
// export const wpButtonsModule = angular.module('openproject.wpButtons',
|
||||
// ['ui.router', 'ui.router.upgrade', 'openproject.services']);
|
||||
//
|
||||
// // main app
|
||||
// var angularDragula:any = require('angular-dragula');
|
||||
//
|
||||
// export const openprojectModule = angular.module('openproject', [
|
||||
// 'ui.router',
|
||||
// 'ui.router.upgrade',
|
||||
// 'openproject.animations',
|
||||
// 'openproject.config',
|
||||
// 'openproject.uiComponents',
|
||||
// 'openproject.workPackages',
|
||||
// 'openproject.messages',
|
||||
// 'openproject.timeEntries',
|
||||
// 'ngAnimate',
|
||||
// 'ngAria',
|
||||
// angularDragula(angular),
|
||||
// 'openproject.layout',
|
||||
// 'openproject.api',
|
||||
// 'openproject.templates',
|
||||
// 'monospaced.elastic',
|
||||
// 'openproject.inplace-edit',
|
||||
// wpButtonsModule.name,
|
||||
// 'openproject.responsive',
|
||||
// ]);
|
||||
//
|
||||
// export default openprojectModule;
|
@ -1,62 +0,0 @@ |
||||
// -- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See doc/COPYRIGHT.rdoc for more details.
|
||||
// ++
|
||||
|
||||
import {WorkPackageFiltersService} from "./wp-filters.service"; |
||||
const expect = chai.expect; |
||||
|
||||
describe('wpFiltersService', () => { |
||||
var wpFiltersService:WorkPackageFiltersService; |
||||
|
||||
beforeEach(angular.mock.module('openproject.services')); |
||||
beforeEach(angular.mock.inject((_wpFiltersService_:any) => { |
||||
wpFiltersService = _wpFiltersService_; |
||||
})); |
||||
|
||||
it('should exist', () => { |
||||
expect(wpFiltersService).to.exist; |
||||
}); |
||||
|
||||
it('should have set its visibility to false', () => { |
||||
expect(wpFiltersService.visible).to.be.false; |
||||
}); |
||||
|
||||
describe('when using toggleVisibility', () => { |
||||
beforeEach(() => { |
||||
wpFiltersService.toggleVisibility(); |
||||
}); |
||||
|
||||
it('should turn its visibility to true', () => { |
||||
expect(wpFiltersService.visible).to.be.true; |
||||
}); |
||||
|
||||
it('should turn off its visibility when used again', () => { |
||||
wpFiltersService.toggleVisibility(); |
||||
expect(wpFiltersService.visible).to.be.false; |
||||
}); |
||||
}); |
||||
}); |
@ -1,49 +0,0 @@ |
||||
// -- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See doc/COPYRIGHT.rdoc for more details.
|
||||
// ++
|
||||
|
||||
import {opDirective} from './open-project.module'; |
||||
|
||||
describe('OpenProject module', () => { |
||||
describe('opDirective function', () => { |
||||
it('should deeply merge the given configuration parameters', () => { |
||||
var directive:ng.IDirective = { |
||||
scope: { |
||||
someValue: '=' |
||||
} |
||||
}; |
||||
var config:ng.IDirective = { |
||||
scope: { |
||||
someOtherValue: '=' |
||||
} |
||||
}; |
||||
var merged:any = opDirective(directive, config); |
||||
|
||||
expect(merged.scope['someValue']).to.eq(merged.scope['someOtherValue']); |
||||
}); |
||||
}); |
||||
}); |
@ -1,32 +0,0 @@ |
||||
// -- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See doc/COPYRIGHT.rdoc for more details.
|
||||
// ++
|
||||
|
||||
export function opDirective(directive:ng.IDirective = {}, config:ng.IDirective = {}):ng.IDirective { |
||||
// TODO: Replace '_.merge' with AngularJS v1.4 'angular.merge' method
|
||||
return _.merge(directive, config); |
||||
} |
@ -1,80 +0,0 @@ |
||||
// -- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See doc/COPYRIGHT.rdoc for more details.
|
||||
// ++
|
||||
|
||||
import IScope = angular.IScope; |
||||
import {Observable} from 'rxjs'; |
||||
import {Observer} from 'rxjs'; |
||||
|
||||
export function runInScopeDigest(scope:IScope, fn:() => void) { |
||||
if (scope.$root.$$phase !== '$apply' && scope.$root.$$phase !== '$digest') { |
||||
scope.$apply(fn); |
||||
} else { |
||||
fn(); |
||||
} |
||||
} |
||||
|
||||
export function scopedObservable<T>(scope:IScope, observable:Observable<T>):Observable<T> { |
||||
return Observable.create((observer:Observer<T>) => { |
||||
var disposable = observable.subscribe( |
||||
value => { |
||||
runInScopeDigest(scope, () => observer.next(value)); |
||||
}, |
||||
exception => { |
||||
runInScopeDigest(scope, () => observer.error(exception)); |
||||
}, |
||||
() => { |
||||
runInScopeDigest(scope, () => observer.complete()); |
||||
} |
||||
); |
||||
|
||||
scope.$on('$destroy', () => { |
||||
return disposable.unsubscribe(); |
||||
}); |
||||
}); |
||||
} |
||||
|
||||
export function asyncTest<T>(done:(error?:any) => void, fn:(value:T) => any):(T:any) => any { |
||||
return (value:T) => { |
||||
try { |
||||
fn(value); |
||||
done(); |
||||
} catch (err) { |
||||
done(err); |
||||
} |
||||
}; |
||||
|
||||
} |
||||
|
||||
export function scopeDestroyed$(scope:IScope):Observable<IScope> { |
||||
return Observable.create((s:Observer<IScope>) => { |
||||
scope.$on('$destroy', () => { |
||||
s.next(scope); |
||||
s.complete(); |
||||
}); |
||||
}); |
||||
} |
@ -1,34 +0,0 @@ |
||||
//-- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See docs/COPYRIGHT.rdoc for more details.
|
||||
//++
|
||||
|
||||
// angular.module('openproject.layout.controllers')
|
||||
// .controller('MainMenuController', [
|
||||
// '$rootScope',
|
||||
// '$window',
|
||||
// require('./main-menu-controller')
|
||||
// ]);
|
@ -1,86 +0,0 @@ |
||||
//-- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See docs/COPYRIGHT.rdoc for more details.
|
||||
//++
|
||||
|
||||
module.exports = function($rootScope, $window) { |
||||
var self = this; |
||||
|
||||
this.toggleNavigation = function(event) { |
||||
event.preventDefault(); |
||||
event.stopPropagation(); |
||||
|
||||
if (!$rootScope.showNavigation) { |
||||
// main menu shall expand.
|
||||
|
||||
// Set focus on first visible main menu item.
|
||||
//
|
||||
// This needs to be called after AngularJS has rendered the menu, which happens some when after(!) we leave this
|
||||
// method here. So we need to set the focus after a timeout.
|
||||
setTimeout(function() { |
||||
jQuery('#main-menu [class*="-menu-item"]:visible').first().focus(); |
||||
}, 100); |
||||
|
||||
// On mobile the main menu shall close whenever you click outside the menu.
|
||||
if ($window.innerWidth < 680) { |
||||
self.setupAutocloseMainMenu(); |
||||
} |
||||
|
||||
// Regain default width: Expand to default menu width if collapsed slimmer than default width.
|
||||
var savedMainMenuWidth = parseInt(window.OpenProject.guardedLocalStorage("openProject-mainMenuWidth")); |
||||
if (savedMainMenuWidth < 230) { |
||||
document.documentElement.style.setProperty("--main-menu-width", '230px'); |
||||
window.OpenProject.guardedLocalStorage("openProject-mainMenuWidth", '230'); |
||||
} |
||||
} |
||||
$rootScope.showNavigation = !$rootScope.showNavigation; |
||||
|
||||
$rootScope.$broadcast('openproject.layout.navigationToggled', $rootScope.showNavigation); |
||||
$window.sessionStorage.setItem('openproject:navigation-toggle', |
||||
!$rootScope.showNavigation ? 'collapsed' : 'expanded'); |
||||
}; |
||||
|
||||
this.setupAutocloseMainMenu = function() { |
||||
jQuery('#main-menu').on('focusout.main_menu', function (event) { |
||||
jQuery('#main-menu').off('focusout.main_menu'); |
||||
|
||||
// Check that main menu is not closed and that the `focusout` event is not a click on an element that tries to close
|
||||
// the menu anyways.
|
||||
if (!$rootScope.showNavigation || |
||||
jQuery.contains(document.getElementById('main-menu-toggle'), event.relatedTarget)) { |
||||
return; |
||||
} |
||||
|
||||
// There might be a time gap between `focusout` and the focussing of the activeElement, thus we need a timeout.
|
||||
setTimeout(function() { |
||||
if (!jQuery.contains(document.getElementById('main-menu'), document.activeElement)) { |
||||
// activeElement is outside of main menu.
|
||||
self.toggleNavigation(new Event('onclick')); |
||||
} |
||||
}, 0); |
||||
}); |
||||
} |
||||
}; |
@ -1,29 +0,0 @@ |
||||
//-- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See docs/COPYRIGHT.rdoc for more details.
|
||||
//++
|
||||
|
||||
require('./controllers'); |
@ -0,0 +1,91 @@ |
||||
//-- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See doc/COPYRIGHT.rdoc for more details.
|
||||
//++
|
||||
|
||||
import {AccessibleByKeyboardComponent} from "core-app/modules/a11y/accessible-by-keyboard.component"; |
||||
import {async, TestBed} from "@angular/core/testing"; |
||||
import {OpIcon} from "core-app/modules/common/icon/op-icon"; |
||||
import {ComponentFixture} from "@angular/core/testing/src/component_fixture"; |
||||
import {By} from "@angular/platform-browser"; |
||||
import {DebugElement} from "@angular/core"; |
||||
|
||||
require('core-app/angular4-test-setup'); |
||||
|
||||
describe('opIcon Directive', function() { |
||||
let app:OpIcon; |
||||
let fixture:ComponentFixture<OpIcon>; |
||||
let element:DebugElement; |
||||
|
||||
beforeEach(async(() => { |
||||
// noinspection JSIgnoredPromiseFromCall
|
||||
TestBed.configureTestingModule({ |
||||
declarations: [ |
||||
OpIcon |
||||
] |
||||
}).compileComponents(); |
||||
})); |
||||
|
||||
beforeEach(() => { |
||||
fixture = TestBed.createComponent(OpIcon); |
||||
app = fixture.debugElement.componentInstance; |
||||
element = fixture.debugElement; |
||||
|
||||
app.iconClasses = 'icon-foobar icon-context'; |
||||
fixture.detectChanges(); |
||||
}); |
||||
|
||||
describe('without a title', function() { |
||||
it('should render an icon', function () { |
||||
const i = element.query(By.css('i')); |
||||
|
||||
expect(i.nativeElement.tagName.toLowerCase()).to.equal('i'); |
||||
expect(i.classes['icon-foobar']).to.be.true; |
||||
expect(i.classes['icon-context']).to.be.true; |
||||
|
||||
expect(element.query(By.css('span'))).to.not.be.ok; |
||||
}); |
||||
}); |
||||
|
||||
describe('with a title', function() { |
||||
beforeEach(function() { |
||||
app.iconTitle = 'blabla'; |
||||
fixture.detectChanges(); |
||||
}); |
||||
|
||||
it('should render icon and title', function() { |
||||
const i = element.query(By.css('i')); |
||||
const span = element.query(By.css('span')); |
||||
|
||||
expect(i.nativeElement.tagName.toLowerCase()).to.equal('i'); |
||||
expect(i.classes['icon-foobar']).to.be.true; |
||||
expect(i.classes['icon-context']).to.be.true; |
||||
|
||||
expect(span.nativeElement.tagName.toLowerCase()).to.equal('span'); |
||||
expect(span.nativeElement.textContent).to.equal('blabla'); |
||||
}); |
||||
}); |
||||
}); |
@ -1,79 +0,0 @@ |
||||
//-- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See doc/COPYRIGHT.rdoc for more details.
|
||||
//++
|
||||
|
||||
describe('opIcon Directive', function() { |
||||
let compile:Function; |
||||
let element:ng.IAugmentedJQuery; |
||||
let html:string; |
||||
|
||||
beforeEach(angular.mock.module('openproject.uiComponents')); |
||||
|
||||
beforeEach(inject(function($rootScope:ng.IRootScopeService, $compile:ng.ICompileService) { |
||||
html = `<op-icon icon-classes="icon-foobar icon-context"></op-icon>`; |
||||
|
||||
compile = function() { |
||||
element = angular.element(html); |
||||
$compile(element)($rootScope); |
||||
$rootScope.$digest(); |
||||
}; |
||||
})); |
||||
|
||||
describe('without a title', function() { |
||||
beforeEach(function () { |
||||
compile(); |
||||
}); |
||||
|
||||
it('should render an icon', function () { |
||||
const i = element.find('i'); |
||||
expect(i[0].tagName.toLowerCase()).to.equal('i'); |
||||
expect(i.hasClass('icon-foobar')).to.be.true; |
||||
expect(i.hasClass('icon-context')).to.be.true; |
||||
|
||||
expect(element.find('span').length).to.equal(0); |
||||
}); |
||||
}); |
||||
|
||||
describe('with a title', function() { |
||||
beforeEach(function() { |
||||
html = `<op-icon icon-title="blabla" icon-classes="icon-foobar icon-context"></op-icon>`; |
||||
compile(); |
||||
}); |
||||
|
||||
it('should render icon and title', function() { |
||||
const i = element.find('i'); |
||||
const span = element.find('span'); |
||||
|
||||
expect(i[0].tagName.toLowerCase()).to.equal('i'); |
||||
expect(i.hasClass('icon-foobar')).to.be.true; |
||||
expect(i.hasClass('icon-context')).to.be.true; |
||||
|
||||
expect(span[0].tagName.toLowerCase()).to.equal('span'); |
||||
expect(span.text()).to.equal('blabla'); |
||||
}); |
||||
}); |
||||
}); |
@ -1,37 +0,0 @@ |
||||
// -- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See doc/COPYRIGHT.rdoc for more details.
|
||||
// ++
|
||||
|
||||
angular |
||||
.module('openproject.workPackages.filters') |
||||
.filter('latestItems', latestItems); |
||||
|
||||
function latestItems() { |
||||
return function(items, visible, reverse) { |
||||
return reverse ? items.slice(-visible).reverse() : items.slice(0,visible); |
||||
}; |
||||
} |
@ -1,53 +0,0 @@ |
||||
// -- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See doc/COPYRIGHT.rdoc for more details.
|
||||
// ++
|
||||
|
||||
describe('Latest items filter', function() { |
||||
|
||||
beforeEach(angular.mock.module('openproject.workPackages.filters')); |
||||
|
||||
describe('latestItems', function() { |
||||
var items; |
||||
|
||||
beforeEach(function(){ |
||||
items = [1,2,3,4,5,6,7,8,9]; |
||||
}); |
||||
|
||||
it('should be defined', inject(function($filter) { |
||||
expect($filter('latestItems')).not.to.equal(null); |
||||
})); |
||||
|
||||
it('should return the first 3 items', inject(function($filter) { |
||||
expect($filter('latestItems')(items, 3, true)).to.eql([9,8,7]); |
||||
})); |
||||
|
||||
it('should return the last 3 items reversed', inject(function($filter) { |
||||
expect($filter('latestItems')(items, 3)).to.eql([1,2,3]); |
||||
})); |
||||
|
||||
}); |
||||
}); |
@ -1,60 +0,0 @@ |
||||
// -- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See doc/COPYRIGHT.rdoc for more details.
|
||||
// ++
|
||||
|
||||
function lazy (obj:any, property:string, getter:{():any}, setter?:{(value:any):void}):void { |
||||
if (angular.isObject(obj)) { |
||||
let done = false; |
||||
let value:any; |
||||
let config:any = { |
||||
get() { |
||||
if (!done) { |
||||
value = getter(); |
||||
done = true; |
||||
} |
||||
return value; |
||||
}, |
||||
set: ():void => undefined, |
||||
|
||||
configurable: true, |
||||
enumerable: true |
||||
}; |
||||
|
||||
if (setter) { |
||||
config.set = (val:any) => { |
||||
value = setter(val); |
||||
done = true; |
||||
}; |
||||
} |
||||
|
||||
Object.defineProperty(obj, property, config); |
||||
} |
||||
} |
||||
|
||||
angular |
||||
.module('openproject.services') |
||||
.factory('lazy', () => lazy); |
@ -1,42 +0,0 @@ |
||||
// -- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See doc/COPYRIGHT.rdoc for more details.
|
||||
// ++
|
||||
|
||||
|
||||
describe('loadingIndicator service', () => { |
||||
var loadingIndicator:any; |
||||
|
||||
beforeEach(angular.mock.module('openproject.services')); |
||||
|
||||
beforeEach(angular.mock.inject((_loadingIndicator_:any) => { |
||||
loadingIndicator = _loadingIndicator_; |
||||
})); |
||||
|
||||
it('should exist', () => { |
||||
expect(loadingIndicator).to.exist; |
||||
}); |
||||
}); |
@ -1,45 +0,0 @@ |
||||
{ |
||||
"projects": [ |
||||
{ |
||||
"identifier": "bums", |
||||
"created_on": "2012-12-18T07:00:17Z", |
||||
"level": 0, |
||||
"updated_on": "2012-12-18T09:09:10Z", |
||||
"name": "Bums zzz", |
||||
"id": 3 |
||||
}, |
||||
{ |
||||
"identifier": "things", |
||||
"created_on": "2012-12-14T14:01:27Z", |
||||
"level": 0, |
||||
"updated_on": "2012-12-14T14:01:27Z", |
||||
"name": "Things", |
||||
"id": 1 |
||||
}, |
||||
{ |
||||
"identifier": "things-bums", |
||||
"created_on": "2012-12-18T06:59:50Z", |
||||
"level": 1, |
||||
"updated_on": "2012-12-18T14:26:05Z", |
||||
"name": "Thingsb-Bums", |
||||
"id": 2 |
||||
}, |
||||
{ |
||||
"identifier": "bums-bums", |
||||
"created_on": "2012-12-18T08:57:46Z", |
||||
"level": 2, |
||||
"updated_on": "2012-12-18T08:57:46Z", |
||||
"name": "Bums Bums", |
||||
"id": 5 |
||||
}, |
||||
{ |
||||
"identifier": "zzz", |
||||
"created_on": "2012-12-18T08:57:14Z", |
||||
"level": 0, |
||||
"updated_on": "2012-12-18T08:57:14Z", |
||||
"name": "ZZZ", |
||||
"id": 4 |
||||
} |
||||
], |
||||
"size": 5 |
||||
} |
@ -1,103 +0,0 @@ |
||||
//-- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See docs/COPYRIGHT.rdoc for more details.
|
||||
//++
|
||||
|
||||
function objectSortationEqual(array1, array2) { |
||||
if (array1.length !== array2.length) { |
||||
return false; |
||||
} |
||||
|
||||
var i; |
||||
for (i = 0; i < array2.length; i += 1) { |
||||
if (array1[i].id !== array2[i].id || array1[i].name !== array2[i].name) { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
function objectsortation() { |
||||
var givenSortation = arguments; |
||||
return function (arr) { |
||||
return objectSortationEqual(arr, givenSortation); |
||||
}; |
||||
} |
||||
|
||||
function sortById(a, b) { |
||||
return a.id > b.id; |
||||
} |
||||
|
||||
function objectContainsAll(givenArray) { |
||||
var givenObjects; |
||||
if (arguments.length === 1 && givenArray instanceof Array) { |
||||
givenObjects = givenArray; |
||||
} else { |
||||
givenObjects = Array.prototype.slice.call(arguments); |
||||
} |
||||
|
||||
givenObjects.sort(sortById); |
||||
|
||||
return function (arr) { |
||||
arr.sort(sortById); |
||||
|
||||
return objectSortationEqual(arr, givenObjects); |
||||
}; |
||||
} |
||||
|
||||
var a = function () { |
||||
return new attributeBuilder(); |
||||
}; |
||||
|
||||
var attributeBuilder = function () {}; |
||||
|
||||
var w = this; |
||||
|
||||
function addProperty(obj, attr) { |
||||
Object.defineProperty(obj, "s" + attr, |
||||
{ |
||||
get: function () { |
||||
return function (val) { |
||||
this[attr] = val; |
||||
|
||||
return this; |
||||
}; |
||||
}, configurable: true |
||||
} |
||||
); |
||||
} |
||||
|
||||
var properties = ["id", "name", "identifier"]; |
||||
|
||||
var i; |
||||
for (i = 0; i < properties.length; i += 1) { |
||||
addProperty(attributeBuilder.prototype, properties[i]); |
||||
} |
||||
|
||||
attributeBuilder.prototype.b = function () { |
||||
return this._result; |
||||
}; |
@ -1,82 +0,0 @@ |
||||
//-- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License version 3.
|
||||
//
|
||||
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
// Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
// Copyright (C) 2010-2013 the ChiliProject Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// See docs/COPYRIGHT.rdoc for more details.
|
||||
//++
|
||||
|
||||
/*jshint expr: true*/ |
||||
|
||||
describe('MainMenuController', function() { |
||||
var rootScope, sessionStorage, ctrl; |
||||
|
||||
beforeEach(angular.mock.module('openproject.layout.controllers')); |
||||
|
||||
beforeEach(inject(function($rootScope, $controller) { |
||||
rootScope = $rootScope.$new(); |
||||
event = new Event('conclick'); |
||||
var fakeSession = {}; |
||||
sessionStorage = { |
||||
setItem: function(k, v) { fakeSession[k] = v; }, |
||||
getItem: function(k) { return fakeSession[k]; } |
||||
}; |
||||
|
||||
ctrl = $controller("MainMenuController", { |
||||
$rootScope: rootScope, |
||||
$window: { sessionStorage: sessionStorage } |
||||
}); |
||||
})); |
||||
|
||||
describe('toggleNavigation', function() { |
||||
it('should toggle navigation off', function() { |
||||
rootScope.showNavigation = true; |
||||
ctrl.toggleNavigation(event); |
||||
expect(rootScope.showNavigation).to.be.false; |
||||
}); |
||||
|
||||
it('should toggle navigation on', function() { |
||||
rootScope.showNavigation = false; |
||||
ctrl.toggleNavigation(event); |
||||
expect(rootScope.showNavigation).to.be.true; |
||||
}); |
||||
|
||||
it('should fire an event when toggled', function() { |
||||
var callback = sinon.spy(); |
||||
rootScope.$on('openproject.layout.navigationToggled', callback); |
||||
ctrl.toggleNavigation(event); |
||||
expect(callback).to.have.been.calledWithMatch(sinon.match.any, sinon.match.truthy); |
||||
}); |
||||
|
||||
it('should persist choice to sessionStorage', function() { |
||||
expect(sessionStorage.getItem('openproject:navigation-toggle')).to.be.undefined; |
||||
|
||||
ctrl.toggleNavigation(event); |
||||
expect(sessionStorage.getItem('openproject:navigation-toggle')).to.equal('expanded'); |
||||
|
||||
ctrl.toggleNavigation(event); |
||||
expect(sessionStorage.getItem('openproject:navigation-toggle')).to.equal('collapsed'); |
||||
}); |
||||
}); |
||||
|
||||
}); |
Loading…
Reference in new issue