Commit f74c41d25288ab4a55b81192240ecfce965ef4ce

Authored by Michel Felipe
2 parents 02560aee 61a0811c

Merge branch 'design-mode' into 'master'

Design mode - Fixes from Merge !39

See merge request !42
bower.json
... ... @@ -38,8 +38,8 @@
38 38 "angular-bind-html-compile": "^1.2.1",
39 39 "angular-click-outside": "^2.7.1",
40 40 "ng-ckeditor": "^0.2.1",
41   - "angular-bootstrap-toggle-switch": "^0.5.6",
42   - "angular-tag-cloud": "^0.3.0"
  41 + "angular-tag-cloud": "^0.3.0",
  42 + "angular-ui-switch": "^0.1.1"
43 43 },
44 44 "devDependencies": {
45 45 "angular-mocks": "~1.5.0"
... ...
src/app/admin/layout-edit/designModeToggler.component.spec.ts
1 1 import {ComponentTestHelper, createClass} from '../../../spec/component-test-helper';
  2 +import {INgForwardJQuery} from 'ng-forward/cjs/util/jqlite-extensions';
2 3 import * as helpers from '../../../spec/helpers';
3 4 import {DesignModeTogglerComponent} from './designModeToggler.component';
4 5 import {DesignModeService} from './designMode.service';
5 6 import {INoosferoLocalStorage} from "./../../shared/models/interfaces";
6 7  
7 8 describe('DesignModeToggler Component', () => {
8   - const htmlTemplate: string = '<noosfero-design-toggler></noosfero-design-toggler>';
  9 + const htmlTemplate: string = '<design-toggler></design-toggler>';
9 10  
10 11 let helper: ComponentTestHelper<DesignModeTogglerComponent>;
11 12 beforeEach(() => {
12 13 angular.mock.module('templates');
13 14 angular.mock.module('ngSanitize');
14   - angular.mock.module('toggle-switch');
  15 + angular.mock.module('uiSwitch');
15 16 });
16 17  
17 18 let designModeService: DesignModeService;
... ... @@ -30,12 +31,12 @@ describe(&#39;DesignModeToggler Component&#39;, () =&gt; {
30 31 });
31 32  
32 33 it('changes css classes representing the switch is on or off', () => {
33   - expect(helper.debugElement.query('div.switch-animate').hasClass('switch-off')).toBeTruthy();
34   - expect(helper.debugElement.query('div.switch-animate').hasClass('switch-on')).toBeFalsy();
  34 + let switchEl: INgForwardJQuery = helper.debugElement.query('span.switch');
  35 +
  36 + expect(switchEl.hasClass('checked')).toBeFalsy();
35 37 helper.component.inDesignMode = true;
36 38 helper.detectChanges();
37   - expect(helper.debugElement.query('div.switch-animate').hasClass('switch-on')).toBeTruthy();
38   - expect(helper.debugElement.query('div.switch-animate').hasClass('switch-off')).toBeFalsy();
  39 + expect(switchEl.hasClass('checked')).toBeTruthy();
39 40 });
40 41  
41 42 it('emits event with value "true" when changing inDesignMode to On', (done) => {
... ... @@ -60,4 +61,4 @@ describe(&#39;DesignModeToggler Component&#39;, () =&gt; {
60 61 helper.component.inDesignMode = false;
61 62 helper.detectChanges();
62 63 });
63   -});
64 64 \ No newline at end of file
  65 +});
... ...
src/app/admin/layout-edit/designModeToggler.component.ts
1   -import {Component, Inject} from 'ng-forward';
  1 +import {Component, Inject, Input} from 'ng-forward';
2 2 import {DesignModeService} from './designMode.service';
3 3 import {AuthService, AuthEvents} from '../../login';
4 4  
5 5 @Component({
6   - selector: 'noosfero-design-toggler',
  6 + selector: 'design-toggler',
7 7 templateUrl: 'app/admin/layout-edit/designModeToggler.html'
8 8 })
9   -@Inject(DesignModeService, AuthService)
  9 +@Inject(DesignModeService, AuthService, '$sce')
10 10 export class DesignModeTogglerComponent {
11 11  
12   - icon: string = "&nbsp;<i class='glyphicon glyphicon-wrench'></i>&nbsp;";
  12 + private _inDesignMode: boolean = false;
13 13  
14   - constructor(private designModeService: DesignModeService, private authService: AuthService) {
  14 + constructor(private designModeService: DesignModeService, private authService: AuthService, private $sce: ng.ISCEService) {
15 15 this.authService.subscribe(AuthEvents[AuthEvents.logoutSuccess], () => {
16 16 this.designModeService.destroy();
17 17 });
18 18 }
19 19  
20   - private _inDesignMode: boolean = false;
21   -
22 20 get inDesignMode(): boolean {
23 21 return this.designModeService.isInDesignMode();
24 22 };
... ...
src/app/admin/layout-edit/designModeToggler.html
1   -<toggle-switch
2   - html="true"
3   - ng-model="ctrl.inDesignMode"
4   - on-label="{{'designMode.toggle.ON' | translate}}"
5   - off-label="{{'designMode.toggle.OFF' | translate}}"
6   - class="switch-small"
7   - knob-label="{{ ctrl.icon + ('designMode.label' | translate) }}">
8   -</toggle-switch>
9 1 \ No newline at end of file
  2 +<switch id="enabled" name="enabled" ng-model="ctrl.inDesignMode" on="ON" off="OFF" class="green"></switch>
... ...
src/app/admin/layout-edit/designModeToggler.scss 0 → 100644
... ... @@ -0,0 +1,55 @@
  1 +$off-text: #949494;
  2 +$off-color: #EFEFEF;
  3 +$blue-color: #36B4F6;
  4 +$red-color: #DF3B3A;
  5 +
  6 +body.noosfero-design-on {
  7 +
  8 + div.content-wrapper {
  9 + opacity: 0.5;
  10 + }
  11 +}
  12 +
  13 +.switch {
  14 + @include not-select();
  15 + background-color: $off-color;
  16 +
  17 + &[on][off] {
  18 + width: 60px;
  19 + }
  20 +
  21 + &:focus {
  22 + outline: none;
  23 + }
  24 +
  25 + &.checked small {
  26 + left: initial;
  27 + right: 0px;
  28 + }
  29 +
  30 + &.blue.checked {
  31 + background: $blue-color;
  32 + border-color: $blue-color;
  33 + }
  34 +
  35 + &.red.checked {
  36 + background: $red-color;
  37 + border-color: $red-color;
  38 + }
  39 +
  40 + %switch-label {
  41 + font-weight: bold;
  42 + }
  43 +
  44 + .on {
  45 + @extend %switch-label;
  46 + }
  47 +
  48 + .off {
  49 + @extend %switch-label;
  50 + right: 2px;
  51 + top: 25%;
  52 + color: $off-text;
  53 + text-align: center;
  54 + }
  55 +}
... ...
src/app/layout/scss/_layout.scss
... ... @@ -34,17 +34,4 @@
34 34 .main-box-body {
35 35 padding: 0 20px 20px 20px;
36 36 }
37   -}
38   -
39   -ul.nav > li.toggler-container {
40   - position: relative;
41   - padding-top: 12px;
42   -}
43   -
44   -.noosfero-main-toolbar {
45   - padding: 5px;
46   - @include make-row();
47   - margin-left: 0px;
48   - margin-right: 0px;
49   - background-color: #edecec;
50   -}
  37 +}
51 38 \ No newline at end of file
... ...
src/app/layout/scss/_mixins.scss
... ... @@ -4,6 +4,12 @@
4 4 background-clip: padding-box; /* stops bg color from leaking outside the border: */
5 5 }
6 6  
  7 +@mixin box-shadow($args...) {
  8 + -webkit-box-shadow: $args;
  9 + -moz-box-shadow: $args;
  10 + box-shadow: $args;
  11 +}
  12 +
7 13 @mixin checkbox-mark($width, $height, $top, $left, $bg, $border, $content: "", $cursor: pointer, $position: absolute) {
8 14 width: $width;
9 15 height: $height;
... ... @@ -48,3 +54,31 @@
48 54 outline-width: $width;
49 55 }
50 56 }
  57 +
  58 +@mixin not-select() {
  59 + -webkit-touch-callout: none; /* iOS Safari */
  60 + -webkit-user-select: none; /* Chrome/Safari/Opera */
  61 + -khtml-user-select: none; /* Konqueror */
  62 + -moz-user-select: none; /* Firefox */
  63 + -ms-user-select: none; /* Internet Explorer/Edge */
  64 + user-select: none; /* Non-prefixed version, currently
  65 + not supported by any browser */
  66 +}
  67 +
  68 +@mixin keyframes($animation-name) {
  69 + @-webkit-keyframes #{$animation-name} {
  70 + @content;
  71 + }
  72 + @-moz-keyframes #{$animation-name} {
  73 + @content;
  74 + }
  75 + @-ms-keyframes #{$animation-name} {
  76 + @content;
  77 + }
  78 + @-o-keyframes #{$animation-name} {
  79 + @content;
  80 + }
  81 + @keyframes #{$animation-name} {
  82 + @content;
  83 + }
  84 +}
... ...
src/app/layout/scss/skins/_whbl.scss
... ... @@ -291,11 +291,7 @@ $whbl-font-color: #16191c;
291 291 background-color: #fff;
292 292 }
293 293  
294   - noosfero-design-toggler .ats-switch .knob i {
295   - color: #999999;
296   - }
297   -
298   - .ats-switch .knob {
  294 + .ats-switch .knob {
299 295 padding-right: 15px;
300 296 }
301 297  
... ...
src/app/layout/services/body-state-classes.service.spec.ts
... ... @@ -193,7 +193,6 @@ describe(&quot;BodyStateClasses Service&quot;, () =&gt; {
193 193  
194 194 service.start();
195 195  
196   - debugger;
197 196 designModeService.setInDesignMode(true);
198 197  
199 198  
... ...
src/app/main/main.component.ts
... ... @@ -116,7 +116,7 @@ export class EnvironmentContent {
116 116 "angular-bind-html-compile", "angularMoment", "angular.filter", "akoenig.deckgrid",
117 117 "angular-timeline", "duScroll", "oitozero.ngSweetAlert",
118 118 "pascalprecht.translate", "tmh.dynamicLocale", "angularLoad",
119   - "angular-click-outside", "toggle-switch", "ngTagCloud", "noosfero.init"]
  119 + "angular-click-outside", "ngTagCloud", "noosfero.init", "uiSwitch"]
120 120 })
121 121 @StateConfig([
122 122 {
... ...
src/app/profile/config-bar.component.ts 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +import {Component, Inject, provide} from "ng-forward";
  2 +import {ProfileService} from "../../lib/ng-noosfero-api/http/profile.service";
  3 +
  4 +@Component({
  5 + selector: "configbar",
  6 + templateUrl: "app/profile/configbar.html",
  7 + providers: [
  8 + provide('profileService', { useClass: ProfileService })
  9 + ]
  10 +})
  11 +@Inject(ProfileService)
  12 +export class ConfigBarComponent {
  13 + profile: noosfero.Profile;
  14 + parentId: number;
  15 +
  16 + constructor(profileService: ProfileService) {
  17 + profileService.getCurrentProfile().then((profile: noosfero.Profile) => {
  18 + this.profile = profile;
  19 + });
  20 + }
  21 +}
... ...
src/app/profile/configbar.html 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +<div id="config-tool" ng-class="{'closed': !showConfig}">
  2 + <a id="config-tool-cog" ng-click="showConfig = !showConfig">
  3 + <i class="fa fa-cog" ng-class="{'anim-icon': showConfig}"></i>
  4 + </a>
  5 +
  6 + <div id="config-tool-options">
  7 + <h4>{{ 'configbar.label' | translate }}</h4>
  8 + <div class="section-title">{{ 'configbar.section.layout' | translate }}</div>
  9 + <ul>
  10 + <li>
  11 + <label class="pull-left">
  12 + <i class="fa fa-th-large"></i>
  13 + <span class="item-label">{{ 'designMode.label' | translate }}</span>
  14 + </label>
  15 + <label class="pull-right">
  16 + <design-toggler></design-toggler>
  17 + </label>
  18 + </li>
  19 + </ul>
  20 + </div>
  21 +</div>
... ...
src/app/profile/configbar.scss 0 → 100644
... ... @@ -0,0 +1,110 @@
  1 +@import "../layout/scss/mixins";
  2 +
  3 +@include keyframes(rotating) {
  4 + from {
  5 + transform: rotate(0deg);
  6 + }
  7 + to {
  8 + transform: rotate(360deg);
  9 + }
  10 +}
  11 +
  12 +/* CONFIG TOOLS */
  13 +#config-tool {
  14 + @include transition(all 0.2s ease-in-out 0s);
  15 + @include box-shadow(0px 1px 4px rgba(0, 0, 0, 0.3));
  16 + position: fixed;
  17 + right: 0;
  18 + top: 120px;
  19 + min-width: 200px;
  20 + z-index: 1000;
  21 +
  22 + #config-tool-cog {
  23 + @include border-radius($border-radius-base 0 0 $border-radius-base);
  24 + @include transition(all 0.1s ease-in-out 0s);
  25 + @include box-shadow(-3px 3px 3px -2px rgba(0, 0, 0, 0.1));
  26 + background: #fff;
  27 + cursor: pointer;
  28 + left: -50px;
  29 + padding: 10px;
  30 + position: absolute;
  31 + text-align: center;
  32 + width: 50px;
  33 + top: 0;
  34 +
  35 + i {
  36 + font-size: 2.2em;
  37 + }
  38 +
  39 + .anim-icon {
  40 + @include animation(rotating 0.7s ease-in-out 0s);
  41 + }
  42 + }
  43 +
  44 + &.closed {
  45 + right: -280px;
  46 + box-shadow: none;
  47 +
  48 + #config-tool-cog {
  49 + &:hover {
  50 + background-color: $primary-color;
  51 + color: #fff;
  52 + }
  53 + }
  54 + }
  55 +
  56 + &.opened {
  57 + right: 0;
  58 + }
  59 +
  60 + .section-title {
  61 + margin: 30px 0 5px;
  62 + font: {
  63 + size: 15px;
  64 + weight: bold;
  65 + }
  66 +
  67 + }
  68 +
  69 + #config-tool-options {
  70 + @include box-shadow(-3px 3px 3px -2px rgba(0, 0, 0, 0.1));
  71 + background: #fff;
  72 + padding: 15px;
  73 +
  74 + h4 {
  75 + margin: 0;
  76 + font-size: 1.3em;
  77 + }
  78 +
  79 + ul {
  80 + list-style: none;
  81 + border-radius: 2px;
  82 + padding: 0;
  83 +
  84 + background: {
  85 + clip: padding-box;
  86 + color: #f1f3f2;
  87 + }
  88 +
  89 + li {
  90 + padding: 10px;
  91 + width: 250px;
  92 + min-height: 50px;
  93 + font: {
  94 + size: 13px;
  95 + weight: 300;
  96 + }
  97 +
  98 + .checkbox {
  99 + margin: 0;
  100 + }
  101 +
  102 + .pull-left {
  103 + margin-top: 8px;
  104 + font-weight: normal;
  105 + }
  106 +
  107 + }
  108 + }
  109 + }
  110 +}
... ...
src/app/profile/profile-toolbar.component.ts
... ... @@ -1,21 +0,0 @@
1   -import {Component, Inject, provide} from "ng-forward";
2   -import {ProfileService} from "../../lib/ng-noosfero-api/http/profile.service";
3   -
4   -@Component({
5   - selector: "profile-toolbar",
6   - templateUrl: "app/profile/toolbar.html",
7   - providers: [
8   - provide('profileService', { useClass: ProfileService })
9   - ]
10   -})
11   -@Inject(ProfileService)
12   -export class ProfileToolbarComponent {
13   - profile: noosfero.Profile;
14   - parentId: number;
15   -
16   - constructor(profileService: ProfileService) {
17   - profileService.getCurrentProfile().then((profile: noosfero.Profile) => {
18   - this.profile = profile;
19   - });
20   - }
21   -}
src/app/profile/profile.component.ts
... ... @@ -10,7 +10,7 @@ import {ProfileService} from &quot;../../lib/ng-noosfero-api/http/profile.service&quot;;
10 10 import {NotificationService} from "../shared/services/notification.service";
11 11 import {MyProfileComponent} from "./myprofile.component";
12 12 import {ProfileActionsComponent} from "./profile-actions.component";
13   -import {ProfileToolbarComponent} from "./profile-toolbar.component";
  13 +import {ConfigBarComponent} from "./config-bar.component";
14 14 /**
15 15 * @ngdoc controller
16 16 * @name profile.Profile
... ... @@ -44,8 +44,8 @@ import {ProfileToolbarComponent} from &quot;./profile-toolbar.component&quot;;
44 44 controllerAs: "vm"
45 45 },
46 46 "toolbar@main": {
47   - templateUrl: "app/profile/toolbar.html",
48   - controller: ProfileToolbarComponent,
  47 + templateUrl: "app/profile/configbar.html",
  48 + controller: ConfigBarComponent,
49 49 controllerAs: "vm"
50 50 }
51 51 }
... ... @@ -61,8 +61,8 @@ import {ProfileToolbarComponent} from &quot;./profile-toolbar.component&quot;;
61 61 controllerAs: "vm"
62 62 },
63 63 "toolbar@main": {
64   - templateUrl: "app/profile/toolbar.html",
65   - controller: ProfileToolbarComponent,
  64 + templateUrl: "app/profile/configbar.html",
  65 + controller: ConfigBarComponent,
66 66 controllerAs: "vm"
67 67 }
68 68 }
... ... @@ -118,8 +118,8 @@ import {ProfileToolbarComponent} from &quot;./profile-toolbar.component&quot;;
118 118 controllerAs: "vm"
119 119 },
120 120 "toolbar@main": {
121   - templateUrl: "app/profile/toolbar.html",
122   - controller: ProfileToolbarComponent,
  121 + templateUrl: "app/profile/configbar.html",
  122 + controller: ConfigBarComponent,
123 123 controllerAs: "vm"
124 124 }
125 125 }
... ...
src/app/profile/toolbar.html
... ... @@ -1,4 +0,0 @@
1   -<div class="noosfero-main-toolbar" permission="vm.profile.permissions" permission-action="allow_edit">
2   - <noosfero-design-toggler class="pull-right"></noosfero-design-toggler>
3   -
4   -</div>
5 0 \ No newline at end of file
src/languages/en.json
... ... @@ -6,6 +6,8 @@
6 6 "navbar.logout": "Log Out",
7 7 "navbar.login": "Login",
8 8 "navbar.toggle_menu": "Toggle navigation",
  9 + "configbar.label": "Configuration",
  10 + "configbar.section.layout": "Layout",
9 11 "language.all": "All languages",
10 12 "language.en": "English",
11 13 "language.pt": "Portuguese",
... ... @@ -77,9 +79,7 @@
77 79 "custom_content.title": "Edit content",
78 80 "profile.custom_header.label": "Header",
79 81 "profile.custom_footer.label": "Footer",
80   - "designMode.label": "In Design",
81   - "designMode.toggle.ON": "ON",
82   - "designMode.toggle.OFF": "OFF",
  82 + "designMode.label": "Design mode",
83 83 "search.results.summary": "{results, plural, one{result} other{# results}}",
84 84 "search.results.query.label": "Search therm:",
85 85 "search.label": "Search",
... ...
src/languages/pt.json
... ... @@ -6,6 +6,8 @@
6 6 "navbar.logout": "Sair",
7 7 "navbar.login": "Login",
8 8 "navbar.toggle_menu": "Abrir Menu",
  9 + "configbar.label": "Configurações",
  10 + "configbar.section.layout": "Visual",
9 11 "language.all": "Todos os idiomas",
10 12 "language.en": "Inglês",
11 13 "language.pt": "Português",
... ... @@ -77,9 +79,7 @@
77 79 "custom_content.title": "Editar conteúdo",
78 80 "profile.custom_header.label": "Cabeçalho",
79 81 "profile.custom_footer.label": "Rodapé",
80   - "designMode.label": "Modo de Edição",
81   - "designMode.toggle.ON": "Ligado",
82   - "designMode.toggle.OFF": "Desligado",
  82 + "designMode.label": "Alterar design",
83 83 "search.results.summary": "{results, plural, one{# resultado} other{# resultados}}",
84 84 "search.results.query.label": "Termo da busca:",
85 85 "search.label": "Pesquisar",
... ...
themes/angular-participa-consulta/app/layout/scss/skins/_yellow.scss
  1 +$yellow-hover: #f5b025;
  2 +$yellow-base: #f9c404;
  3 +
1 4 .skin-yellow {
2 5 @extend %skin-base;
3 6  
... ... @@ -49,7 +52,7 @@
49 52  
50 53 .container-fluid .navbar-header .navbar-toggle {
51 54 &:hover, &:focus {
52   - background-color: #f5b025;
  55 + background-color: $yellow-hover;
53 56 }
54 57 }
55 58  
... ... @@ -61,4 +64,26 @@
61 64 }
62 65 }
63 66  
  67 + #config-tool {
  68 +
  69 + #config-tool-cog {
  70 + color: $yellow-hover;
  71 + }
  72 +
  73 + #config-tool-options {
  74 + h4 {
  75 + color: #2c3e50;
  76 + font-weight: bold;
  77 + }
  78 + }
  79 +
  80 + &.closed {
  81 + #config-tool-cog {
  82 + &:hover {
  83 + background-color: $yellow-hover;
  84 + }
  85 + }
  86 + }
  87 + }
  88 +
64 89 }
... ...