xenia/debugger/src/directives.js

90 lines
2.3 KiB
JavaScript
Raw Normal View History

/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
'use strict';
2013-12-25 06:08:44 +00:00
var module = angular.module('xe.directives', [
'ui.router'
]);
module.directive('uiEnter', function() {
return function($scope, element, attrs) {
2013-12-24 04:03:03 +00:00
element.bind('keydown keypress', function(e) {
if(e.which === 13) {
$scope.$apply(function(){
$scope.$eval(attrs.uiEnter);
});
e.preventDefault();
}
});
};
});
2013-12-22 10:59:42 +00:00
module.directive('uiEscape', function() {
return function($scope, element, attrs) {
2013-12-24 04:03:03 +00:00
element.bind('keydown keypress', function(e) {
2013-12-22 10:59:42 +00:00
if(e.which === 27) {
$scope.$apply(function(){
$scope.$eval(attrs.uiEscape);
});
e.preventDefault();
}
});
};
});
2013-12-24 04:03:03 +00:00
module.directive('uiScrollDownOn', function() {
return {
priority: 1,
link: function($scope, element, attrs) {
$scope.$watch(attrs.uiScrollDownOn, function() {
element[0].scrollTop = element[0].scrollHeight;
});
}
};
});
2013-12-25 06:08:44 +00:00
module.directive('xeCoderef', function($state) {
return {
priority: 1,
link: function($scope, element, attrs) {
var target = attrs.xeCoderef;
var stateName = 'session.code.function';
var stateParams = {
function: target,
a: null
};
element.attr('href', $state.href(stateName, stateParams));
element.bind('click', function(e) {
e.preventDefault();
$state.go(stateName, stateParams);
});
}
};
});
module.directive('xeMemref', function($state) {
return {
priority: 1,
link: function($scope, element, attrs) {
var target = attrs.xeMemref;
var stateName = 'session.memory';
var stateParams = {
a: target
};
element.attr('href', $state.href(stateName, stateParams));
element.bind('click', function(e) {
e.preventDefault();
$state.go(stateName, stateParams);
});
}
};
});