moved layout.js in web2py_bootstrap.js and include_files(extensions=[...]), thanks Jeremy

This commit is contained in:
mdipierro
2012-09-23 14:37:50 -05:00
parent d8417955b3
commit 68f63dc89b
4 changed files with 40 additions and 31 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.0.9 (2012-09-23 14:07:45) stable
Version 2.0.9 (2012-09-23 14:37:46) stable
@@ -0,0 +1,23 @@
// this code improves bootstrap menus and adds dropdown support
jQuery(function(){
jQuery('.nav>li>a').each(function(){
if(jQuery(this).parent().find('ul').length)
jQuery(this).attr({'class':'dropdown-toggle','data-toggle':'dropdown'}).append('<b class="caret"></b>');
});
jQuery('.nav li li').each(function(){
if(jQuery(this).find('ul').length)
jQuery(this).addClass('dropdown-submenu');
});
if(jQuery(document).width()>=980) {
jQuery('ul.nav a.dropdown-toggle').parent().hover(function() {
mi = jQuery(this).addClass('open');
mi.children('.dropdown-menu').stop(true, true).delay(200).fadeIn(400);
}, function() {
mi = jQuery(this);
mi.children('.dropdown-menu').stop(true, true).delay(200).fadeOut(function(){mi.removeClass('open')});
});
}
jQuery('ul.nav li.dropdown a').click(function(){window.location=jQuery(this).attr('href');});
// make all buttons bootstrap buttons
jQuery('button, form input[type="submit"], form input[type="button"]').addClass('btn');
});
+2 -26
View File
@@ -39,7 +39,7 @@
<script src="{{=URL('static','js/modernizr.custom.js')}}"></script>
<!-- include stylesheets -->
{{
{{
response.files.append(URL('static','css/web2py.css'))
response.files.append(URL('static','css/bootstrap.min.css'))
response.files.append(URL('static','css/bootstrap-responsive.min.css'))
@@ -146,32 +146,8 @@
<!-- The javascript =============================================
(Placed at the end of the document so the pages load faster) -->
<script>
// this code improves bootstrap menus and adds dropdown support
jQuery(function(){
jQuery('.nav>li>a').each(function(){
if(jQuery(this).parent().find('ul').length)
jQuery(this).attr({'class':'dropdown-toggle','data-toggle':'dropdown'}).append('<b class="caret"></b>');
});
jQuery('.nav li li').each(function(){
if(jQuery(this).find('ul').length)
jQuery(this).addClass('dropdown-submenu');
});
if(jQuery(document).width()>=980) {
jQuery('ul.nav a.dropdown-toggle').parent().hover(function() {
mi = jQuery(this).addClass('open');
mi.children('.dropdown-menu').stop(true, true).delay(200).fadeIn(400);
}, function() {
mi = jQuery(this);
mi.children('.dropdown-menu').stop(true, true).delay(200).fadeOut(function(){mi.removeClass('open')});
});
}
jQuery('ul.nav li.dropdown a').click(function(){window.location=jQuery(this).attr('href');});
// make all buttons bootstrap buttons
jQuery('button, form input[type="submit"], form input[type="button"]').addClass('btn');
});
</script>
<script src="{{=URL('static','js/bootstrap.min.js')}}"></script>
<script src="{{=URL('static','js/web2py_bootstrap.js')}}"></script>
<!--[if lt IE 7 ]>
<script src="{{=URL('static','js/dd_belatedpng.js')}}"></script>
<script> DD_belatedPNG.fix('img, .png_bg'); //fix any <img> or .png_bg background-images </script>
+14 -4
View File
@@ -229,7 +229,7 @@ class Response(Storage):
for k,v in (self.meta or {}).iteritems())
self.write(s,escape=False)
def include_files(self):
def include_files(self, extensions=None):
"""
Caching method for writing out files.
@@ -240,12 +240,22 @@ class Response(Storage):
from gluon import URL
files = []
has_js = has_css = False
for item in self.files:
if not item in files:
files.append(item)
if have_minify and (self.optimize_css or self.optimize_js):
if extensions and not item.split('.')[-1] in extensions:
continue
if item in files:
continue
if item.endswith('.js'):
has_js = True
if item.endswith('.css'):
has_css = True
files.append(item)
if have_minify and ((self.optimize_css and has_css) or (self.optimize_js and has_js)):
# cache for 5 minutes by default
key = hashlib.md5(repr(files)).hexdigest()
cache = self.cache_includes or (current.cache.ram, 60*5)
def call_minify(files=files):
return minify.minify(files,