From 4126b95cf79c47827ab8959046f9095587d93590 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 7 Feb 2012 20:56:40 +0100 Subject: [PATCH] ENHANCEMENT Allow selection of items in GridField (via JavaScript only) --- css/GridField.css | 2 ++ javascript/GridField.js | 62 +++++++++++++++++++++++++++++++++++------ scss/GridField.scss | 17 +++++++++-- 3 files changed, 71 insertions(+), 10 deletions(-) diff --git a/css/GridField.css b/css/GridField.css index 0d887a91a..f1f228327 100644 --- a/css/GridField.css +++ b/css/GridField.css @@ -1,5 +1,7 @@ /** Core styles for the basic GridField form field without any specific style. @package sapphire @subpackage scss @todo Add radial gradient to default delete button state @todo Create SASS mixin-function to simply swap the from/to, to to/from colours in grsdient mixins? */ .cms fieldset.ss-gridfield > div { margin-bottom: 35px; } +.cms fieldset.ss-gridfield[data-selectable] tr.ui-selected, .cms fieldset.ss-gridfield[data-selectable] tr.ui-selecting { background: #FFFAD6 !important; } +.cms fieldset.ss-gridfield[data-selectable] td { cursor: pointer; } .cms table.ss-gridfield.field { box-shadow: none; padding: 0; margin: 20px 0 0 0; border-collapse: separate; border-bottom: 0 none; } .cms table.ss-gridfield.field thead { color: #1d2224; background: transparent; } .cms table.ss-gridfield.field tbody { background: #FFF; } diff --git a/javascript/GridField.js b/javascript/GridField.js index 570e256ec..011fa6e7e 100644 --- a/javascript/GridField.js +++ b/javascript/GridField.js @@ -1,4 +1,16 @@ jQuery(function($){ + + $('fieldset.ss-gridfield').entwine({ + getItems: function() { + return this.find('.ss-gridfield-item'); + } + }); + + $('fieldset.ss-gridfield *').entwine({ + getGridField: function() { + return this.parents('fieldset.ss-gridfield:first'); + } + }); $('fieldset.ss-gridfield .action').entwine({ onclick: function(e){ @@ -26,13 +38,6 @@ jQuery(function($){ } }); - var removeFilterButtons = function() { - // Remove stuff - $('th').children('div').each(function(i,v) { - $(v).remove(); - }); - } - /* * Upon focusing on a filter element, move "filter" and "reset" buttons and display next to the current element * ToDo ensure filter-button state is maintained after filtering (see resetState param) @@ -46,8 +51,10 @@ jQuery(function($){ return false; } var eleInput = $(this); + // Remove existing
and