public/javascripts/chef.js in chef-server-webui-0.10.2 vs public/javascripts/chef.js in chef-server-webui-0.10.4.rc.1
- old
+ new
@@ -57,11 +57,11 @@
});
$('form#edit_node, form#create_node').submit(function(event) {
var form = $(this);
var to_node = $('ul#for_node').sortable('toArray');
- if (form.attr('id') == 'edit_node') {
+ if (form.attr('id') === 'edit_node') {
form.append('<input type="hidden" name="_method" value="put">');
}
form.append($('input#node_name')).css('display', 'none');
form.append('<input type="hidden" id="attributes" name="attributes"/>');
$('input#attributes').attr('value', BCJTEP.save());
@@ -70,28 +70,28 @@
});
});
$('form#edit_databag_item, form#create_databag_item').submit(function(event) {
var form = $(this);
- if (form.attr('id') == 'edit_databag_item') {
+ if (form.attr('id') === 'edit_databag_item') {
form.append('<input type="hidden" name="_method" value="put">');
}
form.append('<input type="hidden" id="json_data" name="json_data"/>');
form.append($('input#json_data').attr('value', BCJTEP.save()));
});
$('form#edit_databag, form#create_databag').submit(function(event) {
var form = $(this);
- if (form.attr('id') == 'edit_databag') {
+ if (form.attr('id') === 'edit_databag') {
form.append('<input type="hidden" name="_method" value="put">');
}
form.append($('input#databag_name')).css('display', 'none');
});
$('form#edit_client, form#create_client').submit(function(event) {
var form = $(this);
- if (form.attr('id') == 'edit_client') {
+ if (form.attr('id') === 'edit_client') {
form.append('<input type="hidden" name="_method" value="put">');
}
form.append($('input#client_name')).css('display', 'none');
form.append($('input#client_admin')).css('display', 'none');
form.append($('input#client_private_key')).css('display', 'none');
@@ -100,44 +100,44 @@
});
$('form#edit_user, form#login').submit(function(event) {
var form = $(this);
- if (form.attr('id') == 'edit_user') {
+ if (form.attr('id') === 'edit_user') {
form.append('<input type="hidden" name="_method" value="put">');
form.append($('input#user_new_password')).css('display', 'none');
form.append($('input#user_admin')).css('display', 'none');
form.append($('input#user_confirm_new_password')).css('display', 'none');
form.append($('input#openid')).css('display', 'none');
}
- if (form.attr('id') == 'login') {
+ if (form.attr('id') === 'login') {
form.append($('input#user_name')).css('display', 'none');
form.append($('input#password')).css('display', 'none');
}
});
// livequery hidden form for link_to ajax magic
- $('a[method]').livequery(function(){
- var message = $(this).attr('confirm');
- var method = $(this).attr('method');
+ $(document.body).delegate('a[method]', 'click', function(e){
+ var $this = $(this);
+ var message = $this.attr('confirm'), method = $this.attr('method');
- if (!method && !message) return;
+ if (!method && !message) {
+ return;
+ }
- $(this).click(function(event){
- if (message && !confirm(message)) {
- event.preventDefault();
- return;
- }
+ if (message && !confirm(message)) {
+ event.preventDefault();
+ return;
+ }
- if (method === 'post' || method === 'put' || method === 'delete') {
- event.preventDefault();
- var form = $("<form/>").attr('method', 'post').attr('action', this.href).attr('style', 'display: none');
- if (method !== "post") {
+ if (method === 'post' || method === 'put' || method === 'delete') {
+ event.preventDefault();
+ var form = $("<form/>").attr('method', 'post').attr('action', this.href).attr('style', 'display: none');
+ if (method !== "post") {
form.append($('<input type="hidden" name="_method"/>').attr('value', method));
}
form.insertAfter(this).submit();
}
- });
});
// accordion for the cookbooks show view
$('.accordion .head').click(function() {
$(this).next().toggle('slow');