• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript entcore.ng类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中entcore.ng的典型用法代码示例。如果您正苦于以下问题:TypeScript ng类的具体用法?TypeScript ng怎么用?TypeScript ng使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ng类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: http

export let loginController = ng.controller('LoginController', ['$scope', ($scope) => {
	$scope.template = template;
	$scope.template.open('main', 'login-form');
	$scope.user = {};
	$scope.lang = lang;


	$scope.welcome = {

	};

	http().get('/auth/configure/welcome').done(function (d) {
		$scope.welcome.content = d.welcomeMessage;
		if (!d.enabled) {
			$scope.welcome.hideContent = true;
		}
		if (!$scope.$$phase) {
			$scope.$apply();
		}
	})
		.e404(function () {
			$scope.welcome.hideContent = true;
			if (!$scope.$$phase) {
				$scope.$apply();
			}
		});

	$scope.cookieEnabled = navigator.cookieEnabled;
	const safeSplit = (str: string = "", pattern: string = "") => {
		if (typeof str == "string") {
			return str.split(pattern);
		} else {
			return [];
		}
	}
	const checkBrowser = (browser: { browser: string, version: number }) => {
		if (typeof browser == "undefined") {
			console.warn("[Auth][Login.checkBrowser] chould not identify browser NAME: ", browser, navigator.userAgent)
		} else if (typeof browser.version == "undefined") {
			console.warn("[Auth][Login.checkBrowser] chould not identify browser VERSION: ", browser, navigator.userAgent)
		}
	}
	const browser = function (userAgent) {
		if (userAgent.indexOf('Chrome') !== -1) {
			const chromeVersion = safeSplit(userAgent, 'Chrome/')[1];
			const version = parseInt(safeSplit(chromeVersion, '.')[0]);
			return {
				browser: 'Chrome',
				version: version,
				outdated: version < 39
			}
		}
		else if (userAgent.indexOf('IEMobile') !== -1) {
			const ieVersion = safeSplit(userAgent, 'IEMobile/')[1];
			const version = parseInt(safeSplit(ieVersion, ';')[0]);
			return {
				browser: 'MSIE',
				version: version,
				outdated: version < 10
			}
		}
		else if (userAgent.indexOf('AppleWebKit') !== -1 && userAgent.indexOf('Chrome') === -1) {
			const safariVersion = safeSplit(userAgent, 'Version/')[1];
			const version = parseInt(safeSplit(safariVersion, '.')[0]);
			return {
				browser: 'Safari',
				version: version,
				outdated: version < 7
			}
		}
		else if (userAgent.indexOf('Firefox') !== -1) {
			const ffVersion = safeSplit(userAgent, 'Firefox/')[1];
			const version = parseInt(safeSplit(ffVersion, '.')[0]);
			return {
				browser: 'Firefox',
				version: version,
				outdated: version < 34
			}
		}
		else if (userAgent.indexOf('MSIE') !== -1) {
			const msVersion = safeSplit(userAgent, 'MSIE ')[1];
			const version = parseInt(safeSplit(msVersion, ';')[0]);
			return {
				browser: 'MSIE',
				version: version,
				outdated: version < 10
			}
		}
		else if (userAgent.indexOf('MSIE') === -1 && userAgent.indexOf('Trident') !== -1) {
			const msVersion = safeSplit(userAgent, 'rv:')[1];
			const version = parseInt(safeSplit(msVersion, '.')[0]);
			return {
				browser: 'MSIE',
				version: version,
				outdated: version < 10
			}
		}
	};

	$scope.browser = browser(navigator.userAgent);
//.........这里部分代码省略.........
开发者ID:entcore,项目名称:entcore,代码行数:101,代码来源:login.ts


示例2: route

export const accountController = ng.controller('MyAccount', ['$scope', 'route', ($scope, route) => {
	route({
		editUserInfos: async function(params){
			template.open('account/main', 'account/default-view');
			directory.account = new directory.User({ id: params.id, edit: { infos: true } });
			await init();
			$scope.openView('user-edit', 'user');
		},
		editUser: async function(params){
			template.open('account/main', 'account/default-view');
			directory.account = new directory.User({ id: params.id, edit: { userbook: true, infos: true } });
			await init();
			$scope.openView('user-edit', 'user');
			$scope.openView('userbook-edit', 'userbook');
		},
		themes: async function(){
			directory.account = new directory.User({ id: model.me.userId, edit: { userbook: true, visibility: true } });
			template.open('account/main', 'account/themes');
			await init();
		},
		editMe: async function(params){
			template.open('account/main', 'account/default-view');
			directory.account = new directory.User({ id: model.me.userId, edit: { userbook: true, visibility: true } });
			await init();
			lang.addBundle('/auth/i18n', function () {
				$scope.cguUrl = lang.translate("auth.charter");
			});
			if(model.me.type !== 'ELEVE'){
				directory.account.edit.infos = true;
				$scope.openView('user-edit', 'user');
			}
			else {
				$scope.openView('user-view', 'user');
			}
			$scope.openView('userbook-edit', 'userbook');
		}
	});

	$scope.template = template;

	let conf = { overriding: [] };
	const loadThemeConf = async function(){
		await skin.listSkins();
		conf = skin.themeConf;

		$scope.themes = skin.skins;

		if($scope.themes.length > 1){
			$scope.display.pickTheme = skin.pickSkin;
			http().get('/userbook/preference/theme').done(function(pref){
				if(pref.preference){
					$scope.account.themes[pref.preference] = true;
				}
				else{
					$scope.account.themes[skin.skin] = true;
					http().put('/userbook/preference/theme', skin.skin);
				}
				$scope.$apply();
			})
			if(!$scope.account.themes){
				$scope.account.themes = {};
			}
			
			$scope.$apply();
		}
	}
	
	const xhr = new XMLHttpRequest();
	xhr.open('get', '/assets/theme-conf.js');
	xhr.onload = async () => {
		eval(xhr.responseText.split('exports.')[1]);
		const currentTheme = conf.overriding.find(t => t.child === skin.skin);
		if(currentTheme.group){
			$scope.themes = conf.overriding.filter(t => t.group === currentTheme.group);
		}
		else{
			$scope.themes = conf.overriding;
		}
		
	};
	xhr.send();

	Behaviours.loadBehaviours('directory', function(){
		model.me.workflow.load(['directory'])
	});
    model.me.workflow.load(['zimbra']);
	$scope.hasWorkflowZimbraExpert = () => {
       return model.me.hasWorkflow('fr.openent.zimbra.controllers.ZimbraController|preauth');
    };
	async function init(){
		await directory.account.open();
		await directory.account.loadChildren();
		await directory.account.load();
		$scope.me = model.me;
		directory.account.on('change', function(){
			$scope.$apply();
		});

		$scope.account = directory.account;
		$scope.previousMood = directory.account.mood.id;
//.........这里部分代码省略.........
开发者ID:entcore,项目名称:entcore,代码行数:101,代码来源:account.ts


示例3: function

export const teacherDashboardCorrectionStats = ng.directive('teacherDashboardCorrectionStats', ['GrainCopyService', 'GrainScheduledService', 'CorrectionService', 'SubjectCopyService', (GrainCopyService, GrainScheduledService, CorrectionService, SubjectCopyService) => {
        return {
            restrict: 'E',
            scope: {
                selectedSubjectScheduled: "=",

            },
            templateUrl: 'exercizer/public/ts/app/components/dashboard/teacher_dashboard/teacher_dashboard_correction_tab/templates/teacher-dashboard-correction-stats.html',
            link: (scope:any) => {
                scope.$watch('selectedSubjectScheduled.showStats', function(newValue, oldValue) {
                    if(scope.selectedSubjectScheduled && scope.selectedSubjectScheduled.showStats){
                        scope.score = {sum:0, nb:0};
                        scope.numberCopySubmitted = 0;
                        scope.numberCopyNotCorrected = 0;
                        scope.subjectCopyList = SubjectCopyService.getListBySubjectScheduled(scope.selectedSubjectScheduled);
                        scope.subjectCopyList.forEach(copy => {
                            if(copy.is_corrected){
                                scope.score.sum += copy.final_score;
                                scope.score.nb++;
                            }else {
                                scope.numberCopyNotCorrected++;
                            }
                            if(copy.submitted_date){
                                scope.numberCopySubmitted++;
                            }
                        });
                    }
                });

                scope.seeAllAssignAtList = function(){
                    scope.assignDisplayed=true;
                };
            }
        };
    }]
);
开发者ID:OPEN-ENT-NG,项目名称:exercizer,代码行数:36,代码来源:teacherDashboardCorrectionStats.ts


示例4:

import { ng } from 'entcore';

/**
	Wrapper controller
	------------------
	Main controller.
**/
export const mainController = ng.controller('MainController', ['$scope', 'route', ($scope, route) => {
}]);
开发者ID:entcore,项目名称:skeletons,代码行数:9,代码来源:main.ts


示例5: function

export const teacherDashboardFolderEdit = ng.directive('teacherDashboardFolderEdit',
    ['FolderService', (FolderService) => {
        return {
            restrict: 'E',
            scope: {},
            templateUrl: 'exercizer/public/ts/app/components/dashboard/teacher_dashboard/teacher_dashboard_subject_tab/templates/teacher-dashboard-folder-edit.html',
            link: (scope:any) => {

                scope.isDisplayed = false;
                scope.currentFolder = {};

                // event to display model
                scope.$on('E_DISPLAY_DASHBOARD_MODAL_EDIT_FOLDER', function(event, folder) {
                    scope.folder = folder;
                    if(folder){
                        scope.state = 'edit';
                        scope.currentFolder = {};
                        scope.currentFolder.label = angular.copy(folder.label);

                    } else {
                        scope.state = 'create';
                        scope.currentFolder = {};

                    }
                    scope.isDisplayed = true;
                });

                scope.save = function () {
                    if (!scope.currentFolder.label || scope.currentFolder.label.length === 0) {
                        notify.error('exercizer.service.create.folder');
                    } else {
                        
                        if(scope.state === 'create'){
                            var folder = new Folder();
                            folder.label = angular.copy(scope.currentFolder.label);
                            FolderService.persist(folder);
                        } else if(scope.state === 'edit'){
                            scope.folder.label = angular.copy(scope.currentFolder.label);
                            FolderService.update(scope.folder);
                        }
                        
                        scope.hide();
                    }
                };

                // hide model
                scope.hide = function () {
                    scope.isDisplayed = false;
                };
            }
        };
    }]
);
开发者ID:OPEN-ENT-NG,项目名称:exercizer,代码行数:53,代码来源:teacherDashboardFolderEdit.ts


示例6: function

import { ng } from 'entcore';
import { StringISOHelper } from '../../../../models/helpers';

export const performOpenAnswer = ng.directive('performOpenAnswer',
    [() => {
        return {
            restrict: 'E',
            scope: {
                grainCopy: '=',
                grainCopyList: '='
            },
            templateUrl: 'exercizer/public/ts/app/components/grain/open_answer/templates/perform-open-answer.html',
            link:(scope:any, element:any) => {
                scope.updateGrainCopy = function() {
                    scope.$emit('E_UPDATE_GRAIN_COPY', scope.grainCopy);
                };

                /**
                 * Event JQuery because no ng-blur on editor
                 */
                element.find('editor').on('editor-blur', function(){
                    scope.grainCopy.grain_copy_data.custom_copy_data.filled_answer = StringISOHelper.toISO(scope.grainCopy.grain_copy_data.custom_copy_data.filled_answer);
                    scope.$emit('E_UPDATE_GRAIN_COPY', scope.grainCopy);
                });
            }
        };
    }]
);


开发者ID:OPEN-ENT-NG,项目名称:exercizer,代码行数:28,代码来源:performOpenAnswer.ts


示例7: function

import { ng } from 'entcore';
import { IGrainCopy } from '../../../../models/domain';

export const subjectPerformCopyDisplayCurrentGrainCopy = ng.directive('subjectPerformCopyDisplayCurrentGrainCopy',
    [() => {
        return {
            restrict: 'E',
            scope : {
                subjectScheduled : '=',
                previewing: '=',
                grainCopyList: '='
            },
            templateUrl: 'exercizer/public/ts/app/components/subject/subject_perform_copy/templates/subject-perform-copy-display-current-grain-copy.html',
            link:(scope:any) => {
                scope.currentGrainCopy = undefined;

                scope.$on('E_CURRENT_GRAIN_COPY_CHANGE', function(event, grainCopy:IGrainCopy) {
                    scope.currentGrainCopy = grainCopy;
                });
            }
        };
    }]
);

开发者ID:OPEN-ENT-NG,项目名称:exercizer,代码行数:23,代码来源:subjectPerformCopyDisplayCurrentGrainCopy.ts


示例8:

import { ng } from 'entcore';

export const grainCopyStatement = ng.directive('grainCopyStatement',
    ['$sce', ($sce) => {
        return {
            restrict: 'E',
            scope : {
                grainCopy: '='
            },
            templateUrl: 'exercizer/public/ts/app/components/grain/common/grain_copy/templates/grain-copy-statement.html',
            link:(scope:any) => {
            }
        };
    }]
);
开发者ID:OPEN-ENT-NG,项目名称:exercizer,代码行数:15,代码来源:grainCopyStatement.ts


示例9: setTimeout

export const recipientList = ng.directive('recipientList', () => {
    return {
        restrict: 'E',
        template: `
            <div class="twelve flex-row align-center" ng-click="unfoldChip()">
                <contact-chip class="block relative removable" 
                    ng-model="item"
                    action="deleteItem(item)"
                    ng-repeat="item in ngModel | limitTo : (needChipDisplay() ? 2 : ngModel.length)">
                </contact-chip>
                <label class="chip selected" ng-if="needChipDisplay()" ng-click="giveFocus()">
                    <span class="cell">... <i18n>chip.more1</i18n> [[ngModel.length - 2]] <i18n>chip.more2</i18n></span>
                </label>
                <img skin-src="/img/illustrations/loading.gif" width="30px" heigh="30px" ng-if="loading"/>
                <form class="input-help" ng-submit="update(true)">
                    <input class="chip-input right-magnet" type="text" ng-model="search.text" ng-change="update()" autocomplete="off" ng-class="{ move: search.text.length > 0 }" 
                    i18n-placeholder="[[restriction ? 'share.search.help' : 'share.search.placeholder' ]]"
                    />    
                </form>
                <drop-down
                    options="itemsFound"
                    ng-change="addItem()"
                    on-close="clearSearch()"
                    ng-model="currentReceiver">
                </drop-down>
            </div>
        `,

        scope: {
            ngModel: '=',
            ngChange: '&',
            restriction: '=',
            updateFoundItems: '&'
        },

        link: (scope, element, attributes) => {
            var firstFocus = true;
            var minWidth = 0;
            scope.focused = false;
            scope.loading = false;
            scope.search = {
                text: ''
            };
            scope.itemsFound = [];
            scope.currentReceiver = 'undefined';
            scope.addedFavorites = [];

            element.find('input').on('focus', () => {
                if (firstFocus)
                    firstFocus = false;
                scope.focused = true;
                element.find('div').addClass('focus');
                element.find('form').width(minWidth);
            });

            element.find('input').on('blur', () => {
                scope.focused = false;
                element.find('div').removeClass('focus');
                setTimeout(function(){
                    if (!scope.focused) {
                        element.find('form').width(0);
                        scope.itemsFound = [];
                    }
                }, 250);
            });

            element.find('input').on('keydown', function (e) {
                if (e.keyCode === 8 && scope.search.text && scope.search.text.length === 0) { // BackSpace
                    var nb = scope.ngModel.length;
                    if (nb > 0)
                        scope.deleteItem(scope.ngModel[nb - 1]);
                }
            });

            //prevent blur when look for more users in dropDown
            element.parents().find('.display-more').on('click', () => {
                if (!firstFocus) {
                    scope.giveFocus();
                }
            });


            scope.needChipDisplay = () => {
                return !scope.focused && (typeof scope.ngModel !== 'undefined') && scope.ngModel.length > 3;
            };

            scope.update = async (force?: boolean) => {
                scope.addedFavorites = [];
                
                if (force) {
                    await scope.doSearch();
                }
                else {
                    if(scope.restriction && scope.search.text.length < 3 || scope.search.text.length < 1) {
                        scope.itemsFound.splice(0, scope.itemsFound.length);
                    }
                    else {
                        await scope.doSearch();
                    }
                }
//.........这里部分代码省略.........
开发者ID:entcore,项目名称:entcore,代码行数:101,代码来源:recipientList.ts


示例10: constructor

import { IAutomaticCorrection } from '../../../../models/interfaces/IAutomaticCorrection';
import { IGrainCopy, IGrainScheduled } from '../../../../models/domain';
import { CompareStringHelper } from '../../../../models/helpers';
import { ng } from 'entcore';

export class SimpleAnswerService implements IAutomaticCorrection {

    constructor() {}

    public automaticCorrection(grainScheduled:IGrainScheduled, grainCopy:IGrainCopy):{calculated_score:number, answers_result:{}} {

        var isCorrect = CompareStringHelper.compare
        (
            grainScheduled.grain_data.custom_data.correct_answer,
            grainCopy.grain_copy_data.custom_copy_data.filled_answer
        );

        return {
            calculated_score: isCorrect ? grainScheduled.grain_data.max_score : 0,
            answers_result: {
                filled_answer: isCorrect
            }

        };
    }
}

export const simpleAnswerService = ng.service('SimpleAnswerService', SimpleAnswerService);
开发者ID:OPEN-ENT-NG,项目名称:exercizer,代码行数:28,代码来源:SimpleAnswerService.ts



注:本文中的entcore.ng类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript entcore.ng.controllers类代码示例发布时间:2022-05-25
下一篇:
TypeScript entcore.model.me类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap