More directive TS
This commit is contained in:
@@ -1,25 +1,4 @@
|
|||||||
/// <reference types="pug" />
|
import { WebDirective } from './../../types';
|
||||||
export class ActionsMenu {
|
export declare class ActionsMenu extends WebDirective {
|
||||||
restrict: string;
|
constructor();
|
||||||
template: import("pug").compileTemplate;
|
|
||||||
replace: boolean;
|
|
||||||
controller: typeof ActionsMenuCtrl;
|
|
||||||
controllerAs: string;
|
|
||||||
bindToController: boolean;
|
|
||||||
scope: {
|
|
||||||
item: string;
|
|
||||||
application: string;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
declare class ActionsMenuCtrl {
|
|
||||||
constructor($timeout: any);
|
|
||||||
state: {
|
|
||||||
extensions: never[];
|
|
||||||
};
|
|
||||||
$onInit(): void;
|
|
||||||
loadExtensions(): Promise<void>;
|
|
||||||
executeAction(action: any, extension: any): Promise<void>;
|
|
||||||
handleActionResult(action: any, result: any): void;
|
|
||||||
subRowsForAction(parentAction: any, extension: any): any;
|
|
||||||
}
|
|
||||||
export {};
|
|
||||||
|
|||||||
@@ -1,30 +1,4 @@
|
|||||||
/// <reference types="pug" />
|
import { WebDirective } from './../../types';
|
||||||
export class ChallengeModal {
|
export declare class ChallengeModal extends WebDirective {
|
||||||
restrict: string;
|
constructor();
|
||||||
template: import("pug").compileTemplate;
|
|
||||||
controller: typeof ChallengeModalCtrl;
|
|
||||||
controllerAs: string;
|
|
||||||
bindToController: {
|
|
||||||
challenge: string;
|
|
||||||
orchestrator: string;
|
|
||||||
application: string;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
declare class ChallengeModalCtrl {
|
|
||||||
constructor($element: any, $timeout: any);
|
|
||||||
$element: any;
|
|
||||||
processingTypes: any[];
|
|
||||||
$onInit(): void;
|
|
||||||
deinit(): void;
|
|
||||||
application: any;
|
|
||||||
orchestrator: any;
|
|
||||||
challenge: any;
|
|
||||||
reloadProcessingStatus(): void;
|
|
||||||
promptForChallenge(challenge: any): "Enter your application passcode" | "Enter your account password";
|
|
||||||
cancel(): void;
|
|
||||||
onTextValueChange(challenge: any): void;
|
|
||||||
validate(): boolean;
|
|
||||||
submit(): Promise<void>;
|
|
||||||
dismiss(): void;
|
|
||||||
}
|
|
||||||
export {};
|
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
/// <reference types="pug" />
|
import { WebApplication } from './../../application';
|
||||||
export class ComponentModalCtrl {
|
import { SNComponent } from 'snjs';
|
||||||
constructor($element: any);
|
import { WebDirective } from './../../types';
|
||||||
$element: any;
|
declare type ComponentModalScope = {
|
||||||
|
component: SNComponent;
|
||||||
|
callback: () => void;
|
||||||
|
onDismiss: (component: SNComponent) => void;
|
||||||
|
application: WebApplication;
|
||||||
|
};
|
||||||
|
export declare class ComponentModalCtrl implements ComponentModalScope {
|
||||||
|
$element: JQLite;
|
||||||
|
component: SNComponent;
|
||||||
|
callback: () => void;
|
||||||
|
onDismiss: (component: SNComponent) => void;
|
||||||
|
application: WebApplication;
|
||||||
|
constructor($element: JQLite);
|
||||||
dismiss(): void;
|
dismiss(): void;
|
||||||
}
|
}
|
||||||
export class ComponentModal {
|
export declare class ComponentModal extends WebDirective {
|
||||||
restrict: string;
|
constructor();
|
||||||
template: import("pug").compileTemplate;
|
|
||||||
controller: typeof ComponentModalCtrl;
|
|
||||||
controllerAs: string;
|
|
||||||
bindToController: boolean;
|
|
||||||
scope: {
|
|
||||||
show: string;
|
|
||||||
component: string;
|
|
||||||
callback: string;
|
|
||||||
onDismiss: string;
|
|
||||||
application: string;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
export {};
|
||||||
|
|||||||
@@ -1,48 +1,4 @@
|
|||||||
/// <reference types="pug" />
|
import { WebDirective } from './../../types';
|
||||||
export class ComponentView {
|
export declare class ComponentView extends WebDirective {
|
||||||
restrict: string;
|
constructor();
|
||||||
template: import("pug").compileTemplate;
|
|
||||||
scope: {
|
|
||||||
component: string;
|
|
||||||
onLoad: string;
|
|
||||||
manualDealloc: string;
|
|
||||||
application: string;
|
|
||||||
};
|
|
||||||
controller: typeof ComponentViewCtrl;
|
|
||||||
controllerAs: string;
|
|
||||||
bindToController: boolean;
|
|
||||||
}
|
}
|
||||||
declare class ComponentViewCtrl {
|
|
||||||
constructor($scope: any, $rootScope: any, $timeout: any);
|
|
||||||
$rootScope: any;
|
|
||||||
$timeout: any;
|
|
||||||
componentValid: boolean;
|
|
||||||
cleanUpOn: any;
|
|
||||||
onVisibilityChange(): void;
|
|
||||||
$onDestroy(): void;
|
|
||||||
unregisterComponentHandler: any;
|
|
||||||
unregisterDesktopObserver: any;
|
|
||||||
component: any;
|
|
||||||
onLoad: any;
|
|
||||||
application: any;
|
|
||||||
$onChanges(): void;
|
|
||||||
didRegisterObservers: boolean | undefined;
|
|
||||||
lastComponentValue: any;
|
|
||||||
registerPackageUpdateObserver(): void;
|
|
||||||
registerComponentHandlers(): void;
|
|
||||||
reloadComponent(): Promise<void>;
|
|
||||||
reloadStatus(doManualReload?: boolean): void;
|
|
||||||
reloading: boolean | undefined;
|
|
||||||
expired: boolean | undefined;
|
|
||||||
loading: boolean | undefined;
|
|
||||||
error: string | null | undefined;
|
|
||||||
handleActivation(): void;
|
|
||||||
loadTimeout: any;
|
|
||||||
handleIframeLoadTimeout(): Promise<void>;
|
|
||||||
issueLoading: boolean | undefined;
|
|
||||||
didAttemptReload: boolean | undefined;
|
|
||||||
handleIframeLoad(iframe: any): Promise<void>;
|
|
||||||
disableActiveTheme(): void;
|
|
||||||
getUrl(): any;
|
|
||||||
}
|
|
||||||
export {};
|
|
||||||
|
|||||||
@@ -12,17 +12,16 @@ export class EditorMenu {
|
|||||||
application: string;
|
application: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
declare class EditorMenuCtrl {
|
declare class EditorMenuCtrl extends PureCtrl {
|
||||||
constructor($timeout: any);
|
constructor($timeout: any);
|
||||||
state: {
|
state: {
|
||||||
isDesktop: any;
|
isDesktop: any;
|
||||||
};
|
};
|
||||||
$onInit(): void;
|
|
||||||
selectComponent(component: any): void;
|
selectComponent(component: any): void;
|
||||||
toggleDefaultForEditor(editor: any): void;
|
toggleDefaultForEditor(editor: any): void;
|
||||||
offlineAvailableForComponent(component: any): any;
|
offlineAvailableForComponent(component: any): any;
|
||||||
makeEditorDefault(component: any): void;
|
makeEditorDefault(component: any): void;
|
||||||
removeEditorDefault(component: any): void;
|
removeEditorDefault(component: any): void;
|
||||||
shouldDisplayRunningLocallyLabel(component: any): boolean;
|
|
||||||
}
|
}
|
||||||
|
import { PureCtrl } from "../../controllers/abstract/pure_ctrl";
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
export { AccountMenu } from "./accountMenu";
|
export { AccountMenu } from './accountMenu';
|
||||||
export { ActionsMenu } from "./actionsMenu";
|
export { ActionsMenu } from './actionsMenu';
|
||||||
export { ChallengeModal } from "./challengeModal";
|
export { ChallengeModal } from './challengeModal';
|
||||||
export { ComponentModal } from "./componentModal";
|
export { ComponentModal } from './componentModal';
|
||||||
export { ComponentView } from "./componentView";
|
export { ComponentView } from './componentView';
|
||||||
export { ConflictResolutionModal } from "./conflictResolutionModal";
|
export { EditorMenu } from './editorMenu';
|
||||||
export { EditorMenu } from "./editorMenu";
|
export { InputModal } from './inputModal';
|
||||||
export { InputModal } from "./inputModal";
|
export { MenuRow } from './menuRow';
|
||||||
export { MenuRow } from "./menuRow";
|
export { PanelResizer } from './panelResizer';
|
||||||
export { PanelResizer } from "./panelResizer";
|
export { PasswordWizard } from './passwordWizard';
|
||||||
export { PasswordWizard } from "./passwordWizard";
|
export { PermissionsModal } from './permissionsModal';
|
||||||
export { PermissionsModal } from "./permissionsModal";
|
export { PrivilegesAuthModal } from './privilegesAuthModal';
|
||||||
export { PrivilegesAuthModal } from "./privilegesAuthModal";
|
export { PrivilegesManagementModal } from './privilegesManagementModal';
|
||||||
export { PrivilegesManagementModal } from "./privilegesManagementModal";
|
export { RevisionPreviewModal } from './revisionPreviewModal';
|
||||||
export { RevisionPreviewModal } from "./revisionPreviewModal";
|
export { SessionHistoryMenu } from './sessionHistoryMenu';
|
||||||
export { SessionHistoryMenu } from "./sessionHistoryMenu";
|
export { SyncResolutionMenu } from './syncResolutionMenu';
|
||||||
export { SyncResolutionMenu } from "./syncResolutionMenu";
|
|
||||||
|
|||||||
@@ -1,23 +1,10 @@
|
|||||||
/// <reference types="pug" />
|
import { WebDirective } from './../../types';
|
||||||
export class InputModal {
|
export interface InputModalScope extends Partial<ng.IScope> {
|
||||||
restrict: string;
|
type: string;
|
||||||
template: import("pug").compileTemplate;
|
title: string;
|
||||||
controller: typeof InputModalCtrl;
|
message: string;
|
||||||
controllerAs: string;
|
callback: (value: string) => void;
|
||||||
bindToController: boolean;
|
|
||||||
scope: {
|
|
||||||
type: string;
|
|
||||||
title: string;
|
|
||||||
message: string;
|
|
||||||
placeholder: string;
|
|
||||||
callback: string;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
declare class InputModalCtrl {
|
export declare class InputModal extends WebDirective {
|
||||||
constructor($element: any);
|
constructor();
|
||||||
$element: any;
|
|
||||||
formData: {};
|
|
||||||
dismiss(): void;
|
|
||||||
submit(): void;
|
|
||||||
}
|
}
|
||||||
export {};
|
|
||||||
|
|||||||
@@ -1,31 +1,4 @@
|
|||||||
/// <reference types="pug" />
|
import { WebDirective } from './../../types';
|
||||||
export class MenuRow {
|
export declare class MenuRow extends WebDirective {
|
||||||
restrict: string;
|
constructor();
|
||||||
transclude: boolean;
|
|
||||||
template: import("pug").compileTemplate;
|
|
||||||
controller: typeof MenuRowCtrl;
|
|
||||||
controllerAs: string;
|
|
||||||
bindToController: boolean;
|
|
||||||
scope: {
|
|
||||||
action: string;
|
|
||||||
buttonAction: string;
|
|
||||||
buttonClass: string;
|
|
||||||
buttonText: string;
|
|
||||||
desc: string;
|
|
||||||
disabled: string;
|
|
||||||
circle: string;
|
|
||||||
circleAlign: string;
|
|
||||||
faded: string;
|
|
||||||
hasButton: string;
|
|
||||||
label: string;
|
|
||||||
spinnerClass: string;
|
|
||||||
stylekitClass: string;
|
|
||||||
subRows: string;
|
|
||||||
subtitle: string;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
declare class MenuRowCtrl {
|
|
||||||
onClick($event: any): void;
|
|
||||||
clickAccessoryButton($event: any): void;
|
|
||||||
}
|
|
||||||
export {};
|
|
||||||
|
|||||||
@@ -1,22 +1,4 @@
|
|||||||
/// <reference types="pug" />
|
import { WebDirective } from './../../types';
|
||||||
export class PermissionsModal {
|
export declare class PermissionsModal extends WebDirective {
|
||||||
restrict: string;
|
constructor();
|
||||||
template: import("pug").compileTemplate;
|
|
||||||
controller: typeof PermissionsModalCtrl;
|
|
||||||
controllerAs: string;
|
|
||||||
bindToController: boolean;
|
|
||||||
scope: {
|
|
||||||
show: string;
|
|
||||||
component: string;
|
|
||||||
permissionsString: string;
|
|
||||||
callback: string;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
declare class PermissionsModalCtrl {
|
|
||||||
constructor($element: any);
|
|
||||||
$element: any;
|
|
||||||
dismiss(): void;
|
|
||||||
accept(): void;
|
|
||||||
deny(): void;
|
|
||||||
}
|
|
||||||
export {};
|
|
||||||
|
|||||||
@@ -1,33 +1,4 @@
|
|||||||
/// <reference types="pug" />
|
import { WebDirective } from './../../types';
|
||||||
export class PrivilegesAuthModal {
|
export declare class PrivilegesAuthModal extends WebDirective {
|
||||||
restrict: string;
|
constructor();
|
||||||
template: import("pug").compileTemplate;
|
|
||||||
controller: typeof PrivilegesAuthModalCtrl;
|
|
||||||
controllerAs: string;
|
|
||||||
bindToController: boolean;
|
|
||||||
scope: {
|
|
||||||
action: string;
|
|
||||||
onSuccess: string;
|
|
||||||
onCancel: string;
|
|
||||||
application: string;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
declare class PrivilegesAuthModalCtrl {
|
|
||||||
constructor($element: any, $timeout: any);
|
|
||||||
$element: any;
|
|
||||||
$timeout: any;
|
|
||||||
$onInit(): void;
|
|
||||||
authParameters: {} | undefined;
|
|
||||||
sessionLengthOptions: any;
|
|
||||||
selectedSessionLength: any;
|
|
||||||
requiredCredentials: any;
|
|
||||||
selectSessionLength(length: any): void;
|
|
||||||
promptForCredential(credential: any): any;
|
|
||||||
cancel(): void;
|
|
||||||
isCredentialInFailureState(credential: any): boolean;
|
|
||||||
validate(): boolean;
|
|
||||||
failedCredentials: any;
|
|
||||||
submit(): Promise<void>;
|
|
||||||
dismiss(): void;
|
|
||||||
}
|
|
||||||
export {};
|
|
||||||
|
|||||||
@@ -1,33 +1,4 @@
|
|||||||
/// <reference types="pug" />
|
import { WebDirective } from './../../types';
|
||||||
export class PrivilegesManagementModal {
|
export declare class PrivilegesManagementModal extends WebDirective {
|
||||||
restrict: string;
|
constructor();
|
||||||
template: import("pug").compileTemplate;
|
|
||||||
controller: typeof PrivilegesManagementModalCtrl;
|
|
||||||
controllerAs: string;
|
|
||||||
bindToController: boolean;
|
|
||||||
scope: {
|
|
||||||
application: string;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
declare class PrivilegesManagementModalCtrl {
|
|
||||||
constructor($timeout: any, $element: any);
|
|
||||||
$element: any;
|
|
||||||
onAppLaunch(): void;
|
|
||||||
hasPasscode: any;
|
|
||||||
hasAccount: boolean | undefined;
|
|
||||||
displayInfoForCredential(credential: any): any;
|
|
||||||
displayInfoForAction(action: any): any;
|
|
||||||
isCredentialRequiredForAction(action: any, credential: any): any;
|
|
||||||
clearSession(): Promise<void>;
|
|
||||||
reloadPrivileges(): Promise<void>;
|
|
||||||
availableActions: any;
|
|
||||||
availableCredentials: any;
|
|
||||||
sessionExpirey: any;
|
|
||||||
sessionExpired: boolean | undefined;
|
|
||||||
credentialDisplayInfo: {} | undefined;
|
|
||||||
privileges: any;
|
|
||||||
checkboxValueChanged(action: any, credential: any): void;
|
|
||||||
cancel(): void;
|
|
||||||
dismiss(): void;
|
|
||||||
}
|
|
||||||
export {};
|
|
||||||
|
|||||||
@@ -1,27 +1,4 @@
|
|||||||
/// <reference types="pug" />
|
import { WebDirective } from './../../types';
|
||||||
export class RevisionPreviewModal {
|
export declare class RevisionPreviewModal extends WebDirective {
|
||||||
restrict: string;
|
constructor();
|
||||||
template: import("pug").compileTemplate;
|
|
||||||
controller: typeof RevisionPreviewModalCtrl;
|
|
||||||
controllerAs: string;
|
|
||||||
bindToController: boolean;
|
|
||||||
scope: {
|
|
||||||
uuid: string;
|
|
||||||
content: string;
|
|
||||||
application: string;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
declare class RevisionPreviewModalCtrl {
|
|
||||||
constructor($element: any, $timeout: any);
|
|
||||||
$element: any;
|
|
||||||
$timeout: any;
|
|
||||||
$onInit(): void;
|
|
||||||
$onDestroy(): void;
|
|
||||||
unregisterComponent: any;
|
|
||||||
configure(): Promise<void>;
|
|
||||||
note: any;
|
|
||||||
editor: any;
|
|
||||||
restore(asCopy: any): void;
|
|
||||||
dismiss(): void;
|
|
||||||
}
|
|
||||||
export {};
|
|
||||||
|
|||||||
@@ -1,29 +1,4 @@
|
|||||||
/// <reference types="pug" />
|
import { WebDirective } from './../../types';
|
||||||
export class SessionHistoryMenu {
|
export declare class SessionHistoryMenu extends WebDirective {
|
||||||
restrict: string;
|
constructor();
|
||||||
template: import("pug").compileTemplate;
|
|
||||||
controller: typeof SessionHistoryMenuCtrl;
|
|
||||||
controllerAs: string;
|
|
||||||
bindToController: boolean;
|
|
||||||
scope: {
|
|
||||||
item: string;
|
|
||||||
application: string;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
declare class SessionHistoryMenuCtrl {
|
|
||||||
constructor($timeout: any);
|
|
||||||
$timeout: any;
|
|
||||||
$onInit(): void;
|
|
||||||
diskEnabled: any;
|
|
||||||
autoOptimize: any;
|
|
||||||
reloadHistory(): void;
|
|
||||||
entries: any;
|
|
||||||
history: any;
|
|
||||||
openRevision(revision: any): void;
|
|
||||||
classForRevision(revision: any): "default" | "success" | "danger" | undefined;
|
|
||||||
clearItemHistory(): void;
|
|
||||||
clearAllHistory(): void;
|
|
||||||
toggleDiskSaving(): void;
|
|
||||||
toggleAutoOptimize(): void;
|
|
||||||
}
|
|
||||||
export {};
|
|
||||||
|
|||||||
@@ -1,22 +1,4 @@
|
|||||||
/// <reference types="pug" />
|
import { WebDirective } from './../../types';
|
||||||
export class SyncResolutionMenu {
|
export declare class SyncResolutionMenu extends WebDirective {
|
||||||
restrict: string;
|
constructor();
|
||||||
template: import("pug").compileTemplate;
|
|
||||||
controller: typeof SyncResolutionMenuCtrl;
|
|
||||||
controllerAs: string;
|
|
||||||
bindToController: boolean;
|
|
||||||
scope: {
|
|
||||||
closeFunction: string;
|
|
||||||
application: string;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
declare class SyncResolutionMenuCtrl {
|
|
||||||
constructor($timeout: any);
|
|
||||||
$timeout: any;
|
|
||||||
status: {};
|
|
||||||
downloadBackup(encrypted: any): void;
|
|
||||||
skipBackup(): void;
|
|
||||||
performSyncResolution(): Promise<void>;
|
|
||||||
close(): void;
|
|
||||||
}
|
|
||||||
export {};
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export declare class WebDirective implements ng.IDirective {
|
|||||||
[boundProperty: string]: string;
|
[boundProperty: string]: string;
|
||||||
};
|
};
|
||||||
template?: string | ((tElement: any, tAttrs: any) => string);
|
template?: string | ((tElement: any, tAttrs: any) => string);
|
||||||
|
transclude?: boolean;
|
||||||
}
|
}
|
||||||
export declare enum PasswordWizardType {
|
export declare enum PasswordWizardType {
|
||||||
ChangePassword = 1,
|
ChangePassword = 1,
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
import { isDesktopApplication } from '@/utils';
|
|
||||||
import template from '%/directives/editor-menu.pug';
|
|
||||||
import { PureCtrl } from '@Controllers/abstract/pure_ctrl';
|
|
||||||
|
|
||||||
class EditorMenuCtrl extends PureCtrl {
|
|
||||||
/* @ngInject */
|
|
||||||
constructor(
|
|
||||||
$timeout,
|
|
||||||
) {
|
|
||||||
super($timeout);
|
|
||||||
this.state = {
|
|
||||||
isDesktop: isDesktopApplication()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
$onInit() {
|
|
||||||
super.$onInit();
|
|
||||||
const editors = this.application.componentManager.componentsForArea('editor-editor')
|
|
||||||
.sort((a, b) => {
|
|
||||||
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
|
|
||||||
});
|
|
||||||
const defaultEditor = editors.filter((e) => e.isDefaultEditor())[0];
|
|
||||||
this.setState({
|
|
||||||
editors: editors,
|
|
||||||
defaultEditor: defaultEditor
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
selectComponent(component) {
|
|
||||||
if(component) {
|
|
||||||
if(component.content.conflict_of) {
|
|
||||||
component.content.conflict_of = null;
|
|
||||||
this.application.saveItem({item: component});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.$timeout(() => {
|
|
||||||
this.callback()(component);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleDefaultForEditor(editor) {
|
|
||||||
if(this.state.defaultEditor === editor) {
|
|
||||||
this.removeEditorDefault(editor);
|
|
||||||
} else {
|
|
||||||
this.makeEditorDefault(editor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
offlineAvailableForComponent(component) {
|
|
||||||
return component.local_url && this.state.isDesktop;
|
|
||||||
}
|
|
||||||
|
|
||||||
makeEditorDefault(component) {
|
|
||||||
const currentDefault = this.application.componentManager
|
|
||||||
.componentsForArea('editor-editor')
|
|
||||||
.filter((e) => e.isDefaultEditor())[0];
|
|
||||||
if(currentDefault) {
|
|
||||||
currentDefault.setAppDataItem('defaultEditor', false);
|
|
||||||
this.application.setItemsNeedsSync({item: currentDefault});
|
|
||||||
}
|
|
||||||
component.setAppDataItem('defaultEditor', true);
|
|
||||||
this.application.saveItem({ item: component });
|
|
||||||
this.setState({
|
|
||||||
defaultEditor: component
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
removeEditorDefault(component) {
|
|
||||||
component.setAppDataItem('defaultEditor', false);
|
|
||||||
this.application.saveItem({ item: component });
|
|
||||||
this.setState({
|
|
||||||
defaultEditor: null
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class EditorMenu {
|
|
||||||
constructor() {
|
|
||||||
this.restrict = 'E';
|
|
||||||
this.template = template;
|
|
||||||
this.controller = EditorMenuCtrl;
|
|
||||||
this.controllerAs = 'self';
|
|
||||||
this.bindToController = true;
|
|
||||||
this.scope = {
|
|
||||||
callback: '&',
|
|
||||||
selectedEditor: '=',
|
|
||||||
currentItem: '=',
|
|
||||||
application: '='
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
116
app/assets/javascripts/directives/views/editorMenu.ts
Normal file
116
app/assets/javascripts/directives/views/editorMenu.ts
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
import { WebDirective } from './../../types';
|
||||||
|
import { WebApplication } from '@/application';
|
||||||
|
import { SNComponent, SNItem, ComponentArea } from 'snjs';
|
||||||
|
import { isDesktopApplication } from '@/utils';
|
||||||
|
import template from '%/directives/editor-menu.pug';
|
||||||
|
import { PureCtrl } from '@Controllers/abstract/pure_ctrl';
|
||||||
|
import { ComponentMutator } from '@/../../../../snjs/dist/@types/models';
|
||||||
|
|
||||||
|
interface EditorMenuScope {
|
||||||
|
callback: (component: SNComponent) => void
|
||||||
|
selectedEditor: SNComponent
|
||||||
|
currentItem: SNItem
|
||||||
|
application: WebApplication
|
||||||
|
}
|
||||||
|
|
||||||
|
class EditorMenuCtrl extends PureCtrl implements EditorMenuScope {
|
||||||
|
|
||||||
|
callback!: (component: SNComponent) => void
|
||||||
|
selectedEditor!: SNComponent
|
||||||
|
currentItem!: SNItem
|
||||||
|
application!: WebApplication
|
||||||
|
|
||||||
|
/* @ngInject */
|
||||||
|
constructor(
|
||||||
|
$timeout: ng.ITimeoutService,
|
||||||
|
) {
|
||||||
|
super($timeout);
|
||||||
|
this.state = {
|
||||||
|
isDesktop: isDesktopApplication()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
$onInit() {
|
||||||
|
super.$onInit();
|
||||||
|
const editors = this.application.componentManager!.componentsForArea(ComponentArea.Editor)
|
||||||
|
.sort((a, b) => {
|
||||||
|
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
|
||||||
|
});
|
||||||
|
const defaultEditor = editors.filter((e) => e.isDefaultEditor())[0];
|
||||||
|
this.setState({
|
||||||
|
editors: editors,
|
||||||
|
defaultEditor: defaultEditor
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
selectComponent(component: SNComponent) {
|
||||||
|
if (component) {
|
||||||
|
if (component.conflictOf) {
|
||||||
|
this.application.changeAndSaveItem(component.uuid, (mutator) => {
|
||||||
|
mutator.conflictOf = undefined;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.$timeout(() => {
|
||||||
|
this.callback(component);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleDefaultForEditor(editor: SNComponent) {
|
||||||
|
if (this.state.defaultEditor === editor) {
|
||||||
|
this.removeEditorDefault(editor);
|
||||||
|
} else {
|
||||||
|
this.makeEditorDefault(editor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
offlineAvailableForComponent(component: SNComponent) {
|
||||||
|
return component.local_url && this.state.isDesktop;
|
||||||
|
}
|
||||||
|
|
||||||
|
makeEditorDefault(component: SNComponent) {
|
||||||
|
const currentDefault = this.application.componentManager!
|
||||||
|
.componentsForArea(ComponentArea.Editor)
|
||||||
|
.filter((e) => e.isDefaultEditor())[0];
|
||||||
|
if (currentDefault) {
|
||||||
|
this.application.changeItem(currentDefault.uuid, (m) => {
|
||||||
|
const mutator = m as ComponentMutator;
|
||||||
|
mutator.defaultEditor = false;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.application.changeAndSaveItem(component.uuid, (m) => {
|
||||||
|
const mutator = m as ComponentMutator;
|
||||||
|
mutator.defaultEditor = true;
|
||||||
|
});
|
||||||
|
this.setState({
|
||||||
|
defaultEditor: component
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
removeEditorDefault(component: SNComponent) {
|
||||||
|
this.application.changeAndSaveItem(component.uuid, (m) => {
|
||||||
|
const mutator = m as ComponentMutator;
|
||||||
|
mutator.defaultEditor = false;
|
||||||
|
});
|
||||||
|
this.setState({
|
||||||
|
defaultEditor: null
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class EditorMenu extends WebDirective {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.restrict = 'E';
|
||||||
|
this.template = template;
|
||||||
|
this.controller = EditorMenuCtrl;
|
||||||
|
this.controllerAs = 'self';
|
||||||
|
this.bindToController = true;
|
||||||
|
this.scope = {
|
||||||
|
callback: '&',
|
||||||
|
selectedEditor: '=',
|
||||||
|
currentItem: '=',
|
||||||
|
application: '='
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,32 +1,83 @@
|
|||||||
|
import { PanelPuppet, WebDirective } from './../../types';
|
||||||
import angular from 'angular';
|
import angular from 'angular';
|
||||||
import template from '%/directives/panel-resizer.pug';
|
import template from '%/directives/panel-resizer.pug';
|
||||||
import { debounce } from '@/utils';
|
import { debounce } from '@/utils';
|
||||||
|
|
||||||
const PanelSides = {
|
enum PanelSide {
|
||||||
Right: 'right',
|
Right = 'right',
|
||||||
Left: 'left'
|
Left = 'left'
|
||||||
};
|
};
|
||||||
const MouseEvents = {
|
enum MouseEventType {
|
||||||
Move: 'mousemove',
|
Move = 'mousemove',
|
||||||
Down: 'mousedown',
|
Down = 'mousedown',
|
||||||
Up: 'mouseup'
|
Up = 'mouseup'
|
||||||
};
|
};
|
||||||
const CssClasses = {
|
enum CssClass {
|
||||||
Hoverable: 'hoverable',
|
Hoverable = 'hoverable',
|
||||||
AlwaysVisible: 'always-visible',
|
AlwaysVisible = 'always-visible',
|
||||||
Dragging: 'dragging',
|
Dragging = 'dragging',
|
||||||
NoSelection: 'no-selection',
|
NoSelection = 'no-selection',
|
||||||
Collapsed: 'collapsed',
|
Collapsed = 'collapsed',
|
||||||
AnimateOpacity: 'animate-opacity',
|
AnimateOpacity = 'animate-opacity',
|
||||||
};
|
};
|
||||||
const WINDOW_EVENT_RESIZE = 'resize';
|
const WINDOW_EVENT_RESIZE = 'resize';
|
||||||
|
|
||||||
class PanelResizerCtrl {
|
type ResizeFinishCallback = (
|
||||||
|
lastWidth: number,
|
||||||
|
lastLeft: number,
|
||||||
|
isMaxWidth: boolean,
|
||||||
|
isCollapsed: boolean
|
||||||
|
) => void
|
||||||
|
|
||||||
|
interface PanelResizerScope {
|
||||||
|
alwaysVisible: boolean
|
||||||
|
collapsable: boolean
|
||||||
|
control: PanelPuppet
|
||||||
|
defaultWidth: number
|
||||||
|
hoverable: boolean
|
||||||
|
index: number
|
||||||
|
minWidth: number
|
||||||
|
onResizeFinish: ResizeFinishCallback
|
||||||
|
panelId: string
|
||||||
|
property: PanelSide
|
||||||
|
}
|
||||||
|
|
||||||
|
class PanelResizerCtrl implements PanelResizerScope {
|
||||||
|
|
||||||
|
/** @scope */
|
||||||
|
alwaysVisible!: boolean
|
||||||
|
collapsable!: boolean
|
||||||
|
control!: PanelPuppet
|
||||||
|
defaultWidth!: number
|
||||||
|
hoverable!: boolean
|
||||||
|
index!: number
|
||||||
|
minWidth!: number
|
||||||
|
onResizeFinish!: ResizeFinishCallback
|
||||||
|
panelId!: string
|
||||||
|
property!: PanelSide
|
||||||
|
|
||||||
|
$compile: ng.ICompileService
|
||||||
|
$element: JQLite
|
||||||
|
$timeout: ng.ITimeoutService
|
||||||
|
panel!: HTMLElement
|
||||||
|
resizerColumn!: HTMLElement
|
||||||
|
currentMinWidth = 0
|
||||||
|
pressed = false
|
||||||
|
startWidth = 0
|
||||||
|
lastDownX = 0
|
||||||
|
collapsed = false
|
||||||
|
lastWidth = 0
|
||||||
|
startLeft = 0
|
||||||
|
lastLeft = 0
|
||||||
|
appFrame?: DOMRect
|
||||||
|
widthBeforeLastDblClick = 0
|
||||||
|
overlay?: JQLite
|
||||||
|
|
||||||
/* @ngInject */
|
/* @ngInject */
|
||||||
constructor(
|
constructor(
|
||||||
$compile,
|
$compile: ng.ICompileService,
|
||||||
$element,
|
$element: JQLite,
|
||||||
$timeout,
|
$timeout: ng.ITimeoutService,
|
||||||
) {
|
) {
|
||||||
this.$compile = $compile;
|
this.$compile = $compile;
|
||||||
this.$element = $element;
|
this.$element = $element;
|
||||||
@@ -44,51 +95,47 @@ class PanelResizerCtrl {
|
|||||||
this.reloadDefaultValues();
|
this.reloadDefaultValues();
|
||||||
this.configureControl();
|
this.configureControl();
|
||||||
this.addDoubleClickHandler();
|
this.addDoubleClickHandler();
|
||||||
this.addMouseDownListener();
|
this.resizerColumn.addEventListener(MouseEventType.Down, this.onMouseDown);
|
||||||
this.addMouseMoveListener();
|
document.addEventListener(MouseEventType.Move, this.onMouseMove);
|
||||||
this.addMouseUpListener();
|
document.addEventListener(MouseEventType.Up, this.onMouseUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
$onDestroy() {
|
$onDestroy() {
|
||||||
this.onResizeFinish = null;
|
(this.onResizeFinish as any) = undefined;
|
||||||
this.control = null;
|
(this.control as any) = undefined;
|
||||||
window.removeEventListener(WINDOW_EVENT_RESIZE, this.handleResize);
|
window.removeEventListener(WINDOW_EVENT_RESIZE, this.handleResize);
|
||||||
document.removeEventListener(MouseEvents.Move, this.onMouseMove);
|
document.removeEventListener(MouseEventType.Move, this.onMouseMove);
|
||||||
document.removeEventListener(MouseEvents.Up, this.onMouseUp);
|
document.removeEventListener(MouseEventType.Up, this.onMouseUp);
|
||||||
this.resizerColumn.removeEventListener(MouseEvents.Down, this.onMouseDown);
|
this.resizerColumn.removeEventListener(MouseEventType.Down, this.onMouseDown);
|
||||||
this.handleResize = null;
|
(this.handleResize as any) = undefined;
|
||||||
this.onMouseMove = null;
|
(this.onMouseMove as any) = undefined;
|
||||||
this.onMouseUp = null;
|
(this.onMouseUp as any) = undefined;
|
||||||
this.onMouseDown = null;
|
(this.onMouseDown as any) = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
configureControl() {
|
configureControl() {
|
||||||
this.control.setWidth = (value) => {
|
this.control.setWidth = (value) => {
|
||||||
this.setWidth(value, true);
|
this.setWidth(value, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.control.setLeft = (value) => {
|
this.control.setLeft = (value) => {
|
||||||
this.setLeft(value);
|
this.setLeft(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.control.flash = () => {
|
this.control.flash = () => {
|
||||||
this.flash();
|
this.flash();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.control.isCollapsed = () => {
|
this.control.isCollapsed = () => {
|
||||||
return this.isCollapsed();
|
return this.isCollapsed();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.control.ready = true;
|
this.control.ready = true;
|
||||||
this.control.onReady();
|
this.control.onReady!();
|
||||||
}
|
}
|
||||||
|
|
||||||
configureDefaults() {
|
configureDefaults() {
|
||||||
this.panel = document.getElementById(this.panelId);
|
this.panel = document.getElementById(this.panelId)!;
|
||||||
if (!this.panel) {
|
if (!this.panel) {
|
||||||
console.error('Panel not found for', this.panelId);
|
console.error('Panel not found for', this.panelId);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.resizerColumn = this.$element[0];
|
this.resizerColumn = this.$element[0];
|
||||||
this.currentMinWidth = this.minWidth || this.resizerColumn.offsetWidth;
|
this.currentMinWidth = this.minWidth || this.resizerColumn.offsetWidth;
|
||||||
this.pressed = false;
|
this.pressed = false;
|
||||||
@@ -98,17 +145,16 @@ class PanelResizerCtrl {
|
|||||||
this.lastWidth = this.startWidth;
|
this.lastWidth = this.startWidth;
|
||||||
this.startLeft = this.panel.offsetLeft;
|
this.startLeft = this.panel.offsetLeft;
|
||||||
this.lastLeft = this.startLeft;
|
this.lastLeft = this.startLeft;
|
||||||
this.appFrame = null;
|
this.appFrame = undefined;
|
||||||
this.widthBeforeLastDblClick = 0;
|
this.widthBeforeLastDblClick = 0;
|
||||||
|
if (this.property === PanelSide.Right) {
|
||||||
if (this.property === PanelSides.Right) {
|
|
||||||
this.configureRightPanel();
|
this.configureRightPanel();
|
||||||
}
|
}
|
||||||
if (this.alwaysVisible) {
|
if (this.alwaysVisible) {
|
||||||
this.resizerColumn.classList.add(CssClasses.AlwaysVisible);
|
this.resizerColumn.classList.add(CssClass.AlwaysVisible);
|
||||||
}
|
}
|
||||||
if (this.hoverable) {
|
if (this.hoverable) {
|
||||||
this.resizerColumn.classList.add(CssClasses.Hoverable);
|
this.resizerColumn.classList.add(CssClass.Hoverable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +163,7 @@ class PanelResizerCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleResize() {
|
handleResize() {
|
||||||
debounce(this, () => {
|
debounce(() => {
|
||||||
this.reloadDefaultValues();
|
this.reloadDefaultValues();
|
||||||
this.handleWidthEvent();
|
this.handleWidthEvent();
|
||||||
this.$timeout(() => {
|
this.$timeout(() => {
|
||||||
@@ -127,7 +173,8 @@ class PanelResizerCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getParentRect() {
|
getParentRect() {
|
||||||
return this.panel.parentNode.getBoundingClientRect();
|
const node = this.panel!.parentNode! as HTMLElement;
|
||||||
|
return node.getBoundingClientRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
reloadDefaultValues() {
|
reloadDefaultValues() {
|
||||||
@@ -135,7 +182,7 @@ class PanelResizerCtrl {
|
|||||||
? this.getParentRect().width
|
? this.getParentRect().width
|
||||||
: this.panel.scrollWidth;
|
: this.panel.scrollWidth;
|
||||||
this.lastWidth = this.startWidth;
|
this.lastWidth = this.startWidth;
|
||||||
this.appFrame = document.getElementById('app').getBoundingClientRect();
|
this.appFrame = document.getElementById('app')!.getBoundingClientRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
addDoubleClickHandler() {
|
addDoubleClickHandler() {
|
||||||
@@ -148,9 +195,7 @@ class PanelResizerCtrl {
|
|||||||
this.widthBeforeLastDblClick = this.lastWidth;
|
this.widthBeforeLastDblClick = this.lastWidth;
|
||||||
this.setWidth(this.currentMinWidth);
|
this.setWidth(this.currentMinWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.finishSettingWidth();
|
this.finishSettingWidth();
|
||||||
|
|
||||||
const newCollapseState = !preClickCollapseState;
|
const newCollapseState = !preClickCollapseState;
|
||||||
this.onResizeFinish(
|
this.onResizeFinish(
|
||||||
this.lastWidth,
|
this.lastWidth,
|
||||||
@@ -162,54 +207,65 @@ class PanelResizerCtrl {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
addMouseDownListener() {
|
onMouseDown(event: MouseEvent) {
|
||||||
this.resizerColumn.addEventListener(MouseEvents.Down, this.onMouseDown);
|
|
||||||
}
|
|
||||||
|
|
||||||
onMouseDown(event) {
|
|
||||||
this.addInvisibleOverlay();
|
this.addInvisibleOverlay();
|
||||||
this.pressed = true;
|
this.pressed = true;
|
||||||
this.lastDownX = event.clientX;
|
this.lastDownX = event.clientX;
|
||||||
this.startWidth = this.panel.scrollWidth;
|
this.startWidth = this.panel.scrollWidth;
|
||||||
this.startLeft = this.panel.offsetLeft;
|
this.startLeft = this.panel.offsetLeft;
|
||||||
this.panel.classList.add(CssClasses.NoSelection);
|
this.panel.classList.add(CssClass.NoSelection);
|
||||||
if (this.hoverable) {
|
if (this.hoverable) {
|
||||||
this.resizerColumn.classList.add(CssClasses.Dragging);
|
this.resizerColumn.classList.add(CssClass.Dragging);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addMouseMoveListener() {
|
onMouseUp() {
|
||||||
document.addEventListener(MouseEvents.Move, this.onMouseMove);
|
this.removeInvisibleOverlay();
|
||||||
|
if (!this.pressed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.pressed = false;
|
||||||
|
this.resizerColumn.classList.remove(CssClass.Dragging);
|
||||||
|
this.panel.classList.remove(CssClass.NoSelection);
|
||||||
|
const isMaxWidth = this.isAtMaxWidth();
|
||||||
|
if (this.onResizeFinish) {
|
||||||
|
this.onResizeFinish(
|
||||||
|
this.lastWidth,
|
||||||
|
this.lastLeft,
|
||||||
|
isMaxWidth,
|
||||||
|
this.isCollapsed()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
this.finishSettingWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
onMouseMove(event) {
|
onMouseMove(event: MouseEvent) {
|
||||||
if (!this.pressed) {
|
if (!this.pressed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (this.property && this.property === PanelSides.Left) {
|
if (this.property && this.property === PanelSide.Left) {
|
||||||
this.handleLeftEvent(event);
|
this.handleLeftEvent(event);
|
||||||
} else {
|
} else {
|
||||||
this.handleWidthEvent(event);
|
this.handleWidthEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleWidthEvent(event) {
|
handleWidthEvent(event?: MouseEvent) {
|
||||||
let x;
|
let x;
|
||||||
if (event) {
|
if (event) {
|
||||||
x = event.clientX;
|
x = event!.clientX;
|
||||||
} else {
|
} else {
|
||||||
/** Coming from resize event */
|
/** Coming from resize event */
|
||||||
x = 0;
|
x = 0;
|
||||||
this.lastDownX = 0;
|
this.lastDownX = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const deltaX = x - this.lastDownX;
|
const deltaX = x - this.lastDownX;
|
||||||
const newWidth = this.startWidth + deltaX;
|
const newWidth = this.startWidth + deltaX;
|
||||||
this.setWidth(newWidth, false);
|
this.setWidth(newWidth, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLeftEvent(event) {
|
handleLeftEvent(event: MouseEvent) {
|
||||||
const panelRect = this.panel.getBoundingClientRect();
|
const panelRect = this.panel.getBoundingClientRect();
|
||||||
const x = event.clientX || panelRect.x;
|
const x = event.clientX || panelRect.x;
|
||||||
let deltaX = x - this.lastDownX;
|
let deltaX = x - this.lastDownX;
|
||||||
@@ -229,34 +285,10 @@ class PanelResizerCtrl {
|
|||||||
if (newLeft + newWidth > parentRect.width) {
|
if (newLeft + newWidth > parentRect.width) {
|
||||||
newLeft = parentRect.width - newWidth;
|
newLeft = parentRect.width - newWidth;
|
||||||
}
|
}
|
||||||
this.setLeft(newLeft, false);
|
this.setLeft(newLeft);
|
||||||
this.setWidth(newWidth, false);
|
this.setWidth(newWidth, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
addMouseUpListener() {
|
|
||||||
document.addEventListener(MouseEvents.Up, this.onMouseUp);
|
|
||||||
}
|
|
||||||
|
|
||||||
onMouseUp() {
|
|
||||||
this.removeInvisibleOverlay();
|
|
||||||
if (!this.pressed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.pressed = false;
|
|
||||||
this.resizerColumn.classList.remove(CssClasses.Dragging);
|
|
||||||
this.panel.classList.remove(CssClasses.NoSelection);
|
|
||||||
const isMaxWidth = this.isAtMaxWidth();
|
|
||||||
if (this.onResizeFinish) {
|
|
||||||
this.onResizeFinish(
|
|
||||||
this.lastWidth,
|
|
||||||
this.lastLeft,
|
|
||||||
isMaxWidth,
|
|
||||||
this.isCollapsed()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
this.finishSettingWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
isAtMaxWidth() {
|
isAtMaxWidth() {
|
||||||
return (
|
return (
|
||||||
Math.round(this.lastWidth + this.lastLeft) ===
|
Math.round(this.lastWidth + this.lastLeft) ===
|
||||||
@@ -268,7 +300,7 @@ class PanelResizerCtrl {
|
|||||||
return this.lastWidth <= this.currentMinWidth;
|
return this.lastWidth <= this.currentMinWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
setWidth(width, finish) {
|
setWidth(width: number, finish = false) {
|
||||||
if (width < this.currentMinWidth) {
|
if (width < this.currentMinWidth) {
|
||||||
width = this.currentMinWidth;
|
width = this.currentMinWidth;
|
||||||
}
|
}
|
||||||
@@ -277,7 +309,7 @@ class PanelResizerCtrl {
|
|||||||
width = parentRect.width;
|
width = parentRect.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
const maxWidth = this.appFrame.width - this.panel.getBoundingClientRect().x;
|
const maxWidth = this.appFrame!.width - this.panel.getBoundingClientRect().x;
|
||||||
if (width > maxWidth) {
|
if (width > maxWidth) {
|
||||||
width = maxWidth;
|
width = maxWidth;
|
||||||
}
|
}
|
||||||
@@ -294,7 +326,7 @@ class PanelResizerCtrl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setLeft(left) {
|
setLeft(left: number) {
|
||||||
this.panel.style.left = left + 'px';
|
this.panel.style.left = left + 'px';
|
||||||
this.lastLeft = left;
|
this.lastLeft = left;
|
||||||
}
|
}
|
||||||
@@ -306,9 +338,9 @@ class PanelResizerCtrl {
|
|||||||
|
|
||||||
this.collapsed = this.isCollapsed();
|
this.collapsed = this.isCollapsed();
|
||||||
if (this.collapsed) {
|
if (this.collapsed) {
|
||||||
this.resizerColumn.classList.add(CssClasses.Collapsed);
|
this.resizerColumn.classList.add(CssClass.Collapsed);
|
||||||
} else {
|
} else {
|
||||||
this.resizerColumn.classList.remove(CssClasses.Collapsed);
|
this.resizerColumn.classList.remove(CssClass.Collapsed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,28 +354,29 @@ class PanelResizerCtrl {
|
|||||||
if (this.overlay) {
|
if (this.overlay) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.overlay = this.$compile(`<div id='resizer-overlay'></div>`)(this);
|
this.overlay = this.$compile(`<div id='resizer-overlay'></div>`)(this as any);
|
||||||
angular.element(document.body).prepend(this.overlay);
|
angular.element(document.body).prepend(this.overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeInvisibleOverlay() {
|
removeInvisibleOverlay() {
|
||||||
if (this.overlay) {
|
if (this.overlay) {
|
||||||
this.overlay.remove();
|
this.overlay.remove();
|
||||||
this.overlay = null;
|
this.overlay = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flash() {
|
flash() {
|
||||||
const FLASH_DURATION = 3000;
|
const FLASH_DURATION = 3000;
|
||||||
this.resizerColumn.classList.add(CssClasses.AnimateOpacity);
|
this.resizerColumn.classList.add(CssClass.AnimateOpacity);
|
||||||
this.$timeout(() => {
|
this.$timeout(() => {
|
||||||
this.resizerColumn.classList.remove(CssClasses.AnimateOpacity);
|
this.resizerColumn.classList.remove(CssClass.AnimateOpacity);
|
||||||
}, FLASH_DURATION);
|
}, FLASH_DURATION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PanelResizer {
|
export class PanelResizer extends WebDirective {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
super();
|
||||||
this.restrict = 'E';
|
this.restrict = 'E';
|
||||||
this.template = template;
|
this.template = template;
|
||||||
this.controller = PanelResizerCtrl;
|
this.controller = PanelResizerCtrl;
|
||||||
@@ -11,10 +11,16 @@
|
|||||||
"declarationDir": "@types",
|
"declarationDir": "@types",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": true,
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
|
"typeRoots": [
|
||||||
|
"node_modules/@types",
|
||||||
|
"node_modules/snjs/dist/@types/index.d.ts"
|
||||||
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
"%/*": ["../templates/*"],
|
"%/*": ["../templates/*"],
|
||||||
"@/*": ["./*"],
|
"@/*": ["./*"],
|
||||||
"@Controllers/*": ["./controllers/*"]
|
"@Controllers/*": ["./controllers/*"]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"include": ["."],
|
||||||
|
"exclude": ["node_modules", "dist", "./@types"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export function dateToLocalizedString(date: Date) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Via https://davidwalsh.name/javascript-debounce-function */
|
/** Via https://davidwalsh.name/javascript-debounce-function */
|
||||||
export function debounce(this: any, func: any, wait: number, immediate: boolean) {
|
export function debounce(this: any, func: any, wait: number, immediate = false) {
|
||||||
let timeout: any;
|
let timeout: any;
|
||||||
return () => {
|
return () => {
|
||||||
const context = this;
|
const context = this;
|
||||||
|
|||||||
@@ -163,7 +163,7 @@
|
|||||||
)
|
)
|
||||||
.sk-label Editor
|
.sk-label Editor
|
||||||
editor-menu(
|
editor-menu(
|
||||||
callback='self.editorMenuOnSelect',
|
callback='self.editorMenuOnSelect()',
|
||||||
current-item='self.state.note',
|
current-item='self.state.note',
|
||||||
ng-if='self.state.showEditorMenu',
|
ng-if='self.state.showEditorMenu',
|
||||||
selected-editor='self.state.selectedEditor',
|
selected-editor='self.state.selectedEditor',
|
||||||
|
|||||||
Reference in New Issue
Block a user