MINOR Changed GridField.js edit click behaviour from event-based to an (subclassable) method class, which means it works outside of the CMS by default. Making the whole row active in case an edit link is present

This commit is contained in:
Ingo Schommer 2012-03-01 00:19:22 +01:00
parent 1b600a0b09
commit a415034d0a
2 changed files with 34 additions and 3 deletions

View File

@ -381,6 +381,16 @@ jQuery.noConflict();
});
});
/**
* Overload the default GridField behaviour (open a new URL in the browser)
* with the CMS-specific ajax loading.
*/
$('.cms .ss-gridfield').entwine({
showDetailView: function(url) {
$('.cms-container').entwine('ss').loadPanel(url);
}
});
$('.cms-filter-form').entwine({
GridField: null,

View File

@ -34,6 +34,9 @@
}
}, ajaxOpts));
},
showDetailView: function(url) {
window.location.href = url;
},
getItems: function() {
return this.find('.ss-gridfield-item');
},
@ -59,6 +62,24 @@
return this.closest('.ss-gridfield');
}
});
$('.ss-gridfield .ss-gridfield-item').entwine({
onclick: function(e) {
if($(e.target).is('.action')) {
this._super(e);
return;
}
var editLink = this.find('.edit-link');
if(editLink.length) this.getGridField().showDetailView(editLink.prop('href'));
},
onmouseover: function() {
if(this.find('.edit-link').length) this.css('cursor', 'pointer');
},
onmouseout: function() {
this.css('cursor', 'default');
}
});
$('.ss-gridfield .action').entwine({
onclick: function(e){
@ -67,7 +88,7 @@
}
});
$('.ss-gridfield .action-deleterecord').entwine({
$('.ss-gridfield .gridfield-button-delete').entwine({
onclick: function(e){
if(!confirm(ss.i18n._t('TABLEFIELD.DELETECONFIRMMESSAGE'))) return false;
else this._super(e);
@ -76,14 +97,14 @@
$('fieldset.ss-gridfield .new-link').entwine({
onclick: function(e) {
$(this).trigger('opennewview', $(this).prop('href'));
this.getGridField().showDetailView($(this).prop('href'));
return false;
}
});
$('fieldset.ss-gridfield .edit-link').entwine({
onclick: function(e) {
$(this).trigger('openeditview', $(this).prop('href'));
this.getGridField().showDetailView($(this).prop('href'));
return false;
}
});