From 5d0b8445920755f3fc98abd7add556d4b5c68dfb Mon Sep 17 00:00:00 2001 From: colymba Date: Mon, 29 Apr 2013 19:01:32 +0300 Subject: [PATCH] Switch to HTML Classes for Select+Btn Fixes several issues with multiple GridFields on a page with actions being applied accross all GridFields --- code/GridFieldBulkManager.php | 4 +++- css/GridFieldBulkManager.css | 16 +++------------- javascript/GridFieldBulkManager.js | 14 +++++++------- templates/BulkManagerButtons.ss | 6 +++--- 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/code/GridFieldBulkManager.php b/code/GridFieldBulkManager.php index 0035012..9a7643c 100644 --- a/code/GridFieldBulkManager.php +++ b/code/GridFieldBulkManager.php @@ -170,7 +170,9 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr Requirements::javascript(BULK_EDIT_TOOLS_PATH . '/javascript/GridFieldBulkManager.js'); $dropDownActionList = DropdownField::create('bulkActionName', '') - ->setSource( array('edit' => 'Edit','unlink' => 'UnLink','delete' => 'Delete') ); + ->setSource( array('edit' => 'Edit','unlink' => 'UnLink','delete' => 'Delete') ) + ->setAttribute('class', 'bulkActionName') + ->setAttribute('id', ''); $templateData = new ArrayData(array( 'Menu' => $dropDownActionList->FieldHolder(), diff --git a/css/GridFieldBulkManager.css b/css/GridFieldBulkManager.css index f213088..aafab09 100644 --- a/css/GridFieldBulkManager.css +++ b/css/GridFieldBulkManager.css @@ -8,18 +8,18 @@ text-align: center; } -#bulkManagerOptions +.bulkManagerOptions { /*float: right; margin: 0 0 0 20px;*/ } -#bulkManagerOptions th.bulkmanagerselect +.bulkManagerOptions th.bulkmanagerselect { text-align: center; } -#bulkActionName +.bulkManagerOptions .dropdown { display: inline-block; border: none; @@ -31,16 +31,6 @@ color: #000; } -#bulkActionName #bulkActionName_chzn -{ - width: auto !important; -} - -#bulkActionName .chzn-drop -{ - width: 95% !important; -} - .cms table.ss-gridfield-table tbody td a.tempDisabledEditLink { background: url('../../framework/admin/images/btn-icon/document--pencil.png') no-repeat 2px 0px; diff --git a/javascript/GridFieldBulkManager.js b/javascript/GridFieldBulkManager.js index 0f9152f..1c5afaa 100644 --- a/javascript/GridFieldBulkManager.js +++ b/javascript/GridFieldBulkManager.js @@ -47,7 +47,7 @@ }*/ }); - $('#toggleSelectAll').entwine({ + $('.toggleSelectAll').entwine({ onmatch: function(){ }, onunmatch: function(){ @@ -58,7 +58,7 @@ } }); - $('select#bulkActionName').entwine({ + $('select.bulkActionName').entwine({ onmatch: function(){ }, onunmatch: function(){ @@ -66,8 +66,8 @@ onchange: function(e) { var value, btn, icon; value = $(this).val(); - btn = $('#doBulkActionButton'); - icon = $('#doBulkActionButton .ui-icon'); + btn = $(this).parents('.bulkManagerOptions').find('.doBulkActionButton'); + icon = $(this).parents('.bulkManagerOptions').find('.doBulkActionButton .ui-icon'); switch (value) { case 'edit': @@ -97,14 +97,14 @@ }); //@TODO prevent button click to call default url request - $('#doBulkActionButton').entwine({ + $('.doBulkActionButton').entwine({ onmatch: function(){ }, onunmatch: function(){ }, onmouseover: function(){ var action, ids = []; - action = $('select#bulkActionName').val(); + action = $(this).parents('.bulkManagerOptions').find('select.bulkActionName').val(); if ( action == 'edit' ) { $(this).parents('.ss-gridfield-table').find('td.col-bulkSelect input:checked').each(function(){ @@ -115,7 +115,7 @@ }, onclick: function(e) { var action, url, data = {}, ids = [], cacheBuster; - action = $('select#bulkActionName').val(); + action = $(this).parents('.bulkManagerOptions').find('select.bulkActionName').val(); if ( action != 'edit' ) { diff --git a/templates/BulkManagerButtons.ss b/templates/BulkManagerButtons.ss index 2d0be7d..e517ab8 100644 --- a/templates/BulkManagerButtons.ss +++ b/templates/BulkManagerButtons.ss @@ -1,14 +1,14 @@ - + $Menu - + $Button.Label - + \ No newline at end of file