Skip to content

Commit

Permalink
Reverted things to work with bs2
Browse files Browse the repository at this point in the history
  • Loading branch information
phiamo committed Sep 10, 2013
1 parent 4f64d63 commit d7753ff
Show file tree
Hide file tree
Showing 20 changed files with 580 additions and 1,275 deletions.
12 changes: 7 additions & 5 deletions BRANCHES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ MopaBootstrapBundle Branches
============================

Current Master:
master: Using Symfony >=2.3 with Bootstrap >=2.x or >=3.x
master: Using Symfony >=2.3 with Bootstrap >=3.x
v2.3.x: Using Symfony >=2.3 with Bootstrap >=2.3.2


No Longer Maintained:
v2.2.x: Using Symfony ~2.2.x with Bootstrap 2.x
v2.1.x: Using Symfony ~2.1.x with Bootstrap 2.x
v2.0.x: Using Symfony ~2.0.x with Bootstrap 2.x
v1.x: Using Symfony ~2.0.x with Bootstrap 1.x
* v2.2.x: Using Symfony ~2.2.x with Bootstrap 2.x
* v2.1.x: Using Symfony ~2.1.x with Bootstrap 2.x
* v2.0.x: Using Symfony ~2.0.x with Bootstrap 2.x
* v1.x: Using Symfony ~2.0.x with Bootstrap 1.x

5 changes: 0 additions & 5 deletions DependencyInjection/Compiler/NavbarPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ public function process(ContainerBuilder $container)
$definition = $container->getDefinition('mopa_bootstrap.navbar_renderer');

$template = $container->getParameter('mopa_bootstrap.navbar.template');
if(strpos($template, "%d") !== false){
$version = $container->getParameter('mopa_bootstrap.version');
$template = sprintf($template, $version);
$container->setParameter('mopa_bootstrap.navbar.template', $template);
}

$navbars = array();
foreach ($container->findTaggedServiceIds('mopa_bootstrap.navbar') as $id => $tags) {
Expand Down
10 changes: 6 additions & 4 deletions DependencyInjection/Compiler/VersionPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function process(ContainerBuilder $container)
$cachePath = $container->getParameter('kernel.cache_dir').'/mopa_bootstrap_version.cache';

// the second argument indicates whether or not you want to use debug mode
$versionCache = new ConfigCache($cachePath, $container->getParameter("kernel.debug"));
$versionCache = new ConfigCache($cachePath, false);

if (!$versionCache->isFresh()) {
$symfonyComposerJson = $container->getParameter('kernel.cache_dir').DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."composer.json";
Expand All @@ -31,10 +31,12 @@ public function process(ContainerBuilder $container)
$version = preg_split("/-/", $package->getVersion());
$targetPackagePath = $composer->getInstallationManager()->getInstallPath($package);
$twbscomposer = $targetPackagePath ."/composer.json";

$resources = array(new FileResource($twbscomposer));

$versionCache->write($version[0], $resources);
$version = $version[0];
if (strpos($version, ".") !== false) { # only get the first
$version = substr($version, 0, 1);
}
$versionCache->write($version, $resources);
} else {
throw new \RuntimeException("Could not find composer and mopa_bootstrap.version not set in config!!");
}
Expand Down
18 changes: 5 additions & 13 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,12 @@ public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('mopa_bootstrap');
$this->addVersionConfig($rootNode);
$this->addFormConfig($rootNode);
$this->addNavbarConfig($rootNode);
$this->addInitializrConfig($rootNode);

return $treeBuilder;
}

protected function addVersionConfig(ArrayNodeDefinition $rootNode)
{
$rootNode
->children()
->scalarNode('version')
->defaultValue(null)
->cannotBeEmpty()
->end();
}
protected function addFormConfig(ArrayNodeDefinition $rootNode)
{
$rootNode
Expand All @@ -54,7 +43,7 @@ protected function addFormConfig(ArrayNodeDefinition $rootNode)
->addDefaultsIfNotSet()
->children()
->scalarNode('templating')
->defaultValue("MopaBootstrapBundle:Form:fields_bs_%d.html.twig")
->defaultValue("MopaBootstrapBundle:Form:fields.html.twig")
->end()
->scalarNode('horizontal_label_class')
->defaultValue("col-lg-3")
Expand Down Expand Up @@ -83,6 +72,9 @@ protected function addFormConfig(ArrayNodeDefinition $rootNode)
->booleanNode('render_optional_text')
->defaultValue(true)
->end()
->booleanNode('errors_on_forms')
->defaultValue(false)
->end()
->booleanNode('render_required_asterisk')
->defaultValue(false)
->end()
Expand Down Expand Up @@ -175,7 +167,7 @@ protected function addNavbarConfig(ArrayNodeDefinition $rootNode)
->addDefaultsIfNotSet()
->children()
->scalarNode('template')
->defaultValue('MopaBootstrapBundle:Navbar:navbar_bs_%d.html.twig')
->defaultValue('MopaBootstrapBundle:Navbar:navbar.html.twig')
->cannotBeEmpty()
->end()
->end()
Expand Down
5 changes: 1 addition & 4 deletions DependencyInjection/MopaBootstrapExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ public function load(array $configs, ContainerBuilder $container)
$config = $this->processConfiguration($configuration, $configs);

$yamlloader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
if(!isset($config['version'])){
#throw new \RuntimeException("You need to specify mopa_bootstrap.version!");
}
else{
if(isset($config['version'])){
$container->setParameter('mopa_bootstrap.version', $config['version']);
}
$yamlloader->load('twig_extensions.yml');
Expand Down
43 changes: 0 additions & 43 deletions Form/Extension/HorizontalFormTypeExtension.php

This file was deleted.

4 changes: 4 additions & 0 deletions Form/Extension/LegendFormTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class LegendFormTypeExtension extends AbstractTypeExtension
private $show_child_legend;
private $render_required_asterisk;
private $render_optional_text;
private $errors_on_forms;

public function __construct(array $options)
{
Expand All @@ -21,6 +22,7 @@ public function __construct(array $options)
$this->show_child_legend = $options['show_child_legend'];
$this->render_required_asterisk = $options['render_required_asterisk'];
$this->render_optional_text = $options['render_optional_text'];
$this->errors_on_forms = $options['errors_on_forms'];
}

public function buildView(FormView $view, FormInterface $form, array $options)
Expand All @@ -31,6 +33,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
$view->vars['label_render'] = $options['label_render'];
$view->vars['render_required_asterisk'] = $options['render_required_asterisk'];
$view->vars['render_optional_text'] = $options['render_optional_text'];
$view->vars['errors_on_forms'] = $options['errors_on_forms'];
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
Expand All @@ -41,6 +44,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
'label_render' => true,
'render_required_asterisk' => $this->render_required_asterisk,
'render_optional_text' => $this->render_optional_text,
'errors_on_forms' => $this->errors_on_forms,
));
}
public function getExtendedType()
Expand Down
13 changes: 8 additions & 5 deletions Form/Extension/WidgetFormTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,24 @@ public function buildView(FormView $view, FormInterface $form, array $options)
throw new \Exception('You must provide a "type" for widget_addon');
}

$view->vars['widget_form_group'] = $options['widget_form_group'];
$view->vars['widget_control_group'] = $options['widget_control_group'];
$view->vars['widget_controls'] = $options['widget_controls'];
$view->vars['widget_addon'] = $options['widget_addon'];
$view->vars['widget_prefix'] = $options['widget_prefix'];
$view->vars['widget_suffix'] = $options['widget_suffix'];
$view->vars['widget_type'] = $options['widget_type'];
$view->vars['widget_items_attr'] = $options['widget_items_attr'];
$view->vars['widget_form_group_attr'] = $options['widget_form_group_attr'];
$view->vars['widget_control_group_attr'] = $options['widget_control_group_attr'];
$view->vars['widget_controls_attr'] = $options['widget_controls_attr'];
$view->vars['widget_checkbox_label'] = $options['widget_checkbox_label'];

}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(
array(
'widget_form_group' => true,
'widget_control_group' => true,
'widget_controls' => true,
'widget_addon' => array(
'type' => null, //false: dont add anything, null: using presets, anything; prepend; append
'icon' => null,
Expand All @@ -60,9 +63,9 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
'widget_suffix' => null,
'widget_type' => '',
'widget_items_attr' => array(),
'widget_form_group_attr' => array(),
'widget_control_group_attr' => array(),
'widget_controls_attr' => array(),
'widget_checkbox_label' => $this->options['checkbox_label'],
'mopa_bootstrap_version' => $this->options['bootstrap_version']
)
);
$resolver->setAllowedValues(array(
Expand Down
24 changes: 10 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,33 @@ To use bootstrap 3 in your project add it via [composer](https://github.com/phia
and let the Bundle detect version etc, automatically.
An upgrade to bootstrap 3 should also be as easy as changing your composer.json to use bootstrap 3


Branches
--------

To use this bundle with boostrap 3 use the master branch:

``` json
{
"require": {
"mopa/bootstrap-bundle": "dev-master",
"twbs/bootstrap": "v3.0.0"
}
}
```

For bootstrap 2 use the v2.3.x branch:

```json
If you want to use bootstrap 2:

{
"require": {
"mopa/bootstrap-bundle": "dev-v2.3.x",
"twbs/bootstrap": "v2.3.2"
}
}
```

If you encounter any problems,
e.g. @MopaBootstrapBundle/Resources/bootstrap/js/[bootstrap-]tooltip.js missing
or anything similar related to boostrap 2/3 changes, try setting the version manually:

``` yaml
mopa_boostrap:
# this tells the bundle which boostrap version you are using, to choose the correct files:
# e.g. using Resources/views/Form/fields_bs_2.html.twig or Resources/public/js/eyecon-bootstrap-3-datepicker.js
version: 2 # or 3
```
Branches
--------
To understand which versions are currently required have a look into `BRANCHES.md`

Documentation
Expand Down
9 changes: 1 addition & 8 deletions Resources/config/form_extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
mopa.form.legend_extension:
class: Mopa\Bundle\BootstrapBundle\Form\Extension\LegendFormTypeExtension
arguments:
- { render_fieldset: %mopa_bootstrap.form.render_fieldset%, show_legend: %mopa_bootstrap.form.show_legend%, show_child_legend: %mopa_bootstrap.form.show_child_legend%, render_required_asterisk: %mopa_bootstrap.form.render_required_asterisk%, render_optional_text: %mopa_bootstrap.form.render_optional_text% }
- { render_fieldset: %mopa_bootstrap.form.render_fieldset%, show_legend: %mopa_bootstrap.form.show_legend%, show_child_legend: %mopa_bootstrap.form.show_child_legend%, render_required_asterisk: %mopa_bootstrap.form.render_required_asterisk%, render_optional_text: %mopa_bootstrap.form.render_optional_text%, errors_on_forms: %mopa_bootstrap.form.errors_on_forms%}
tags:
- { name: form.type_extension, alias: form }

Expand All @@ -32,13 +32,6 @@ services:
tags:
- { name: form.type_extension, alias: form }

mopa.form.horizontal_extension:
class: Mopa\Bundle\BootstrapBundle\Form\Extension\HorizontalFormTypeExtension
arguments:
- { horizontal_label_class: %mopa_bootstrap.form.horizontal_label_class%, horizontal_input_wrapper_class: %mopa_bootstrap.form.horizontal_input_wrapper_class%, row_wrapper_class: %mopa_bootstrap.form.row_wrapper_class% }
tags:
- { name: form.type_extension, alias: form }

mopa.form.widget_collection_extension:
class: Mopa\Bundle\BootstrapBundle\Form\Extension\WidgetCollectionFormTypeExtension
arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@
@import "../../bootstrap/less/variables.less";
@import "../../bootstrap/less/mixins.less";

/* @TODO: deprecated variables, put somewhere else or substitute */
@grayLighter: #eee;
@grayLight: #999;

.datepicker {
top: 0;
left: 0;
padding: 4px;
margin-top: 1px;
border-radius: 4px;
.border-radius(4px);
&:before {
content: '';
display: inline-block;
Expand All @@ -36,7 +32,7 @@
display: inline-block;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 6px solid #fff;
border-bottom: 6px solid @white;
position: absolute;
top: -6px;
left: 7px;
Expand All @@ -53,7 +49,7 @@
text-align: center;
width: 20px;
height: 20px;
border-radius: 4px;
.border-radius(4px);
}
td {
&.day:hover {
Expand All @@ -66,7 +62,7 @@
}
&.active,
&.active:hover {
.btn-pseudo-states(@btn-default-color, @btn-default-bg, @btn-default-border);
.buttonBackground(@btnPrimaryBackground, @btnPrimaryBackgroundHighlight);
color: #fff;
text-shadow: 0 -1px 0 rgba(0,0,0,.25);
}
Expand All @@ -78,12 +74,12 @@
float: left;
margin: 2px;
cursor: pointer;
border-radius: 4px;
.border-radius(4px);
&:hover {
background: @grayLighter;
}
&.active {
.btn-pseudo-states(@btn-default-color, @btn-default-bg, @btn-default-border);
.buttonBackground(@btnPrimaryBackground, @btnPrimaryBackgroundHighlight);
color: #fff;
text-shadow: 0 -1px 0 rgba(0,0,0,.25);
}
Expand All @@ -99,7 +95,7 @@
}
&.next,
&.prev {
font-size: @font-size-base * 1.5;
font-size: @baseFontSize * 1.5;
}
}

Expand Down
Loading

0 comments on commit d7753ff

Please sign in to comment.