back to bs2

This commit is contained in:
mdipierro
2014-03-02 17:17:21 -06:00
parent 379db55111
commit 29042f08a1
23 changed files with 637 additions and 951 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-6
View File
@@ -1,6 +0,0 @@
/*! Respond.js v1.4.2: min/max-width media query polyfill
* Copyright 2014 Scott Jehl
* Licensed under MIT
* http://j.mp/respondjs */
!function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='&shy;<style media="'+a+'"> #mq-test-1 { width: 42px; }</style>',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){v(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))},g=function(a){return a.replace(c.regex.minmaxwh,"").match(c.regex.other)};if(c.ajax=f,c.queue=d,c.unsupportedmq=g,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,comments:/\/\*[^*]*\*+([^/][^*]*\*+)*\//gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,maxw:/\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,minmaxwh:/\(\s*m(in|ax)\-(height|width)\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/gi,other:/\([^\)]*\)/g},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var h,i,j,k=a.document,l=k.documentElement,m=[],n=[],o=[],p={},q=30,r=k.getElementsByTagName("head")[0]||l,s=k.getElementsByTagName("base")[0],t=r.getElementsByTagName("link"),u=function(){var a,b=k.createElement("div"),c=k.body,d=l.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=k.createElement("body"),c.style.background="none"),l.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&l.insertBefore(c,l.firstChild),a=b.offsetWidth,f?l.removeChild(c):c.removeChild(b),l.style.fontSize=d,e&&(c.style.fontSize=e),a=j=parseFloat(a)},v=function(b){var c="clientWidth",d=l[c],e="CSS1Compat"===k.compatMode&&d||k.body[c]||d,f={},g=t[t.length-1],p=(new Date).getTime();if(b&&h&&q>p-h)return a.clearTimeout(i),i=a.setTimeout(v,q),void 0;h=p;for(var s in m)if(m.hasOwnProperty(s)){var w=m[s],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?j||u():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?j||u():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(n[w.rules]))}for(var C in o)o.hasOwnProperty(C)&&o[C]&&o[C].parentNode===r&&r.removeChild(o[C]);o.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=k.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,r.insertBefore(E,g.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(k.createTextNode(F)),o.push(E)}},w=function(a,b,d){var e=a.replace(c.regex.comments,"").replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var h=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},i=!f&&d;b.length&&(b+="/"),i&&(f=1);for(var j=0;f>j;j++){var k,l,o,p;i?(k=d,n.push(h(a))):(k=e[j].match(c.regex.findStyles)&&RegExp.$1,n.push(RegExp.$2&&h(RegExp.$2))),o=k.split(","),p=o.length;for(var q=0;p>q;q++)l=o[q],g(l)||m.push({media:l.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:n.length-1,hasquery:l.indexOf("(")>-1,minw:l.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:l.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}v()},x=function(){if(d.length){var b=d.shift();f(b.href,function(c){w(c,b.href,b.media),p[b.href]=!0,a.setTimeout(function(){x()},0)})}},y=function(){for(var b=0;b<t.length;b++){var c=t[b],e=c.href,f=c.media,g=c.rel&&"stylesheet"===c.rel.toLowerCase();e&&g&&!p[e]&&(c.styleSheet&&c.styleSheet.rawCssText?(w(c.styleSheet.rawCssText,e,f),p[e]=!0):(!/^([a-zA-Z:]*\/\/)/.test(e)&&!s||e.replace(RegExp.$1,"").split("/")[0]===a.location.host)&&("//"===e.substring(0,2)&&(e=a.location.protocol+e),d.push({href:e,media:f})))}x()};y(),c.update=y,c.getEmValue=u,a.addEventListener?a.addEventListener("resize",b,!1):a.attachEvent&&a.attachEvent("onresize",b)}}(this);
@@ -1,253 +0,0 @@
/*!
* part of the package to convert web2py elements to bootstrap3 theme
* Developed by Paolo Caruccio ( paolo.caruccio66@gmail.com )
* Released under MIT license
* version 1 rev.201402261600
*
* Supported version of bootstrap framework: 3.0.2+
* The full package includes:
* - bootstrap3.py python module
* - web2py-bootstrap3.css
* - this js file
* - example of layout.html
*/
(function ($) {
// bootstrap3 classes for elements of horizontal form - data
var FH_CL_PREFIX = 'col-md-', // class prefix
FH_LABEL_COLW = '4', // nr. of columns of 12
FH_CONTROL_COLW = '8' // 12 - FH_LABEL_COLW;
// bootstrap3 classes for elements of horizontal form - calculations
var fh_label_class = FH_CL_PREFIX + FH_LABEL_COLW,
fh_offest_class = FH_CL_PREFIX+'offset-'+FH_LABEL_COLW,
fh_control_class = FH_CL_PREFIX + FH_CONTROL_COLW;
// functions
function menu_is_collapsed() {
return !$('.navbar-toggle').is(':hidden')
};
function closeSubmenu() {
$(".dropdown-submenu>a.active").each(function(){
var o = $(this);
o.parent().children("ul").toggleClass('open').data('phase', null);
o.toggleClass('active');
});
};
$.fn.center = function (options) {
var defaults = {'parent': false, 'mode': "both"};
var settings = $.extend(defaults, options);
var parent;
if (settings.parent) {
parent = this.parent();
} else {
parent = window;
}
if (settings.mode != "horizontally") {
this.css("top", Math.max(0, (($(parent).height() - $(this).outerHeight()) / 2) + $(parent).scrollTop()) + "px");}
if (settings.mode != "vertically") {
this.css("left", Math.max(0, (($(parent).width() - $(this).outerWidth()) / 2) + $(parent).scrollLeft()) + "px");}
return this;
};
function adjust_maxheight_of_collapsed_nav() {
var cn = $('div.navbar-collapse');
var sh = $(window).height();
if (cn.get(0)) {
if (sh<320) {
cn.addClass('short-screen');
}
else {
cn.removeClass('short-screen');
}
}
};
// alert centering
$('.flash.alert.centered').center({'mode': "horizontally"});
// navs
$(".nav ul.dropdown-menu").not("#w2p-auth-bar").each(function() {
var toggle = $(this).parent();
if (toggle.parent().hasClass("nav")) {
toggle.attr("data-w2pmenulevel", "l0");
toggle.children("a")
.addClass("dropdown-toggle")
.append('<span class="caret"> </span>')
.attr("data-toggle", "dropdown");
} else {
toggle.addClass("dropdown-submenu").removeClass("dropdown");
};
});
$('.navbar-nav a.dropdown-toggle').click(function(e) {
if (menu_is_collapsed()) {
e.preventDefault();
}else{
window.location=$(this).attr('href');
};
});
$(".dropdown-submenu>a").click(function(event) {
if (menu_is_collapsed()) {
event.preventDefault();
event.stopPropagation();
var submenu = $(this).parent().children("ul");
submenu.data('phase','opening');
var dropdownOfThis = $(this).parent().parent();
var actives = dropdownOfThis.find('ul.dropdown-menu.open');
if (actives && actives.length) {
var hasData = actives.data('phase');
if (hasData && hasData=='opened') {
actives.removeClass('open');
actives.siblings('a.active').removeClass('active');
hasData || actives.data('phase', null);
};
};
submenu.toggleClass('open').data('phase','opened');
$(this).toggleClass('active');
}else{
window.location=$(this).attr('href');
};
});
$(".nav-tabs .web2py-menu-active").addClass('active');
$(".nav-tabs a").not(".dropdown-toggle").attr("data-toggle", "tab");
// form fixes
$(document).ready(function() {
$("form.bs3-form .w2p_list a").each(function() {
// the plus and minus buttons are generated by web2py.js
$(this).addClass('btn btn-default');
});
$("form.bs3-form p.w2p-autocomplete-widget").each(function() {
// not generated by formstyle
$(this).children('input').addClass('form-control');
});
$("form.bs3-form input[name='password_two']").each(function() {
// auth addition after form creation
var $this = $(this).addClass('form-control');
var groupClass = 'form-group'
var labelClass = 'control-label';
var commentClass = 'help-block';
var comment;
var mode;
var hasError = false;
if ($this.parent().hasClass('form-horizontal')) {
mode = 'horizontal';
labelClass = fh_label_class+' control-label';
};
if ($this.parent().hasClass('form-inline')) {
mode = 'inline';
labelClass = 'sr-only';
commentClass = 'sr-only';
var labelText = $this.prev('label').text();
$this.attr("placeholder", labelText.slice(0,-2));
};
var error = $this.next('div.error_wrapper');
if (error.length > 0) {
var hasError = true;
groupClass = 'form-group has-error'
var text = error[0].nextSibling.nodeValue;
if (text) {
comment = "<span class='"+commentClass+"'>"+text+"</span>";
error[0].parentNode.removeChild(error[0].nextSibling);
};
} else {
var text = $this[0].nextSibling.nodeValue;
if (text) {
comment = "<span class='"+commentClass+"'>"+text+"</span>";
$this[0].parentNode.removeChild($this[0].nextSibling);
};
};
$this.prev('label').addClass(labelClass).andSelf().wrapAll("<div class='"+groupClass+"' id='auth_user_verify_password__row'></div>");
if (mode == 'horizontal') {
$this.wrap('<div class="'+fh_control_class+'"></div>');
};
if (hasError) {
$this.parent().append(error);
};
$this.parent().append(comment);
});
$('form.bs3-form #auth_user_remember').each(function() {
// auth addition after form creation
var $input = $(this);
var $label = $input.next('label');
var $iParent = $input.parent();
$input.removeClass('checkbox');
$iParent.prev('label').remove();
$input.prependTo($label);
var newGroup = $label;
$iParent.replaceWith(newGroup);
if (newGroup.parent().hasClass('form-horizontal')) {
newGroup.wrap($('<div class="form-group"><div class="'+fh_offest_class+' '+fh_control_class+'"><div class="checkbox"></div></div></div>'));
} else {
newGroup.wrap($('<div class="form-group"><div class="checkbox"></div></div>'));
};
});
});
// form errors
$('form.bs3-form .error_wrapper').each(function() {
var $this = $(this)
var rcContainer = $this.parents('.rc_container');
if (rcContainer.length > 0) {
$this.appendTo(rcContainer);
}
});
$('form.bs3-form').find('div.error').addClass('text-danger').closest(".form-group").addClass('has-error');
// uploadwidget
$('#file-reset-btn').click(function() {
var el = $('div.w2p-uploaded-file')[0];
var whatReset = jQuery.data(el, "reset");
if (whatReset == "changed") {
$('.w2p-uploaded-file input[type="file"]')
.replaceWith(
$('.w2p-uploaded-file input[type="file"]')
.clone());
$('.w2p-file-preview, .w2p-uploaded-file input[type="file"], #edit-btn-dd, #file-reset-btn').toggle();
}else{
$('.w2p-file-preview, #no-file, #edit-btn-dd, #file-reset-btn').toggle();
$('div.w2p-uploaded-file').children('input[type=checkbox]').trigger('click');
}
jQuery.removeData(el, "reset");
});
$('#change-file-option').click(function(e) {
e.preventDefault();
$('.w2p-file-preview, .w2p-uploaded-file input[type="file"], #edit-btn-dd, #file-reset-btn').toggle();
jQuery.data($('div.w2p-uploaded-file')[0], "reset", "changed");
});
$('#delete-file-option').click(function(e) {
e.preventDefault();
var wimg = $('#image-thumb').outerWidth(),
himg = $('#image-thumb').outerHeight();
$('#no-file')
.width(wimg)
.height(himg)
.css({'line-height':himg+'px'});
$('.w2p-file-preview, #no-file, #edit-btn-dd, #file-reset-btn').toggle();
$('div.w2p-uploaded-file').children('input[type=checkbox]').trigger('click');
jQuery.data($('div.w2p-uploaded-file')[0], "reset", "deleted");
});
// on page load
adjust_maxheight_of_collapsed_nav();
// resize and orientation change events
$(window).on('orientationchange resize', function(event) {
adjust_maxheight_of_collapsed_nav();
$('.flash.alert').center({'mode':"horizontally"});
if (menu_is_collapsed() === false) {
closeSubmenu();
$('.navbar-nav .dropdown.open a.dropdown-toggle').dropdown('toggle');
$('#main-menu.in, #login-menu.in').collapse('hide');
};
});
}(jQuery));
+2 -2
View File
@@ -75,8 +75,8 @@
* this over and over... all will be bound to the document
*/
/*adds btn class to buttons*/
$('button', target).addClass('btn').addClass('btn-default');
$('form input[type="submit"], form input[type="button"]', target).addClass('btn').addClass('btn-default');
$('button', target).addClass('btn');
$('form input[type="submit"], form input[type="button"]', target).addClass('btn');
/* javascript for PasswordWidget*/
$('input[type=password][data-w2p_entropy]', target).each(function () {
web2py.validate_entropy($(this));
@@ -0,0 +1,33 @@
// 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');
});
function adjust_height_of_collapsed_nav() {
var cn = jQuery('div.collapse');
if (cn.get(0)) {
var cnh = cn.get(0).style.height;
if (cnh>'0px'){
cn.css('height','auto');
}
}
}
function hoverMenu(){
jQuery('ul.nav a.dropdown-toggle').parent().hover(function(){
adjust_height_of_collapsed_nav();
var mi = jQuery(this).addClass('open');
mi.children('.dropdown-menu').stop(true, true).delay(200).fadeIn(400);
}, function(){
var mi = jQuery(this);
mi.children('.dropdown-menu').stop(true, true).delay(200).fadeOut(function(){mi.removeClass('open')});
});
}
hoverMenu(); // first page load
jQuery(window).resize(hoverMenu); // on resize event
jQuery('ul.nav li.dropdown a').click(function(){window.location=jQuery(this).attr('href');});
});