Skip to content

Commit 04b065a

Browse files
committed
Worked on angular&ef project
1 parent c362bdf commit 04b065a

File tree

6 files changed

+102
-7
lines changed

6 files changed

+102
-7
lines changed

SimpleTaskSystemSPA_AngularJs_EntityFramework/SimpleTaskSystem.Web/Abp/Framework/scripts/abp.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
11
var abp = abp || {};
22
(function () {
33

4+
/* Application paths *****************************************/
5+
6+
//Current application root path (including virtual directory if exists).
7+
abp.appPath = abp.appPath || '/';
8+
9+
//Converts given path to absolute path using abp.appPath variable.
10+
abp.toAbsAppPath = function (path) {
11+
if (path.indexOf('/') == 0) {
12+
path = path.substring(1);
13+
}
14+
15+
return abp.appPath + path;
16+
};
17+
418
/* LOCALIZATON ***********************************************/
519
//Implements Localization API that simplifies usage of localization scripts generated by Abp.
620

721
abp.localization = abp.localization || {};
822

23+
abp.localization.defaultSourceName = undefined;
24+
925
abp.localization.localize = function (key, sourceName) {
26+
sourceName = sourceName || abp.localization.defaultSourceName;
27+
1028
var source = abp.localization.values[sourceName];
29+
1130
if (source == undefined) {
1231
abp.log.warn('Could not find localization source: ' + sourceName);
1332
return key;
@@ -248,5 +267,13 @@
248267

249268
return str;
250269
};
270+
271+
function endsWith(str, suffix) {
272+
if (suffix.length > str.length) {
273+
return false;
274+
}
275+
276+
return str.indexOf(suffix, str.length - suffix.length) !== -1;
277+
}
251278

252279
})();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*! http://mths.be/endswith v0.2.0 by @mathias */
2+
if (!String.prototype.endsWith) {
3+
(function () {
4+
'use strict'; // needed to support `apply`/`call` with `undefined`/`null`
5+
var defineProperty = (function () {
6+
// IE 8 only supports `Object.defineProperty` on DOM elements
7+
try {
8+
var object = {};
9+
var $defineProperty = Object.defineProperty;
10+
var result = $defineProperty(object, object, object) && $defineProperty;
11+
} catch (error) { }
12+
return result;
13+
}());
14+
var toString = {}.toString;
15+
var endsWith = function (search) {
16+
if (this == null) {
17+
throw TypeError();
18+
}
19+
var string = String(this);
20+
if (search && toString.call(search) == '[object RegExp]') {
21+
throw TypeError();
22+
}
23+
var stringLength = string.length;
24+
var searchString = String(search);
25+
var searchLength = searchString.length;
26+
var pos = stringLength;
27+
if (arguments.length > 1) {
28+
var position = arguments[1];
29+
if (position !== undefined) {
30+
// `ToInteger`
31+
pos = position ? Number(position) : 0;
32+
if (pos != pos) { // better `isNaN`
33+
pos = 0;
34+
}
35+
}
36+
}
37+
var end = Math.min(Math.max(pos, 0), stringLength);
38+
var start = end - searchLength;
39+
if (start < 0) {
40+
return false;
41+
}
42+
var index = -1;
43+
while (++index < searchLength) {
44+
if (string.charCodeAt(start + index) != searchString.charCodeAt(index)) {
45+
return false;
46+
}
47+
}
48+
return true;
49+
};
50+
if (defineProperty) {
51+
defineProperty(String.prototype, 'endsWith', {
52+
'value': endsWith,
53+
'configurable': true,
54+
'writable': true
55+
});
56+
} else {
57+
String.prototype.endsWith = endsWith;
58+
}
59+
}());
60+
}

SimpleTaskSystemSPA_AngularJs_EntityFramework/SimpleTaskSystem.Web/Abp/Framework/scripts/libs/angular/abp.ng.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
};
1717

1818
return {
19+
20+
'request': function (config) {
21+
if (config.url.endsWith('.cshtml')) {
22+
config.url = abp.appPath + 'AbpAppView/Load?viewUrl=' + config.url;
23+
}
24+
25+
return config;
26+
},
27+
1928
'response': function (response) {
2029
if (!response.config || !response.config.abp || !response.data) {
2130
return response;
@@ -50,6 +59,7 @@
5059

5160
return defer.promise;
5261
}
62+
5363
};
5464
});
5565
}

SimpleTaskSystemSPA_AngularJs_EntityFramework/SimpleTaskSystem.Web/App/Main/app.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
(function () {
22
'use strict';
33

4-
var getViewUrl = function (path) {
5-
return '/AbpAppView/Load?viewUrl=/App/Main/views/' + path + '.cshtml';
6-
};
7-
84
var app = angular.module('app', [
95
'ngAnimate',
106
'ngRoute',
@@ -23,14 +19,14 @@
2319
{
2420
url: '/', //default: /task/new
2521
config: {
26-
templateUrl: getViewUrl('task/list'),
22+
templateUrl: '/App/Main/views/task/list.cshtml',
2723
menuItem: 'TaskList'
2824
}
2925
},
3026
{
3127
url: '/task/new',
3228
config: {
33-
templateUrl: getViewUrl('task/new'),
29+
templateUrl: '/App/Main/views/task/new.cshtml',
3430
menuItem: 'NewTask'
3531
}
3632
}
@@ -44,7 +40,7 @@
4440
$routeProvider.when(r.url, r.config);
4541
});
4642

47-
$routeProvider.otherwise({ redirectTo: '/' });
43+
$routeProvider.otherwise({ redirectTo: abp.appPath });
4844
}
4945

5046
app.run(['$rootScope', '$location', '$routeParams', '$route', function ($rootScope, $location, $routeParams, $route) {

SimpleTaskSystemSPA_AngularJs_EntityFramework/SimpleTaskSystem.Web/SimpleTaskSystem.Web.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@
322322
<Content Include="Scripts\angular-cookies.min.js.map" />
323323
<Content Include="Scripts\angular-animate.min.js.map" />
324324
<Content Include="Scripts\angular.min.js.map" />
325+
<Content Include="Abp\Framework\scripts\abp.polyfills.js" />
325326
<None Include="Scripts\jquery-2.1.1.intellisense.js" />
326327
<Content Include="Scripts\i18n\angular-locale_af-na.js" />
327328
<Content Include="Scripts\i18n\angular-locale_af-za.js" />

SimpleTaskSystemSPA_AngularJs_EntityFramework/SimpleTaskSystem.Web/Views/Shared/_Layout.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
<script src="~/Scripts/bootstrap.min.js"></script>
6767

6868
<!-- Abp framework scripts -->
69+
<script src="~/Abp/Framework/scripts/abp.polyfills.js"></script>
6970
<script src="~/Abp/Framework/scripts/abp.js"></script>
7071
<script src="~/Abp/Framework/scripts/libs/abp.jquery.js"></script>
7172
<script src="~/Abp/Framework/scripts/libs/abp.toastr.js"></script>

0 commit comments

Comments
 (0)