Skip to content

Commit

Permalink
added typeahead to creating a new domain
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevnz committed Mar 9, 2012
1 parent e0582b3 commit b6c5da5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
33 changes: 31 additions & 2 deletions public/javascripts/main.js
@@ -1,5 +1,20 @@
(function() {

var setObject = function(key, value) {
localStorage.setItem(key, JSON.stringify(value));
}

var getObject = function(key) {
return JSON.parse(localStorage.getItem(key));
}
var getAppNames = function(){
var names= [];
var apps = getObject('apps');
for (var i=0; i < apps.length; i++) {
names.push(apps[i].name);
};
return names;
}
// Global object
window.panel = {};

Expand Down Expand Up @@ -185,6 +200,7 @@
});

var AppDetailView = Backbone.View.extend({
el: '#modal',
initialize: function() {
this.tmpl = $('#app-info-tmpl').html();
this.model.on('sync', this.render, this);
Expand All @@ -200,7 +216,15 @@
},
deleteApp : function(e){
e.preventDefault();
this.destroy();
$.ajax({
url: $(e.currentTarget).attr('href'),
type: "DELETE",
success: function(r) {
alert('App Removed');
panel.appListView.collection.fetch();
$('#modal').modal('hide');
}
})
}
});

Expand All @@ -216,6 +240,7 @@
render: function() {
//this feels very wrong
if(window.location.pathname === '/apps' || window.location.pathname ==='/'){
setObject('apps', this.collection.toJSON());
var html = Mustache.to_html(this.tmpl);
$('.content').html(html).fadeIn('fast');
this.collection.each(function(app) {
Expand Down Expand Up @@ -272,7 +297,8 @@
type: "DELETE",
success: function(r) {
alert('Domain Removed');
panel.domainListView.collection.fetch()
panel.domainListView.collection.fetch();
$('#modal').modal('hide');
}
})
}
Expand Down Expand Up @@ -308,6 +334,9 @@
var html = Mustache.to_html($('#domain-new-tmpl').html());
$('#modal').html(html);
$('#modal').modal('show');


$('#newdomain-appname').typeahead({source:getAppNames()})
panel.router.navigate('appdomains/new' , {trigger: true });
},
addDomain: function(e){
Expand Down
1 change: 1 addition & 0 deletions public/stylesheets/style.css
Expand Up @@ -230,4 +230,5 @@ footer p {
top:180px;
left:50%;
z-index:5;
display:none;
}
2 changes: 1 addition & 1 deletion views/frontend-templates.jade
Expand Up @@ -49,7 +49,7 @@ script(id="app-info-tmpl", type="text/html")
td.label process id
td {{pid}}
p
a.submit.r5.redgrad.no_u(href="/app/{{name}}", data-params="{'appname':'{{name}}'}") Destroy App
a.submit.delete.r5.redgrad.no_u(href="/api/apps/{{name}}", data-params="{'appname':'{{name}}'}") Destroy App

script(id="app-new-tmpl", type="text/html")
.modal-header
Expand Down

0 comments on commit b6c5da5

Please sign in to comment.