Skip to content

Commit

Permalink
Merge branch 'upstream' into 313-Inflector-Helper
Browse files Browse the repository at this point in the history
* upstream:
  Fixes issue yiisoft#320: Module::createController() will fail with a route with trailing slash.
  Fixed test break about AssetController.
  requirements css.php twitter bootstrap update to 2.3.2
  Twitter bootstrap updated to 2.3.2
  Modified the IAssetConvert interface.
  hashing the key for registerCss and registerJs.
  Update AccessRule.php
  refactored code after feedback
  Fixed framework path.
  Added support for View::POS_READY.
  new proposed structure
  remove from master (update track)
  made some changes, fix some pitfalls, remove PHP_EOL
  yiisoft#20 proposed architecture for bootstrap

Conflicts:
	yii/helpers/base/Inflector.php
  • Loading branch information
tonydspaniard committed May 20, 2013
2 parents edd7ec4 + 7f9cc39 commit 8101b5e
Show file tree
Hide file tree
Showing 15 changed files with 3,115 additions and 2,691 deletions.
5 changes: 2 additions & 3 deletions apps/bootstrap/yii
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ defined('YII_DEBUG') or define('YII_DEBUG', true);
// fcgi doesn't have STDIN defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));

$frameworkPath = __DIR__ . '/../../yii';

require($frameworkPath . '/Yii.php');
require(__DIR__ . '/vendor/yiisoft/yii2/yii.php');
require(__DIR__ . '/vendor/autoload.php');

$config = require(__DIR__ . '/config/console.php');

Expand Down
2 changes: 1 addition & 1 deletion yii/assets/bootstrap/css/bootstrap-responsive.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Bootstrap Responsive v2.3.1
* Bootstrap Responsive v2.3.2
*
* Copyright 2012 Twitter, Inc
* Licensed under the Apache License v2.0
Expand Down
11 changes: 10 additions & 1 deletion yii/assets/bootstrap/css/bootstrap.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Bootstrap v2.3.1
* Bootstrap v2.3.2
*
* Copyright 2012 Twitter, Inc
* Licensed under the Apache License v2.0
Expand Down Expand Up @@ -3009,6 +3009,15 @@ table th[class*="span"],
display: block;
}

.dropdown-backdrop {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 990;
}

.pull-right > .dropdown-menu {
right: 0;
left: auto;
Expand Down
32 changes: 18 additions & 14 deletions yii/assets/bootstrap/js/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ===================================================
* bootstrap-transition.js v2.3.1
* bootstrap-transition.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#transitions
* ===================================================
* Copyright 2012 Twitter, Inc.
Expand Down Expand Up @@ -58,7 +58,7 @@
})

}(window.jQuery);/* ==========================================================
* bootstrap-alert.js v2.3.1
* bootstrap-alert.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#alerts
* ==========================================================
* Copyright 2012 Twitter, Inc.
Expand Down Expand Up @@ -156,7 +156,7 @@
$(document).on('click.alert.data-api', dismiss, Alert.prototype.close)

}(window.jQuery);/* ============================================================
* bootstrap-button.js v2.3.1
* bootstrap-button.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#buttons
* ============================================================
* Copyright 2012 Twitter, Inc.
Expand Down Expand Up @@ -260,7 +260,7 @@
})

}(window.jQuery);/* ==========================================================
* bootstrap-carousel.js v2.3.1
* bootstrap-carousel.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#carousel
* ==========================================================
* Copyright 2012 Twitter, Inc.
Expand Down Expand Up @@ -466,7 +466,7 @@
})

}(window.jQuery);/* =============================================================
* bootstrap-collapse.js v2.3.1
* bootstrap-collapse.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#collapse
* =============================================================
* Copyright 2012 Twitter, Inc.
Expand Down Expand Up @@ -632,7 +632,7 @@
})

}(window.jQuery);/* ============================================================
* bootstrap-dropdown.js v2.3.1
* bootstrap-dropdown.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#dropdowns
* ============================================================
* Copyright 2012 Twitter, Inc.
Expand Down Expand Up @@ -685,6 +685,10 @@
clearMenus()

if (!isActive) {
if ('ontouchstart' in document.documentElement) {
// if mobile we we use a backdrop because click events don't delegate
$('<div class="dropdown-backdrop"/>').insertBefore($(this)).on('click', clearMenus)
}
$parent.toggleClass('open')
}

Expand Down Expand Up @@ -737,6 +741,7 @@
}

function clearMenus() {
$('.dropdown-backdrop').remove()
$(toggle).each(function () {
getParent($(this)).removeClass('open')
})
Expand Down Expand Up @@ -791,13 +796,12 @@
$(document)
.on('click.dropdown.data-api', clearMenus)
.on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
.on('click.dropdown-menu', function (e) { e.stopPropagation() })
.on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
.on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)

}(window.jQuery);
/* =========================================================
* bootstrap-modal.js v2.3.1
* bootstrap-modal.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#modals
* =========================================================
* Copyright 2012 Twitter, Inc.
Expand Down Expand Up @@ -1044,7 +1048,7 @@

}(window.jQuery);
/* ===========================================================
* bootstrap-tooltip.js v2.3.1
* bootstrap-tooltip.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#tooltips
* Inspired by the original jQuery.tipsy by Jason Frame
* ===========================================================
Expand Down Expand Up @@ -1405,7 +1409,7 @@

}(window.jQuery);
/* ===========================================================
* bootstrap-popover.js v2.3.1
* bootstrap-popover.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#popovers
* ===========================================================
* Copyright 2012 Twitter, Inc.
Expand Down Expand Up @@ -1519,7 +1523,7 @@

}(window.jQuery);
/* =============================================================
* bootstrap-scrollspy.js v2.3.1
* bootstrap-scrollspy.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#scrollspy
* =============================================================
* Copyright 2012 Twitter, Inc.
Expand Down Expand Up @@ -1680,7 +1684,7 @@
})

}(window.jQuery);/* ========================================================
* bootstrap-tab.js v2.3.1
* bootstrap-tab.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#tabs
* ========================================================
* Copyright 2012 Twitter, Inc.
Expand Down Expand Up @@ -1823,7 +1827,7 @@
})

}(window.jQuery);/* =============================================================
* bootstrap-typeahead.js v2.3.1
* bootstrap-typeahead.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#typeahead
* =============================================================
* Copyright 2012 Twitter, Inc.
Expand Down Expand Up @@ -2158,7 +2162,7 @@

}(window.jQuery);
/* ==========================================================
* bootstrap-affix.js v2.3.1
* bootstrap-affix.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#affix
* ==========================================================
* Copyright 2012 Twitter, Inc.
Expand Down
1 change: 1 addition & 0 deletions yii/base/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ public function createController($route)
if ($route === '') {
$route = $this->defaultRoute;
}
$route = trim($route, '/');
if (($pos = strpos($route, '/')) !== false) {
$id = substr($route, 0, $pos);
$route = substr($route, $pos + 1);
Expand Down
37 changes: 24 additions & 13 deletions yii/base/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ class View extends Component
* This means the location is at the end of the body section.
*/
const POS_END = 3;
/**
* The location of registered JavaScript code block.
* This means the JavaScript code block will be enclosed within `jQuery(document).ready()`.
*/
const POS_READY = 4;
/**
* This is internally used as the placeholder for receiving the content registered for the head section.
*/
Expand Down Expand Up @@ -609,7 +614,7 @@ public function registerLinkTag($options, $key = null)
*/
public function registerCss($css, $options = array(), $key = null)
{
$key = $key ?: $css;
$key = $key ?: md5($css);
$this->css[$key] = Html::style($css, $options);
}

Expand All @@ -630,24 +635,26 @@ public function registerCssFile($url, $options = array(), $key = null)
/**
* Registers a JS code block.
* @param string $js the JS code block to be registered
* @param array $options the HTML attributes for the script tag. A special option
* named "position" is supported which specifies where the JS script tag should be inserted
* in a page. The possible values of "position" are:
* @param integer $position the position at which the JS script tag should be inserted
* in a page. The possible values are:
*
* - [[POS_HEAD]]: in the head section
* - [[POS_BEGIN]]: at the beginning of the body section
* - [[POS_END]]: at the end of the body section
* - [[POS_READY]]: enclosed within jQuery(document).ready(). This is the default value.
* Note that by using this position, the method will automatically register the jquery js file.
*
* @param string $key the key that identifies the JS code block. If null, it will use
* $js as the key. If two JS code blocks are registered with the same key, the latter
* will overwrite the former.
*/
public function registerJs($js, $options = array(), $key = null)
public function registerJs($js, $position = self::POS_READY, $key = null)
{
$position = isset($options['position']) ? $options['position'] : self::POS_END;
unset($options['position']);
$key = $key ?: $js;
$this->js[$position][$key] = Html::script($js, $options);
$key = $key ?: md5($js);
$this->js[$position][$key] = $js;
if ($position === self::POS_READY) {
$this->registerAssetBundle('yii/jquery');
}
}

/**
Expand All @@ -659,7 +666,7 @@ public function registerJs($js, $options = array(), $key = null)
*
* - [[POS_HEAD]]: in the head section
* - [[POS_BEGIN]]: at the beginning of the body section
* - [[POS_END]]: at the end of the body section
* - [[POS_END]]: at the end of the body section. This is the default value.
*
* @param string $key the key that identifies the JS script file. If null, it will use
* $url as the key. If two JS files are registered with the same key, the latter
Expand Down Expand Up @@ -697,7 +704,7 @@ protected function renderHeadHtml()
$lines[] = implode("\n", $this->jsFiles[self::POS_HEAD]);
}
if (!empty($this->js[self::POS_HEAD])) {
$lines[] = implode("\n", $this->js[self::POS_HEAD]);
$lines[] = Html::script(implode("\n", $this->js[self::POS_HEAD]), array('type' => 'text/javascript'));
}
return empty($lines) ? '' : implode("\n", $lines) . "\n";
}
Expand All @@ -714,7 +721,7 @@ protected function renderBodyBeginHtml()
$lines[] = implode("\n", $this->jsFiles[self::POS_BEGIN]);
}
if (!empty($this->js[self::POS_BEGIN])) {
$lines[] = implode("\n", $this->js[self::POS_BEGIN]);
$lines[] = Html::script(implode("\n", $this->js[self::POS_BEGIN]), array('type' => 'text/javascript'));
}
return empty($lines) ? '' : implode("\n", $lines) . "\n";
}
Expand All @@ -731,7 +738,11 @@ protected function renderBodyEndHtml()
$lines[] = implode("\n", $this->jsFiles[self::POS_END]);
}
if (!empty($this->js[self::POS_END])) {
$lines[] = implode("\n", $this->js[self::POS_END]);
$lines[] = Html::script(implode("\n", $this->js[self::POS_END]), array('type' => 'text/javascript'));
}
if (!empty($this->js[self::POS_READY])) {
$js = "jQuery(document).ready(function(){\n{" . implode("\n", $this->js[self::POS_READY]) . "}\n});";
$lines[] = Html::script($js, array('type' => 'text/javascript'));
}
return empty($lines) ? '' : implode("\n", $lines) . "\n";
}
Expand Down
Loading

0 comments on commit 8101b5e

Please sign in to comment.