mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Added bootstrap and angularjs
This commit is contained in:
30
frontend/app/js/app.js
Normal file
30
frontend/app/js/app.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
function ctrl($scope){
|
||||||
|
$scope.rows = ['Paul','John','Lucie'];
|
||||||
|
$scope.temp = false;
|
||||||
|
|
||||||
|
$scope.addRow = function(){
|
||||||
|
$scope.temp = false;
|
||||||
|
$scope.addName="";
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.deleteRow = function(row){
|
||||||
|
$scope.rows.splice($scope.rows.indexOf(row),1);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.plural = function (tab){
|
||||||
|
return tab.length > 1 ? 's': '';
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.addTemp = function(){
|
||||||
|
if($scope.temp) $scope.rows.pop();
|
||||||
|
else if($scope.addName) $scope.temp = true;
|
||||||
|
|
||||||
|
if($scope.addName) $scope.rows.push($scope.addName);
|
||||||
|
else $scope.temp = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.isTemp = function(i){
|
||||||
|
return i==$scope.rows.length-1 && $scope.temp;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
window.helloText = function() {
|
|
||||||
return 'Hello, World!';
|
|
||||||
};
|
|
||||||
|
|
||||||
window.hello = function() {
|
|
||||||
html = JST['app/templates/hello.us']({text: helloText()});
|
|
||||||
document.body.innerHTML += html;
|
|
||||||
};
|
|
||||||
|
|
||||||
if(window.addEventListener) {
|
|
||||||
window.addEventListener('DOMContentLoaded', hello, false);
|
|
||||||
} else {
|
|
||||||
window.attachEvent('onload', hello);
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,36 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html ng-app>
|
||||||
<head>
|
<head>
|
||||||
<title><%= pkg.name %></title>
|
<link rel="stylesheet" type="text/css" href="<%= css %>" media="all" />
|
||||||
|
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.5/angular.min.js"></script>
|
||||||
|
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.2/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
|
||||||
|
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
|
||||||
|
<meta charset=utf-8 />
|
||||||
|
<title>Angular JS Demo</title>
|
||||||
|
</head>
|
||||||
|
<body ng-controller="ctrl">
|
||||||
|
<h2>{{rows.length}} Friend{{plural(rows)}} <span ng-show="temp">?<small class="muted"><em > (only {{rows.length-1}} actually....)</em></small></span></h2>
|
||||||
|
<form class="form-horizontal">
|
||||||
|
<span ng-class="{'input-append':addName}">
|
||||||
|
<input id="add" type="text" placeholder="Another one ?" ng-model="addName" ng-change="addTemp()"/>
|
||||||
|
<input type="submit" class="btn btn-primary" ng-click="addRow()" ng-show="addName" value="+ add"/>
|
||||||
|
</span>
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="<%= css %>" media="all" />
|
<span class="search input-prepend" ng-class="{'input-append':search}">
|
||||||
</head>
|
<span class="add-on"><i class="icon-search"></i></span>
|
||||||
<body>
|
<input type="text" class="span2" placeholder="Search" ng-model="search">
|
||||||
<script type="text/javascript" src="<%= js %>"></script>
|
<button type="submit" class="btn btn-inverse" ng-click="search=''" ng-show="search" value="+ add"><i class="icon-remove icon-white"></i></button>
|
||||||
</body>
|
</span>
|
||||||
</html>
|
</form>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<tr ng-repeat="row in rows | filter : search" ng-class="{'muted':isTemp($index)}">
|
||||||
|
<td>{{$index+1}}</td>
|
||||||
|
<td>{{row}}</td>
|
||||||
|
<td>
|
||||||
|
<button class="btn btn-danger btn-mini" ng-click="deleteRow(row)" ng-hide="isTemp($index)"><i class="icon-trash icon-white"></i></button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<script type="text/javascript" src="/js/app.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user