Permalink
Browse files

MINOR Changed GridField.js edit click behaviour from event-based to a…

…n (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
  • Loading branch information...
1 parent 1b600a0 commit a415034d0af04bee922c0f2934c449e607fcd3f2 @chillu chillu committed Feb 29, 2012
Showing with 34 additions and 3 deletions.
  1. +10 −0 admin/javascript/LeftAndMain.js
  2. +24 −3 javascript/GridField.js
@@ -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
@@ -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;
}
});

0 comments on commit a415034

Please sign in to comment.