Client side JS updates

pull/59/head
Michael Jett 2012-04-26 16:30:03 -04:00
parent c98204e705
commit 37452f4bb5
4 changed files with 108 additions and 116 deletions

View File

@ -1,12 +1,11 @@
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="resources/boostrap2/js/bootstrap.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js"></script>
<script src="resources/js/app.js"></script>
<script src="resources/js/tmpl.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="resources/boostrap2/js/bootstrap.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js"></script>
<script type="text/javascript" src="resources/js/app.js"></script>
</body>
</html>

View File

@ -3,49 +3,6 @@
<o:header title="welcome"/>
<script type="text/html" id="client_tmpl">
<tr>
<td>
<#=name#>
</td>
<td>
<#=redirectURL#>
</td>
<td>
<ul>
<# for (var i in grantType) { #>
<li>
<#=grantType[i]#>
</li>
<# } #>
</ul>
</td>
<td>
<ul>
<# for (var i in scope) { #>
<li>
<#=scope[i]#>
</li>
<# } #>
</ul>
</td>
<td>
<#=authority#>
</td>
<td>
<#=description#>
</td>
<td><input type="checkbox" "
<#=(refreshTokens == 1 ? 'checked' : '')#> value="" id="" name="" disabled>
</td>
<td>
<button class="btn">edit</button>
</td>
<td>
<button class="btn btn-danger">delete</button>
</td>
</tr>
</script>
<o:topbar/>

View File

@ -1,86 +1,78 @@
$(function () {
var ExampleOpenIdClient = {
name:"A name",
redirectURL:"http://myURL.domain",
grantType:["my grant type 1", "my grant type 2"],
scope:["scope 1", "scope 2"],
authority:"my authority",
description:"my description",
refreshTokens:false
};
console.log(tmpl('client_tmpl', ExampleOpenIdClient));
$('#client-table').append(tmpl('client_tmpl', ExampleOpenIdClient));
});
var Client = Backbone.Model.extend({
var Client = Backbone.Model.extend({
// We can pass it default values.
defaults:{
name:null,
redirectURL:"http://myURL.domain",
grantType:["my grant type 1", "my grant type 2"],
scope:["scope 1", "scope 2"],
authority:"my authority",
description:"my description",
refreshTokens:false
},
// We can pass it default values.
defaults:{
name:null,
redirectURL:"http://myURL.domain",
grantType:["my grant type 1", "my grant type 2"],
scope:["scope 1", "scope 2"],
authority:"my authority",
description:"my description",
refreshTokens:false
},
urlRoot:"../api/clients"
urlRoot:"../api/clients"
});
});
var ClientCollection = Backbone.Collection.extend({
model:Client,
url:"../api/clients"
});
var ClientCollection = Backbone.Collection.extend({
model:Client,
url:"../api/clients"
});
var ClientView = Backbone.View.extend({
var ClientView = Backbone.View.extend({
initialize:function () {
initialize:function () {
var self = this;
var self = this;
if (!($.isFunction(self.template))) {
$.get('resources/template/client.html', function (templates) {
$('body').append(templates);
self.template = $('#tmpl-client').template();
});
if (!($.isFunction(self.template))) {
$.get('resources/template/client.html', function (templates) {
$('body').append(templates);
self.template = _.template($('#tmpl-client').html());
});
}
//this.model.bind("change", this.render, this);
debugger;
},
render:function (eventName) {
$(this.el).html(this.template(this.model.toJSON()));
return this;
},
events:{
"change input":"change",
"click .save":"saveClient",
"click .delete":"deleteClient"
},
change:function (event) {
},
saveClient:function () {
},
deleteClient:function () {
},
close:function () {
$(this.el).unbind();
$(this.el).empty();
}
});
this.model.bind("change", this.render, this);
},
var view = new ClientView;
render:function (eventName) {
$(this.el).html(this.template(this.model.toJSON()));
return this;
},
});
events:{
"change input":"change",
"click .save":"saveClient",
"click .delete":"deleteClient"
},
change:function (event) {
},
saveClient:function () {
},
deleteClient:function () {
},
close:function () {
$(this.el).unbind();
$(this.el).empty();
}
});

View File

@ -0,0 +1,44 @@
<script type="text/html" id="tmpl-client">
<tr>
<td>
<%=name%>
</td>
<td>
<%=redirectURL%>
</td>
<td>
<ul>
<% for (var i in grantType) { %>
<li>
<%=grantType[i]%>
</li>
<% } %>
</ul>
</td>
<td>
<ul>
<% for (var i in scope) { %>
<li>
<%=scope[i]%>
</li>
<% } %>
</ul>
</td>
<td>
<%=authority%>
</td>
<td>
<%=description%>
</td>
<td><input type="checkbox"
<%=(refreshTokens == 1 ? 'checked' : '')%>
value="" id="" name="" disabled>
</td>
<td>
<button class="btn">edit</button>
</td>
<td>
<button class="btn btn-danger">delete</button>
</td>
</tr>
</script>