Skip to content

Commit 5c19e08

Browse files
committed
[IM] Fix Chosen width issues
1 parent 9e696b2 commit 5c19e08

20 files changed

+68
-23
lines changed

library/IXP/Form/AddAddresses.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function init()
4444
$type->setMultiOptions( [ 'IPv4' => 'IPv4', 'IPv6' => 'IPv6' ] )
4545
->setRegisterInArrayValidator( true )
4646
->setValue( 'IPv6' )
47-
->setAttrib( 'class', 'span3 chzn-select' )
47+
->setAttrib( 'class', 'span2 chzn-select' )
4848
->setLabel( 'Address Family' );
4949
$this->addElement( $type );
5050
}

library/IXP/Form/Cabinet.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public static function getPopulatedSelect( $name = 'cabinetid' )
104104
$cab->setRegisterInArrayValidator( true )
105105
->setRequired( true )
106106
->setLabel( _( 'Cabinet' ) )
107-
->setAttrib( 'class', 'span3 chzn-select' )
107+
->setAttrib( 'class', 'span2 chzn-select' )
108108
->addValidator( 'between', false, array( 1, $maxId ) )
109109
->setErrorMessages( array( _( 'Please select a cabinet' ) ) );
110110

library/IXP/Form/ContactGroup.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function init()
5555

5656
$type = $this->createElement( 'select', 'type' );
5757
$type->setLabel( _( 'Type' ) )
58-
->setAttrib( 'class', 'span3 chzn-select' )
58+
->setAttrib( 'class', 'span2 chzn-select' )
5959
->setRegisterInArrayValidator( true )
6060
->setErrorMessages( array( 'Please set the role' ) );
6161
$this->addElement( $type );

library/IXP/Form/Customer.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function init()
5050
$type->setMultiOptions( [ '0' => '' ] + \Entities\Customer::$CUST_TYPES_TEXT )
5151
->setRegisterInArrayValidator( true )
5252
->setLabel( 'Type' )
53-
->setAttrib( 'class', 'chzn-select span6' )
53+
->setAttrib( 'class', 'chzn-select span2' )
5454
->setErrorMessages( array( 'Please select a customer type' ) );
5555
$this->addElement( $type );
5656

@@ -101,7 +101,7 @@ public function init()
101101
->setRegisterInArrayValidator( true )
102102
->setLabel( 'Status' )
103103
->setRequired( true )
104-
->setAttrib( 'class', 'chzn-select span6' )
104+
->setAttrib( 'class', 'chzn-select span2' )
105105
->setErrorMessages( array( 'Please set the customer\'s status' ) );
106106
$this->addElement( $status );
107107

@@ -136,7 +136,7 @@ public function init()
136136
->setRegisterInArrayValidator( true )
137137
->setLabel( 'Peering Policy' )
138138
->setRequired( false )
139-
->setAttrib( 'class', 'chzn-select span6' );
139+
->setAttrib( 'class', 'chzn-select span2' );
140140

141141
$this->addElement( $peeringpolicy );
142142

@@ -223,7 +223,7 @@ public function init()
223223
->setRegisterInArrayValidator( true )
224224
->setLabel( 'Hours' )
225225
->setRequired( false )
226-
->setAttrib( 'class', 'chzn-select span6' );
226+
->setAttrib( 'class', 'chzn-select span2' );
227227
$this->addElement( $nochours );
228228

229229

@@ -288,7 +288,7 @@ public function init()
288288
->setValue( 'IE' )
289289
->setLabel( 'Country' )
290290
->setRequired( false )
291-
->setAttrib( 'class', 'chzn-select span6' );
291+
->setAttrib( 'class', 'chzn-select span2' );
292292

293293
$this->addElement( $billingCountry );
294294

@@ -407,7 +407,7 @@ public function init()
407407
->setValue( 'IE' )
408408
->setLabel( 'Country' )
409409
->setRequired( false )
410-
->setAttrib( 'class', 'chzn-select span6' );
410+
->setAttrib( 'class', 'chzn-select span2' );
411411

412412
$this->addElement( $country );
413413

@@ -447,7 +447,7 @@ public static function getPopulatedSelect( $name = 'custid' )
447447
$cust->setRegisterInArrayValidator( true )
448448
->setRequired( true )
449449
->setLabel( _( 'Customer' ) )
450-
->setAttrib( 'class', 'span3 chzn-select' )
450+
->setAttrib( 'class', 'span2 chzn-select' )
451451
->addValidator( 'between', false, array( 1, $maxId ) )
452452
->setErrorMessages( array( _( 'Please select a customer' ) ) );
453453

library/IXP/Form/Customer/NocDetails.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function init()
8080
->setRegisterInArrayValidator( true )
8181
->setLabel( 'Hours' )
8282
->setRequired( false )
83-
->setAttrib( 'class', 'chzn-select span6' );
83+
->setAttrib( 'class', 'chzn-select span2' );
8484
$this->addElement( $nochours );
8585

8686

library/IXP/Form/Interface/AddWizard.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function init()
3838
$this->setDecorators( [ [ 'ViewScript', [ 'viewScript' => 'virtual-interface/forms/add-wizard.phtml' ] ] ] );
3939

4040
$this->addElement( IXP_Form_Customer::getPopulatedSelect( 'custid' ) );
41-
$this->getElement( 'custid' )->setAttrib( 'class', 'chzn-select span12' );
41+
$this->getElement( 'custid' )->setAttrib( 'class', 'chzn-select span12' )->setAttrib( 'chzn-nofix-width', '1' );
4242

4343
////////////////////////////////////////////////////////////////////////////////////////////////////
4444
// VIRTUAL INTERFACE DETAILS
@@ -93,14 +93,15 @@ public function init()
9393
// PHYSICAL INTERFACE DETAILS
9494

9595
$this->addElement( IXP_Form_Switch::getPopulatedSelect( 'switchid' ) );
96-
$this->getElement( 'switchid' )->setAttrib( 'class', 'chzn-select span12' );
96+
$this->getElement( 'switchid' )->setAttrib( 'class', 'chzn-select span12' )->setAttrib( 'chzn-nofix-width', '1' );
9797

9898
$switchPorts = $this->createElement( 'select', 'switchportid' );
9999

100100
$switchPorts->setRequired( true )
101101
->setRegisterInArrayValidator( false )
102102
->setLabel( 'Port' )
103103
->setAttrib( 'class', 'chzn-select span12' )
104+
->setAttrib( 'chzn-nofix-width', '1' )
104105
->addValidator( 'greaterThan', false, array( 'min' => 1 ) )
105106
->setErrorMessages( array( 'Please select a switch port' ) );
106107
$this->addElement( $switchPorts );
@@ -110,6 +111,7 @@ public function init()
110111
$status->setMultiOptions( \Entities\PhysicalInterface::$STATES )
111112
->setRegisterInArrayValidator( true )
112113
->setAttrib( 'class', 'chzn-select span12' )
114+
->setAttrib( 'chzn-nofix-width', '1' )
113115
->setLabel( 'Status' )
114116
->setErrorMessages( array( 'Please set the status' ) );
115117
$this->addElement( $status );
@@ -119,6 +121,7 @@ public function init()
119121
$speed->setMultiOptions( \Entities\PhysicalInterface::$SPEED )
120122
->setRegisterInArrayValidator( true )
121123
->setAttrib( 'class', 'chzn-select span12' )
124+
->setAttrib( 'chzn-nofix-width', '1' )
122125
->setLabel( 'Speed' )
123126
->setErrorMessages( array( 'Please set the speed' ) );
124127
$this->addElement( $speed );
@@ -128,6 +131,7 @@ public function init()
128131
$duplex->setMultiOptions( \Entities\PhysicalInterface::$DUPLEX )
129132
->setRegisterInArrayValidator( true )
130133
->setAttrib( 'class', 'chzn-select span12' )
134+
->setAttrib( 'chzn-nofix-width', '1' )
131135
->setLabel( 'Duplex' )
132136
->setErrorMessages( array( 'Please set the duplex' ) );
133137
$this->addElement( $duplex );
@@ -144,7 +148,10 @@ public function init()
144148
// VLAN INTERFACE DETAILS
145149

146150
$this->addElement( IXP_Form_Vlan::getPopulatedSelect( 'vlanid' ) );
147-
$this->getElement( 'vlanid' )->setAttrib( 'class', 'chzn-select span12' );
151+
$this->getElement( 'vlanid' )
152+
->setAttrib( 'class', 'chzn-select span12' )
153+
->setAttrib( 'chzn-nofix-width', '1' );
154+
148155

149156
$ipv4enabled = $this->createElement( 'checkbox', 'ipv4enabled' );
150157
$ipv4enabled->setLabel( 'IPv4 Enabled' )

library/IXP/Form/Interface/Physical.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function init()
4343
$switchPorts->setRequired( true )
4444
->setRegisterInArrayValidator( false )
4545
->setLabel( 'Port' )
46-
->setAttrib( 'class', 'chzn-select span3' )
46+
->setAttrib( 'class', 'chzn-select span2' )
4747
->addValidator( 'greaterThan', false, array( 'min' => 1 ) )
4848
->setErrorMessages( array( 'Please select a switch port' ) );
4949
$this->addElement( $switchPorts );
@@ -54,7 +54,7 @@ public function init()
5454
$status = $this->createElement( 'select', 'status' );
5555
$status->setMultiOptions( \Entities\PhysicalInterface::$STATES )
5656
->setRegisterInArrayValidator( true )
57-
->setAttrib( 'class', 'chzn-select span3' )
57+
->setAttrib( 'class', 'chzn-select span2' )
5858
->setLabel( 'Status' )
5959
->setErrorMessages( array( 'Please set the status' ) );
6060
$this->addElement( $status );
@@ -63,7 +63,7 @@ public function init()
6363
$speed = $this->createElement( 'select', 'speed' );
6464
$speed->setMultiOptions( \Entities\PhysicalInterface::$SPEED )
6565
->setRegisterInArrayValidator( true )
66-
->setAttrib( 'class', 'chzn-select span3' )
66+
->setAttrib( 'class', 'chzn-select span2' )
6767
->setLabel( 'Speed' )
6868
->setErrorMessages( array( 'Please set the speed' ) );
6969
$this->addElement( $speed );
@@ -72,7 +72,7 @@ public function init()
7272
$duplex = $this->createElement( 'select', 'duplex' );
7373
$duplex->setMultiOptions( \Entities\PhysicalInterface::$DUPLEX )
7474
->setRegisterInArrayValidator( true )
75-
->setAttrib( 'class', 'chzn-select span3' )
75+
->setAttrib( 'class', 'chzn-select span2' )
7676
->setLabel( 'Duplex' )
7777
->setErrorMessages( array( 'Please set the duplex' ) );
7878
$this->addElement( $duplex );

library/IXP/Form/Interface/Virtual.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function init()
3939
$this->setDecorators( [ [ 'ViewScript', [ 'viewScript' => 'virtual-interface/forms/virtual-interface.phtml' ] ] ] );
4040

4141
$this->addElement( IXP_Form_Customer::getPopulatedSelect( 'custid' ) );
42-
$this->getElement( 'custid' )->setAttrib( 'class', 'chzn-select span6' );
42+
$this->getElement( 'custid' )->setAttrib( 'class', 'chzn-select span2' );
4343

4444
$name = $this->createElement( 'text', 'name' );
4545
$name->addValidator( 'stringLength', false, array( 0, 255 ) )

library/IXP/Form/Interface/Vlan.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function init()
4242
$this->addElement( $virtualInterface );
4343

4444
$this->addElement( IXP_Form_Vlan::getPopulatedSelect( 'vlanid' ) );
45-
$this->getElement( 'vlanid' )->setAttrib( 'class', 'chzn-select span6' );
45+
$this->getElement( 'vlanid' )->setAttrib( 'class', 'chzn-select span2' );
4646

4747
$ipv4enabled = $this->createElement( 'checkbox', 'ipv4enabled' );
4848
$ipv4enabled->setLabel( 'IPv4 Enabled' )

library/IXP/Form/IrrdbConfig.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static function getPopulatedSelect( $name = 'irrdb' )
8989

9090
$e->setRegisterInArrayValidator( true )
9191
->setLabel( _( 'IRRDB Source' ) )
92-
->setAttrib( 'class', 'span3 chzn-select' )
92+
->setAttrib( 'class', 'span2 chzn-select' )
9393
->setErrorMessages( array( _( 'Please select an IRRDB source' ) ) );
9494

9595
return $e;

library/IXP/Form/Location.php

+1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ public static function getPopulatedSelect( $name = 'locationid' )
160160
->setRequired( true )
161161
->setLabel( _( 'Location' ) )
162162
->setAttrib( 'class', 'span3 chzn-select' )
163+
->setAttrib( 'chzn-nofix-width', '1' )
163164
->addValidator( 'between', false, array( 1, $maxId ) )
164165
->setErrorMessages( array( _( 'Please select a location' ) ) );
165166

library/IXP/Form/Switch.php

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public function init()
5757
$switchtype = $this->createElement( 'select', 'switchtype' );
5858
$switchtype->setMultiOptions( \Entities\Switcher::$TYPES )
5959
->setAttrib( 'class', 'span3 chzn-select' )
60+
->setAttrib( 'chzn-nofix-width', '1' )
6061
->setRegisterInArrayValidator( true )
6162
->addValidator( 'greaterThan', true, array( 0 ) )
6263
->setLabel( 'Type' )
@@ -155,6 +156,7 @@ public static function getPopulatedSelect( $name = 'switchid', $type = null )
155156
->setRequired( true )
156157
->setLabel( _( 'Switch' ) )
157158
->setAttrib( 'class', 'span3 chzn-select' )
159+
->setAttrib( 'chzn-nofix-width', '1' )
158160
->addValidator( 'between', false, array( 1, $maxId ) )
159161
->setErrorMessages( array( _( 'Please select a switch' ) ) );
160162

library/IXP/Form/Switch/AddBySNMP.php

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public function init()
5757
$switchtype = $this->createElement( 'select', 'switchtype' );
5858
$switchtype->setMultiOptions( \Entities\Switcher::$TYPES )
5959
->setAttrib( 'class', 'span3 chzn-select' )
60+
->setAttrib( 'chzn-nofix-width', '1' )
6061
->setRegisterInArrayValidator( true )
6162
->addValidator( 'greaterThan', true, array( 0 ) )
6263
->setLabel( 'Type' )

library/IXP/Form/Switch/AddPorts.php

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function init()
4242
$deftype = $this->createElement( 'select', 'deftype' );
4343
$deftype->setMultiOptions( \Entities\SwitchPort::$TYPES )
4444
->setAttrib( 'class', 'chzn-select span3' )
45+
->setAttrib( 'chzn-nofix-width', '1' )
4546
->setRegisterInArrayValidator( true )
4647
->setLabel( 'Default Type' );
4748
$this->addElement( $deftype );

library/IXP/Form/Switch/Port.php

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function init()
4848
->addValidator( 'greaterThan', true, array( 0 ) )
4949
->setLabel( 'Type' )
5050
->setAttrib( 'class', 'span3 chzn-select' )
51+
->setAttrib( 'chzn-nofix-width', '1' )
5152
->setErrorMessages( array( 'Please set the port type' ) );
5253
$this->addElement( $type );
5354

library/IXP/Form/User.php

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public function init()
8181
->setRegisterInArrayValidator( true )
8282
->setLabel( 'Privileges' )
8383
->setAttrib( 'class', 'span3 chzn-select' )
84+
->setAttrib( 'chzn-nofix-width', '1' )
8485
->setErrorMessages( array( 'Please select the users privilege level' ) );
8586

8687
$this->addElement( $privileges );

library/IXP/Form/Vendor.php

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public static function getPopulatedSelect( $name = 'vendorid' )
6565
->setRequired( true )
6666
->setLabel( _( 'Vendor' ) )
6767
->setAttrib( 'class', 'span3 chzn-select' )
68+
->setAttrib( 'chzn-nofix-width', '1' )
6869
->addValidator( 'between', false, array( 1, $maxId ) )
6970
->setErrorMessages( array( _( 'Please select a vendor' ) ) );
7071

library/IXP/Form/Vlan.php

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public static function getPopulatedSelect( $name = 'vlanid' )
9696
->setRequired( true )
9797
->setLabel( _( 'VLAN' ) )
9898
->setAttrib( 'class', 'span3 chzn-select' )
99+
->setAttrib( 'chzn-nofix-width', '1' )
99100
->addValidator( 'between', false, array( 1, $maxId ) )
100101
->setErrorMessages( array( _( 'Please select a VLAN' ) ) );
101102

public/css/900-ixp-manager.css

+8
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,11 @@ a.aplain, a:link.aplain, a:visited.aplain, a:hover.aplain, a:active.aplain {
330330
}
331331

332332

333+
334+
/* Chosen width issues: https://github.com/harvesthq/chosen/issues/92
335+
336+
.chzn-container, .chzn-drop {
337+
width: 100% !important;
338+
}
339+
340+
*/

public/js/900-oss-framework.js

+23-2
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,31 @@ function ossPopover()
376376
//****************************************************************************
377377

378378
$( 'document' ).ready( function(){
379-
$(".chzn-select").chosen();
380-
$(".chzn-select-deselect").chosen({allow_single_deselect:true});
379+
380+
$(".chzn-select").each( function( index ){
381+
$( this ).chosen();
382+
ossChosenFixWidth( $( this ) );
383+
});
384+
385+
$(".chzn-select-deselect").each( function( index ) {
386+
$( this ).chosen( { allow_single_deselect:true } );
387+
ossChosenFixWidth( $( this ) );
388+
});
381389
});
382390

391+
392+
// See https://github.com/harvesthq/chosen/issues/92 for:
393+
function ossChosenFixWidth( obj ) {
394+
if( obj.attr( 'chzn-nofix-width' ) !== '1' ) {
395+
czn_id = "#" + obj.attr( "id" ) + "_chzn";
396+
width = parseInt( obj.css( "width" ) );
397+
398+
$( czn_id ).css( "width", width + "px" );
399+
$( czn_id + " > .chzn-drop" ).css( "width", ( width - 2 ) + "px" );
400+
$( czn_id + " > .chzn-drop > .chzn-search > input" ).css( "width", (width - 37 ) + "px" );
401+
}
402+
}
403+
383404
// clear a chosen dropdown
384405
function ossChosenClear( id ) {
385406
$( id ).html( "" ).val( "" );

0 commit comments

Comments
 (0)