From e824fbfc8a7937e4a4d092524d8f376d20bf9977 Mon Sep 17 00:00:00 2001 From: Josh Angell Date: Wed, 3 Dec 2014 14:38:21 +0000 Subject: [PATCH 1/4] Fixed some formatting in the docs --- docs/1-field-types.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/1-field-types.md b/docs/1-field-types.md index e5fa2e2..5590f64 100644 --- a/docs/1-field-types.md +++ b/docs/1-field-types.md @@ -63,10 +63,10 @@ Create a select drop-down of colours. ![text size](http://s3-eu-west-1.amazonaws.com/supercoolplugins/Button-Box/colours.jpg) -* Option Label: Name of your colour (e.g. 'Grey', 'Orange', or 'Mountain Honey Dew') -* Value: This appears in your template and will most likely be a CSS class name -* Valid CSS Colour: This creates the preview colour and just needs to be valid CSS (i.e. CSS colour names, Hex, RGB or RGBA values should all work for you). -* Default: Optionally choose one row to define as your default option for users. +* __Option Label:__ Name of your colour (e.g. 'Grey', 'Orange', or 'Mountain Honey Dew') +* __Value:__ This appears in your template and will most likely be a CSS class name +* __Valid CSS Colour:__ This creates the preview colour and just needs to be valid CSS (i.e. CSS colour names, Hex, RGB or RGBA values should all work for you). +* __Default:__ Optionally choose one row to define as your default option for users. ## Text Size @@ -99,5 +99,5 @@ You are of course free to use this as you see fit and the generic nature of a ro ![width](http://s3-eu-west-1.amazonaws.com/supercoolplugins/Button-Box/width.jpg) Each row you add, creates an extra box. -* Value: This appears in your template and will most likely need to be a CSS class name. -* Default: Optionally choose one row to define as your default option for users. +* __Value:__ This appears in your template and will most likely need to be a CSS class name. +* __Default:__ Optionally choose one row to define as your default option for users. From 39b3ebc7db32857cb0db872c72ed34e404f095d6 Mon Sep 17 00:00:00 2001 From: Josh Angell Date: Fri, 9 Jan 2015 10:21:41 +0000 Subject: [PATCH 2/4] Changed the behaviour of getDefaultValue() for colours and text size fields If no default is picked then it will fallback to using the first option as the default value. This fixes #5. --- .../fieldtypes/ButtonBox_ColoursFieldType.php | 67 ++++++++++--------- .../ButtonBox_TextSizeFieldType.php | 67 ++++++++++--------- 2 files changed, 72 insertions(+), 62 deletions(-) diff --git a/buttonbox/fieldtypes/ButtonBox_ColoursFieldType.php b/buttonbox/fieldtypes/ButtonBox_ColoursFieldType.php index 48e899d..0a1c9c5 100644 --- a/buttonbox/fieldtypes/ButtonBox_ColoursFieldType.php +++ b/buttonbox/fieldtypes/ButtonBox_ColoursFieldType.php @@ -10,9 +10,6 @@ * @link http://www.supercooldesign.co.uk */ -/** - * - */ class ButtonBox_ColoursFieldType extends BaseOptionsFieldType { /** @@ -57,10 +54,10 @@ public function getInputHtml($name, $value) /** - * @inheritDoc BaseElementFieldType::getSettingsHtml() - * - * @return string|null - */ + * @inheritDoc BaseElementFieldType::getSettingsHtml() + * + * @return string|null + */ public function getSettingsHtml() { $options = $this->getOptions(); @@ -74,22 +71,6 @@ public function getSettingsHtml() 'value' => '', 'cssColour' => '' ) - // array( - // 'label' => 'Green', - // 'value' => 'green', - // 'cssColour' => '#328d7e', - // 'default' => true - // ), - // array( - // 'label' => 'Navy', - // 'value' => 'navy', - // 'cssColour' => '#17333a' - // ), - // array( - // 'label' => 'Brown', - // 'value' => 'brown', - // 'cssColour' => '#818b80' - // ) ); } @@ -133,10 +114,10 @@ public function getSettingsHtml() // ========================================================================= /** - * @inheritDoc BaseOptionsFieldType::getOptionsSettingsLabel() - * - * @return string - */ + * @inheritDoc BaseOptionsFieldType::getOptionsSettingsLabel() + * + * @return string + */ protected function getOptionsSettingsLabel() { return Craft::t('Colour Options'); @@ -144,10 +125,10 @@ protected function getOptionsSettingsLabel() /** - * @inheritDoc BaseSavableComponentType::defineSettings() - * - * @return array - */ + * @inheritDoc BaseSavableComponentType::defineSettings() + * + * @return array + */ protected function defineSettings() { return array( @@ -155,4 +136,28 @@ protected function defineSettings() ); } + + /** + * Returns the default field value. + * + * @return array|string|null + */ + protected function getDefaultValue() + { + + foreach ($this->getOptions() as $option) + { + + if ( !empty($option['default']) ) + { + return $option['value']; + } + + } + + return $this->getOptions()[0]['value']; + + } + + } diff --git a/buttonbox/fieldtypes/ButtonBox_TextSizeFieldType.php b/buttonbox/fieldtypes/ButtonBox_TextSizeFieldType.php index c4194e2..3cc176a 100644 --- a/buttonbox/fieldtypes/ButtonBox_TextSizeFieldType.php +++ b/buttonbox/fieldtypes/ButtonBox_TextSizeFieldType.php @@ -10,9 +10,6 @@ * @link http://www.supercooldesign.co.uk */ -/** - * - */ class ButtonBox_TextSizeFieldType extends BaseOptionsFieldType { /** @@ -57,10 +54,10 @@ public function getInputHtml($name, $value) /** - * @inheritDoc BaseElementFieldType::getSettingsHtml() - * - * @return string|null - */ + * @inheritDoc BaseElementFieldType::getSettingsHtml() + * + * @return string|null + */ public function getSettingsHtml() { $options = $this->getOptions(); @@ -74,22 +71,6 @@ public function getSettingsHtml() 'value' => '', 'pxVal' => '' ) - // array( - // 'label' => 'Medium', - // 'value' => 'medium', - // 'pxVal' => '16', - // 'default' => true - // ), - // array( - // 'label' => 'Large', - // 'value' => 'large', - // 'pxVal' => '24' - // ), - // array( - // 'label' => 'Mega', - // 'value' => 'mega', - // 'pxVal' => '36' - // ) ); } @@ -132,10 +113,10 @@ public function getSettingsHtml() // ========================================================================= /** - * @inheritDoc BaseOptionsFieldType::getOptionsSettingsLabel() - * - * @return string - */ + * @inheritDoc BaseOptionsFieldType::getOptionsSettingsLabel() + * + * @return string + */ protected function getOptionsSettingsLabel() { return Craft::t('Text Size Options'); @@ -143,10 +124,10 @@ protected function getOptionsSettingsLabel() /** - * @inheritDoc BaseSavableComponentType::defineSettings() - * - * @return array - */ + * @inheritDoc BaseSavableComponentType::defineSettings() + * + * @return array + */ protected function defineSettings() { return array( @@ -154,4 +135,28 @@ protected function defineSettings() ); } + + /** + * Returns the default field value. + * + * @return array|string|null + */ + protected function getDefaultValue() + { + + foreach ($this->getOptions() as $option) + { + + if ( !empty($option['default']) ) + { + return $option['value']; + } + + } + + return $this->getOptions()[0]['value']; + + } + + } From ea1dad3a2f6ad4c60a5a388edc8654cdc8d60e3c Mon Sep 17 00:00:00 2001 From: Josh Angell Date: Fri, 9 Jan 2015 10:21:41 +0000 Subject: [PATCH 3/4] Changed the behaviour of getDefaultValue() for colours and text size fields If no default is picked then it will fallback to using the first option as the default value. This fixes #5. --- .../fieldtypes/ButtonBox_ColoursFieldType.php | 67 ++++++++++--------- .../ButtonBox_TextSizeFieldType.php | 67 ++++++++++--------- 2 files changed, 72 insertions(+), 62 deletions(-) diff --git a/buttonbox/fieldtypes/ButtonBox_ColoursFieldType.php b/buttonbox/fieldtypes/ButtonBox_ColoursFieldType.php index 48e899d..0a1c9c5 100644 --- a/buttonbox/fieldtypes/ButtonBox_ColoursFieldType.php +++ b/buttonbox/fieldtypes/ButtonBox_ColoursFieldType.php @@ -10,9 +10,6 @@ * @link http://www.supercooldesign.co.uk */ -/** - * - */ class ButtonBox_ColoursFieldType extends BaseOptionsFieldType { /** @@ -57,10 +54,10 @@ public function getInputHtml($name, $value) /** - * @inheritDoc BaseElementFieldType::getSettingsHtml() - * - * @return string|null - */ + * @inheritDoc BaseElementFieldType::getSettingsHtml() + * + * @return string|null + */ public function getSettingsHtml() { $options = $this->getOptions(); @@ -74,22 +71,6 @@ public function getSettingsHtml() 'value' => '', 'cssColour' => '' ) - // array( - // 'label' => 'Green', - // 'value' => 'green', - // 'cssColour' => '#328d7e', - // 'default' => true - // ), - // array( - // 'label' => 'Navy', - // 'value' => 'navy', - // 'cssColour' => '#17333a' - // ), - // array( - // 'label' => 'Brown', - // 'value' => 'brown', - // 'cssColour' => '#818b80' - // ) ); } @@ -133,10 +114,10 @@ public function getSettingsHtml() // ========================================================================= /** - * @inheritDoc BaseOptionsFieldType::getOptionsSettingsLabel() - * - * @return string - */ + * @inheritDoc BaseOptionsFieldType::getOptionsSettingsLabel() + * + * @return string + */ protected function getOptionsSettingsLabel() { return Craft::t('Colour Options'); @@ -144,10 +125,10 @@ protected function getOptionsSettingsLabel() /** - * @inheritDoc BaseSavableComponentType::defineSettings() - * - * @return array - */ + * @inheritDoc BaseSavableComponentType::defineSettings() + * + * @return array + */ protected function defineSettings() { return array( @@ -155,4 +136,28 @@ protected function defineSettings() ); } + + /** + * Returns the default field value. + * + * @return array|string|null + */ + protected function getDefaultValue() + { + + foreach ($this->getOptions() as $option) + { + + if ( !empty($option['default']) ) + { + return $option['value']; + } + + } + + return $this->getOptions()[0]['value']; + + } + + } diff --git a/buttonbox/fieldtypes/ButtonBox_TextSizeFieldType.php b/buttonbox/fieldtypes/ButtonBox_TextSizeFieldType.php index c4194e2..3cc176a 100644 --- a/buttonbox/fieldtypes/ButtonBox_TextSizeFieldType.php +++ b/buttonbox/fieldtypes/ButtonBox_TextSizeFieldType.php @@ -10,9 +10,6 @@ * @link http://www.supercooldesign.co.uk */ -/** - * - */ class ButtonBox_TextSizeFieldType extends BaseOptionsFieldType { /** @@ -57,10 +54,10 @@ public function getInputHtml($name, $value) /** - * @inheritDoc BaseElementFieldType::getSettingsHtml() - * - * @return string|null - */ + * @inheritDoc BaseElementFieldType::getSettingsHtml() + * + * @return string|null + */ public function getSettingsHtml() { $options = $this->getOptions(); @@ -74,22 +71,6 @@ public function getSettingsHtml() 'value' => '', 'pxVal' => '' ) - // array( - // 'label' => 'Medium', - // 'value' => 'medium', - // 'pxVal' => '16', - // 'default' => true - // ), - // array( - // 'label' => 'Large', - // 'value' => 'large', - // 'pxVal' => '24' - // ), - // array( - // 'label' => 'Mega', - // 'value' => 'mega', - // 'pxVal' => '36' - // ) ); } @@ -132,10 +113,10 @@ public function getSettingsHtml() // ========================================================================= /** - * @inheritDoc BaseOptionsFieldType::getOptionsSettingsLabel() - * - * @return string - */ + * @inheritDoc BaseOptionsFieldType::getOptionsSettingsLabel() + * + * @return string + */ protected function getOptionsSettingsLabel() { return Craft::t('Text Size Options'); @@ -143,10 +124,10 @@ protected function getOptionsSettingsLabel() /** - * @inheritDoc BaseSavableComponentType::defineSettings() - * - * @return array - */ + * @inheritDoc BaseSavableComponentType::defineSettings() + * + * @return array + */ protected function defineSettings() { return array( @@ -154,4 +135,28 @@ protected function defineSettings() ); } + + /** + * Returns the default field value. + * + * @return array|string|null + */ + protected function getDefaultValue() + { + + foreach ($this->getOptions() as $option) + { + + if ( !empty($option['default']) ) + { + return $option['value']; + } + + } + + return $this->getOptions()[0]['value']; + + } + + } From 0b9cdac7c044c52600e15241c0032bd1dcc9734d Mon Sep 17 00:00:00 2001 From: Josh Angell Date: Fri, 9 Jan 2015 10:29:33 +0000 Subject: [PATCH 4/4] add release notes for 1.3.1 --- buttonbox/ButtonBoxPlugin.php | 4 ++-- release-notes.json | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/buttonbox/ButtonBoxPlugin.php b/buttonbox/ButtonBoxPlugin.php index 4121646..55f7538 100644 --- a/buttonbox/ButtonBoxPlugin.php +++ b/buttonbox/ButtonBoxPlugin.php @@ -20,7 +20,7 @@ public function getName() public function getVersion() { - return '1.3'; + return '1.3.1'; } public function getDeveloper() @@ -30,7 +30,7 @@ public function getDeveloper() public function getDeveloperUrl() { - return 'http://www.supercooldesign.co.uk'; + return 'http://plugins.supercooldesign.co.uk'; } } diff --git a/release-notes.json b/release-notes.json index da0737c..3ff4202 100644 --- a/release-notes.json +++ b/release-notes.json @@ -1,4 +1,14 @@ [ + { + "version" : "1.3.1", + "date" : "9-1-2015", + "notes" : [ + { + "type" : "fixed", + "message" : "Fixed a bug where fancy options fields (text size and colours) were not showing if there was no default option selected." + } + ] + }, { "version" : "1.3", "date" : "3-12-2014",