Skip to content

Commit d183273

Browse files
committed
jquery load demo
1 parent 43561dd commit d183273

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

demo/jquery/jquery.html

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>jQuery</title>
6+
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
7+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.8/angular.js"></script>
8+
<script src="../../dist/ui-scroll.js"></script>
9+
<script src="jquery.js"></script>
10+
<link rel="stylesheet" href="../css/style.css" type="text/css"/>
11+
</head>
12+
<body ng-controller="mainController" ng-app="application">
13+
14+
<div class="cont cont-global">
15+
16+
<a class="back" href="../index.html">browse other examples</a>
17+
18+
<h1 class="page-header page-header-exapmle">jQuery</h1>
19+
20+
<div class="description">
21+
In case the Angular App works with jQuery, the ui-scroll should use jQuery.
22+
Otherwise, the ui-scroll should use jqLiteExtras.
23+
</div>
24+
25+
<div class="actions">
26+
<span ng-if="jqueryVersion">jQuery version is {{jqueryVersion}}</span>
27+
<span ng-if="!jqueryVersion">jQuery is not loaded</span>
28+
</div>
29+
30+
<div class="viewport" id="viewport-serviceDatasource" ui-scroll-viewport>
31+
<div class="item" ui-scroll="item in datasource" adapter="adapter">{{item}}</div>
32+
</div>
33+
34+
</div>
35+
36+
</body>
37+
</html>

demo/jquery/jquery.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
angular.module('application', ['ui.scroll'])
2+
.controller('mainController', [
3+
'$scope', '$log', '$timeout', function ($scope, console, $timeout) {
4+
var datasource = {};
5+
6+
datasource.get = function (index, count, success) {
7+
$timeout(function () {
8+
var result = [];
9+
for (var i = index; i <= index + count - 1; i++) {
10+
result.push("item #" + i);
11+
}
12+
success(result);
13+
}, 100);
14+
};
15+
16+
$scope.datasource = datasource;
17+
18+
$scope.jqueryVersion = window.jQuery && angular.element.fn && angular.element.fn.jquery;
19+
20+
}
21+
]);

src/ui-scroll.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ angular.module('ui.scroll', [])
88

99
.constant('JQLiteExtras', JQLiteExtras)
1010
.run(['JQLiteExtras', (JQLiteExtras) => {
11-
!(angular.element.fn && angular.element.fn.jquery) ? new JQLiteExtras().registerFor(angular.element) : null;
11+
const elt = angular.element;
12+
!(window.jQuery && elt.fn && elt.fn.jquery) ? (new JQLiteExtras()).registerFor(elt) : null;
1213
ElementRoutines.addCSSRules();
1314
}])
1415

0 commit comments

Comments
 (0)