当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ng.directive方法代码示例

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


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

示例1: hide

export const teacherDashboardToaster = ng.directive('teacherDashboardToaster', ['FolderService','SubjectService', (FolderService,SubjectService) => {
        return {
            restrict: 'E',
            scope : {},
            controller: function($scope) {
                $scope.isDisplayed = false;
            },
            templateUrl: 'exercizer/public/ts/app/components/dashboard/teacher_dashboard/teacher_dashboard_subject_tab/templates/teacher-dashboard-toaster.html',
            compile: function(element, attributes){
                return {
                    pre: function(scope, element, attributes, controller, transcludeFn){
                    },
                    post: function(scope, element, attributes, controller, transcludeFn){
                        scope.subjectList = [];
                        scope.folderList = [];
                        scope.lowerRight = null;

                        function hide(){
                            scope.isDisplayed = false;
                        }
                        hide();

                        scope.$on('E_DISPLAY_DASHBOARD_TOASTER', function (event, subjectList, folderList) {
                            var length = subjectList.length + folderList.length;
                            if (length === 0 || (subjectList.length > 0 && folderList.length > 0)) {
                                hide();
                            } else{
                                scope.isDisplayed = true;
                                scope.subjectList = subjectList;
                                scope.folderList = folderList;
                                checkRightFn(subjectList);
                            }
                        });

                        function checkRightFn(subjectList){
                            var isOneRead = false;
                            var isOneManage = false;
                            var isOneContrib = false;
                            var isOneOwner = false;

                            angular.forEach(subjectList, function(id){
                                var subject = SubjectService.getById(id);
                                if(model.me.hasRight(subject, 'owner')){
                                    //scope.lowerRight = 'owner';
                                    isOneOwner = true
                                }
                                else if(model.me.hasRight(subject, Behaviours.applicationsBehaviours.exercizer.rights.resource.manager)){
                                    //scope.lowerRight = 'manager';
                                    isOneManage = true;
                                }
                                else if(model.me.hasRight(subject, Behaviours.applicationsBehaviours.exercizer.rights.resource.contrib)){
                                    //scope.lowerRight = 'contrib';
                                    isOneContrib = true;
                                }
                                else{
                                    //scope.lowerRight = 'read';
                                    isOneRead = true;
                                }
                            });

                            if (isOneRead) {
                                scope.lowerRight = 'read';
                            } else if (isOneContrib) {
                                scope.lowerRight = 'contrib';
                            } else if (isOneManage) {
                                scope.lowerRight = 'manager';
                            } else if (isOneOwner) {
                                scope.lowerRight = 'owner';
                            }
                        }

                        scope.itemList = [
                            {
                                publicName : idiom.translate('exercizer.instructer.toaster.property'),
                                actionOnClick : function(){
                                    if(scope.folderList.length == 1){
                                        // folder is selected
                                        var folder = FolderService.folderById(scope.folderList[0]);
                                        scope.$emit('E_EDIT_FOLDER', folder);

                                    }
                                    if(scope.subjectList.length == 1){
                                        // subject is selected
                                        var subject = SubjectService.getById(scope.subjectList[0]);
                                        scope.$emit('E_EDIT_SUBJECT', subject);
                                    }
                                },
                                display : function(){
                                    if(scope.folderList.length + scope.subjectList.length == 1){
                                        // only one item
                                        if(scope.subjectList.length == 1){
                                            // is subject
                                            var subject = SubjectService.getById(scope.subjectList[0]);
                                            return (scope.lowerRight == 'owner' || scope.lowerRight == 'manager') && subject && subject.type === 'interactive';
                                        } else {
                                            //is folder
                                            return true;
                                        }
                                    } else{
                                        return false;
//.........这里部分代码省略.........
开发者ID:OPEN-ENT-NG,项目名称:exercizer,代码行数:101,代码来源:teacherDashboardToaster.ts

示例2: 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

示例3: function

export const studentDashboardSubjectCopyList = ng.directive('studentDashboardSubjectCopyList',
    ['DateService', 'SubjectCopyService', 'SubjectScheduledService', '$location',
        (DateService, SubjectCopyService, SubjectScheduledService, $location) => {
            return {
                restrict: 'E',
                scope: {},
                templateUrl: 'exercizer/public/ts/app/components/dashboard/student_dashboard/student_dashboard_subject_copy_list/templates/student-dashboard-subject-copy-list.html',
                link: (scope:any) => {

                    // Get data
                    scope.subjectCopyList = [];
                    SubjectCopyService.resolve(false).then(
                        function () {
                            scope.subjectCopyList = SubjectCopyService.getList();
                        }
                    );
                    SubjectScheduledService.resolve(false).then(
                        function(){
                        }
                    );

                    // Date
                    scope.today = new Date();
                    scope.dateInAWeek = moment().startOf('week').add(1, 'week').toDate();
                    scope.dateInAYears = moment().add(1, 'year').toDate();

                    // Search
                    if (!scope.search) {
                        scope.search = {
                            beginDate: moment().startOf('week').add(1, 'week').toDate(),
                            endDate: moment().add(3, 'month').toDate()
                        }
                    }
                }
            }
        }
    ]
);
开发者ID:OPEN-ENT-NG,项目名称:exercizer,代码行数:38,代码来源:studentDashBoardSubjectCopyList.ts

示例4: 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

示例5: 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

示例6: function

export const dashboardArchives = ng.directive('dashboardArchives', [ '$location', '$window', 'DateService', 'ArchivesService', 'SubjectCopyService', ($location, $window, DateService, ArchivesService, SubjectCopyService) => {
        return {
            restrict: 'E',
            scope: {
                selectedSubjectScheduled : "=",
                subjectScheduledList : "="
            },
            templateUrl: 'exercizer/public/ts/app/components/dashboard/teacher_dashboard/teacher_dashboard_archive/templates/dashboard-archives.html',
            link: (scope:any) => {

                scope.search = {
                    groupList: [],
                    beginDate: moment().subtract(3, 'month').toDate(),
                    endDate: moment().add(3, 'month').toDate(),
                };


                scope.selectedSubjectsScheduled=[];



                scope.getSubjectScheduledPicture = function (subjectScheduled) {
                    return subjectScheduled.picture || skin.basePath + 'img/illustrations/image-default.svg';
                };


                scope.filterOnSubjectScheduledDueDate = function (begin, end) {
                    return function (subjectScheduled) {
                        var dueDate = DateService.isoToDate(subjectScheduled.due_date);
                        if (!begin || !end) {
                            throw "begin or end date in params missing"
                        }
                        return DateService.compare_after(dueDate, begin, true) && DateService.compare_after(end, dueDate, true);
                    }
                };

                scope.orderByCopyListModificationDate = function(id){
                    var copyList = ArchivesService.getSubjectScheduledCopyById(id);
                    var lastUpdateCopy:any = null;
                    angular.forEach(copyList, function(copy){
                        if(lastUpdateCopy){
                            if(DateService.compare_after(DateService.isoToDate(copy.modified), DateService.isoToDate(lastUpdateCopy))){
                                lastUpdateCopy = copy;
                            }
                        } else{
                            lastUpdateCopy = copy;
                        }
                    });
                    if(lastUpdateCopy != null && lastUpdateCopy.modified != null){
                        return lastUpdateCopy.modified;
                    }
                }


                scope.selectsubjectScheduled = function(subjectScheduled){
                    if(subjectScheduled.selected){
                        scope.selectedSubjectsScheduled.push(subjectScheduled);
                    }else{
                        scope.selectedSubjectsScheduled.pop(subjectScheduled);
                    }

                }
                scope.clickOnSubjectScheduled = function(subjectScheduled){
                    scope.selectedSubjectScheduled = subjectScheduled;
                    $location.path('/dashboard/teacher/archive/'+subjectScheduled.id);
                };

                scope.exportAll = function(){
                    exportCSV(scope.subjectScheduledList);
                };

                scope.exportSelected = function(){
                    exportCSV(scope.selectedSubjectsScheduled);
                }

                function exportCSV(subjects:ISubjectScheduled[]) {
                    var ids:string = "?"
                    subjects.forEach((subject) =>{
                        ids = ids.concat("id="+subject.id+"&");
                    } );
                    window.location.href = '/exercizer/archive/subjects-scheduled/export-csv' + ids.slice(0,-1);
                }
            }
        };
    }]
);
开发者ID:OPEN-ENT-NG,项目名称:exercizer,代码行数:86,代码来源:dashboardArchives.ts

示例7:

import { ng } from 'entcore';

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

示例8: function

export let gridResizable = ng.directive('gridResizable', function($compile){
	return {
		restrict: 'A',
		link: function(scope, element, attributes){
			$('body').css({
				'-webkit-user-select': 'none',
				'-moz-user-select': 'none',
				'user-select' : 'none'
			});

			let cellSizes = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve'];
			let parent = element.parents('.drawing-grid');

			element.addClass('grid-media');

            let lock: Directions = {};
            let resizeLimits: { horizontal: boolean, vertical: boolean };

			//cursor styles to indicate resizing possibilities
			element.on('mouseover', (e) => {
				element.on('mousemove.gridresize', (e) => {
					if(element.data('resizing') || element.data('lock')){
						return;
					}

					lock.vertical = (element.find('grid-cell, [vertical-lock]').length > 0);
					lock.horizontal = (element.find('grid-cell, [horizontal-lock]').length > 0) || 
						element.index() == element.parent().children('grid-cell').length - 1;

					let mouse = { x: e.pageX, y: e.pageY };
					resizeLimits = {
						horizontal:  element.offset().left + element.width() + 5 > mouse.x && mouse.x > element.offset().left + element.width() - 15 && !lock.horizontal,
						vertical: (element.offset().top + (element.height() + parseInt(element.css('padding-bottom'))) +
							5 > mouse.y && mouse.y > element.offset().top + (element.height() + parseInt(element.css('padding-bottom'))) - 15) && !lock.vertical
					};

					let orientations = {
						'ns': resizeLimits.vertical,
						'ew': resizeLimits.horizontal,
						'nwse': resizeLimits.vertical && resizeLimits.horizontal
					};

					let cursor = '';
					for(let orientation in orientations){
						if(orientations[orientation]){
							cursor = orientation;
						}
					}

					if(cursor){
						cursor = cursor + '-resize';
					}
					if(cursor !== element.css('cursor')){
						removeCursorEffect(element);
						if(cursor){
							element.addClass(cursor + '-over');
						}
						
						element.css({ cursor: cursor });
						element.children('*').css({ cursor: cursor })
					}
					
				});
				element.on('mouseout', (e) => {
					removeCursorEffect(element);
					element.removeClass(element.css('cursor'));
					element.off('mousemove');
				});
			});

			//actual resize
            element.on('mousedown.resize', (e) => {
                if (element.data('lock') === true || element.data('resizing') === true || (!resizeLimits.vertical && !resizeLimits.horizontal)) {
					return;
				}
				element.find('editor').css({ 'pointer-events': 'none' });
				element.addClass(element.css('cursor'));
				let mouse = { y: e.pageY, x: e.pageX };

				resizeLimits = {
					horizontal:  element.offset().left + element.width() + 5 > mouse.x && mouse.x > element.offset().left + element.width() - 15,
					vertical: (element.offset().top + (element.height() + parseInt(element.css('padding-bottom'))) +
						5 > mouse.y && mouse.y > element.offset().top + (element.height() + parseInt(element.css('padding-bottom'))) - 15) && !lock.vertical
				};

				let cellWidth = Math.ceil(element.parent().width() / 12) + 4;
				let cells = element.parent().children('grid-cell');
				let interrupt = false;
				let parentData = {
					pos: element.parents('.grid-row').offset(),
					size: {
						width: element.parents('.grid-row').width(),
						height: element.parents('.grid-row').height()
					}
				};

				if(resizeLimits.horizontal || resizeLimits.vertical){
					cells.data('lock', true);
				}

//.........这里部分代码省略.........
开发者ID:web-education,项目名称:pages,代码行数:101,代码来源:grid-resizable.ts

示例9: function

export const stats = ng.directive('stats', ['GrainCopyService', 'GrainScheduledService', 'CorrectionService', (GrainCopyService, GrainScheduledService, CorrectionService) => {
    return {
        restrict: 'E',
        scope: {
            subjectCopyList: "=",
            subjectScheduled: "=",
            filterOwner: "="
            
        },
        templateUrl: 'exercizer/public/ts/app/components/dashboard/teacher_dashboard/common/templates/stats.html',
        link: (scope:any) => {
            scope.$watch('subjectCopyList', function(newValue, oldValue) {
                if(scope.subjectCopyList){
                    GrainScheduledService.getListBySubjectScheduled(scope.subjectScheduled).then(scheduledGrains => {
                        scope.scheduledGrains= scheduledGrains;
                        scope.filtredScheduledGrains =scope.scheduledGrains.filter(grain => grain.grain_type_id > 3)
                        scope.canUpIndex =  scope.filtredScheduledGrains.length > 6;
                    });
                    scope.matrice = {};
                    scope.index = 0;
                    scope.scores = {auto:{sum:0, nb:0}, final:{sum:0, nb:0}};
                    scope.submittedCopies = scope.subjectCopyList.filter( copy => copy.submitted_date != null);
                    if(scope.submittedCopies && scope.submittedCopies.length > 0)
                    GrainCopyService.getListBySubjectCopies(scope.submittedCopies).then(listMapped => {
                        scope.listMapped = listMapped;
                        scope.submittedCopies.forEach(copy => {
                            if(copy.calculated_score != null) {
                                scope.scores.auto.sum += copy.calculated_score;
                                scope.scores.auto.nb++;
                            }
                            if(copy.final_score != null) {
                                scope.scores.final.sum += copy.final_score;
                                scope.scores.final.nb++;
                            }


                            scope.matrice[copy.id] = {};
                            if(!copy.is_correction_on_going)
                                CorrectionService.grainsCorrection(scope.listMapped[copy.id], scope.scheduledGrains);
                            scope.listMapped[copy.id].forEach(grain => {
                                if(grain.final_score != null && grain.final_score != grain.calculated_score){
                                    grain.score = grain.final_score;
                                    grain.changed = true;
                                }else{
                                    grain.score = grain.calculated_score;
                                }
                                if(grain.score != null) {
                                    if(!scope.scores[grain.grain_scheduled_id])
                                        scope.scores[grain.grain_scheduled_id] = {sum:0, nb:0};
                                    scope.scores[grain.grain_scheduled_id].sum += grain.score;
                                    scope.scores[grain.grain_scheduled_id].nb++;
                                }
                                scope.matrice[copy.id][grain.grain_scheduled_id] = grain;
                            })
                        })
                    });
                    console.log(scope.matrice);
                }
            });

            scope.translate = idiom.translate;

            scope.getScore = function (grainId) {
                if(scope.scores[grainId] && scope.scores[grainId].nb > 0)
                    return scope.scores[grainId].sum/scope.scores[grainId].nb;
            }

            scope.hoverIndex = function(indx){
                scope.hoverIndex = indx;
            }

            var n = 0;
            $('#infos').on('scroll', function () {
                if(n == 0) {
                    $('#scores').scrollTop($(this).scrollTop());
                    n++;
                }else
                    n--;
            });


            scope.test = function () {
                console.log("test")
            }

            $('#scores').on('scroll', function () {
                if(n == 0) {
                    $('#infos').scrollTop($(this).scrollTop());
                    n++;
                }else
                    n--;
            });

            scope.upIndex = function(){
                var diff = scope.filtredScheduledGrains.length-6-scope.index;
                if(5 < diff)
                    scope.index+=6;
                else {
                    scope.index += diff;
                    scope.canUpIndex = false;
//.........这里部分代码省略.........
开发者ID:OPEN-ENT-NG,项目名称:exercizer,代码行数:101,代码来源:stats.ts

示例10: function

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

                scope.isDisplayed = false;
                scope.data = {
                    selectedFolder : null
                };
                scope.translate = idiom.translate;
                scope.allFolderList = FolderService.folderList;

                // event to display model
                scope.$on('E_DISPLAY_DASHBOARD_MODAL_MOVE', function(event, selectedSubjectList, selectedFolderList) {
                    scope.isDisplayed = true;
                    scope.allFolderList = FolderService.folderList;
                    scope.subjectList = selectedSubjectList;
                    scope.folderList = selectedFolderList;
                });

                // confirm move
                scope. moveSelection = function () {
                    var folder = null;
                    if (scope.data.selectedFolder) {
                        folder = FolderService.folderById(scope.data.selectedFolder);
                    }
                    scope.$emit('E_CONFIRM_MOVE', folder);
                    scope.isDisplayed = false;
                    scope.list = null;
                };

                // hide model
                scope.hide = function () {
                    scope.isDisplayed = false;
                    scope.list = null;
                    scope.$emit('E_RESET_SELECTED_LIST');
                };

                // get label of folder
                scope.getFolderLabelById = function(id) {
                    var folder = FolderService.folderById(id);
                    return folder? folder.label : null;
                };

                // get title of subject
                scope.getSubjectTitleById = function(id) {
                    var subject = SubjectService.getById(id);
                    return subject ? subject.title : null;
                };
            }
        };
    }]
);
开发者ID:OPEN-ENT-NG,项目名称:exercizer,代码行数:56,代码来源:teacherDashboardMove.ts


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