-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmetawidget-bootstrap.min.js
16 lines (15 loc) · 5.29 KB
/
metawidget-bootstrap.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Metawidget 4.2 minified
//
// This file is dual licensed under both the LGPL
// (http://www.gnu.org/licenses/lgpl-2.1.html) and the EPL
// (http://www.eclipse.org/org/documents/epl-v10.php). As a
// recipient of Metawidget, you may choose to receive it under either
// the LGPL or the EPL.
//
// Commercial licenses are also available. See http://metawidget.org
// for details.
//
// Author: Richard Kennard (http://kennardconsulting.com)
var metawidget=metawidget||{};(function(){metawidget.bootstrap=metawidget.bootstrap||{};metawidget.bootstrap.widgetprocessor=metawidget.bootstrap.widgetprocessor||{};metawidget.bootstrap.widgetprocessor.BootstrapWidgetProcessor=function(a){if(!(this instanceof metawidget.bootstrap.widgetprocessor.BootstrapWidgetProcessor)){throw new Error("Constructor called as a function")}var b=a!==undefined?a.version:3;this.processWidget=function(i,n,g,m){var e=i.tagName;if(e==="TABLE"){metawidget.util.appendToAttribute(i,"class","table table-striped table-bordered table-hover")}else{if(e==="SELECT"||e==="TEXTAREA"){metawidget.util.appendToAttribute(i,"class","form-control")}else{if(e==="OUTPUT"){metawidget.util.appendToAttribute(i,"style","padding:6px 12px",";")}else{if(e==="INPUT"){var j=i.getAttribute("type");switch(j){case"submit":metawidget.util.appendToAttribute(i,"class","btn btn-primary");break;case"button":metawidget.util.appendToAttribute(i,"class","btn btn-default");break;default:if(j!=="checkbox"){metawidget.util.appendToAttribute(i,"class","form-control")}if(g.inputPrepend!==undefined||g.inputAppend!==undefined){var c=metawidget.util.createElement(m,"div");var l;if(g.inputPrepend!==undefined){c.setAttribute("class","input-prepend input-group");l=metawidget.util.createElement(m,"span");l.setAttribute("class","add-on input-group-addon");l.innerHTML=g.inputPrepend;c.appendChild(l)}c.appendChild(i);if(g.inputAppend!==undefined){if(g.inputPrepend!==undefined){c.setAttribute("class","input-prepend input-append input-group")}else{c.setAttribute("class","input-append input-group")}l=metawidget.util.createElement(m,"span");l.setAttribute("class","add-on input-group-addon");l.innerHTML=g.inputAppend;c.appendChild(l)}return c}}}else{if(b===3&&e==="DIV"&&g["enum"]!==undefined&&(g.type==="array"||g.componentType!==undefined)){for(var h=0,d=i.childNodes.length;h<d;h++){var k=i.childNodes[h];var f=metawidget.util.createElement(m,"div");f.setAttribute("class",k.getAttribute("class"));
k.removeAttribute("class");i.replaceChild(f,k);f.appendChild(k)}}}}}}return i}};metawidget.bootstrap.layout=metawidget.bootstrap.layout||{};metawidget.bootstrap.layout.BootstrapDivLayout=function(b){if(!(this instanceof metawidget.bootstrap.layout.BootstrapDivLayout)){throw new Error("Constructor called as a function")}if(b===undefined){b={}}if(b.version===2){if(b.divStyleClasses===undefined){b.divStyleClasses=["control-group",undefined,"controls"]}if(b.labelStyleClass===undefined){b.labelStyleClass="control-label"}}else{if(b.divStyleClasses===undefined){b.divStyleClasses=["form-group","col-sm-2 control-label","col-sm-10"]}if(b.widgetDivSpanAllClass===undefined){b.widgetDivSpanAllClass="col-sm-12"}if(b.widgetDivOffsetClass===undefined){b.widgetDivOffsetClass="col-sm-offset-2"}if(b.suppressLabelSuffixOnCheckboxes===undefined){b.suppressLabelSuffixOnCheckboxes=true}if(b.wrapInsideLabels===undefined){b.wrapInsideLabels=["checkbox","radio"]}if(b.wrapWithExtraDiv===undefined){b.wrapWithExtraDiv={checkbox:"checkbox",radio:"radio"}}}var c=new metawidget.layout.DivLayout(b);if(b.version!==2){var a=c.layoutWidget;c.layoutWidget=function(h,d,f,e,i){a.call(this,h,d,f,e,i);var g=e.childNodes[e.childNodes.length-1];if(g!==undefined&&g.childNodes.length===1){if(f.title===null){g.childNodes[0].setAttribute("class",b.widgetDivSpanAllClass)}else{metawidget.util.appendToAttribute(g.childNodes[0],"class",b.widgetDivOffsetClass)}}}}return c};metawidget.bootstrap.layout.TabLayoutDecorator=function(a){if(!(this instanceof metawidget.bootstrap.layout.TabLayoutDecorator)){throw new Error("Constructor called as a function")}metawidget.layout.createNestedSectionLayoutDecorator(a,this,"bootstrapTabLayoutDecorator")};metawidget.bootstrap.layout.TabLayoutDecorator.prototype.createSectionWidget=function(j,k,e,b,m){var h=j;var g,f;if(h===undefined){h=metawidget.util.createElement(m,"div");h.setAttribute("id",metawidget.util.getId("property",e,m)+"-tabs");h.setAttribute("class","tabs");g=metawidget.util.createElement(m,"ul");
g.setAttribute("class","nav nav-tabs");h.appendChild(g);f=metawidget.util.createElement(m,"div");f.setAttribute("class","tab-content");h.appendChild(f);this.getDelegate().layoutWidget(h,"property",{wide:"true"},b,m);m.bootstrapTabLayoutDecorator=m.bootstrapTabLayoutDecorator||[];m.bootstrapTabLayoutDecorator.push(h)}else{h=j.parentNode.parentNode}g=h.childNodes[0];var c=h.getAttribute("id")+(g.childNodes.length+1);var l=metawidget.util.createElement(m,"li");if(g.childNodes.length===0){l.setAttribute("class","active")}var i=metawidget.util.createElement(m,"a");i.setAttribute("data-toggle","tab");i.setAttribute("href","#"+c);i.setAttribute("target","_self");l.appendChild(i);g.appendChild(l);f=h.childNodes[1];var d=metawidget.util.createElement(m,"div");if(f.childNodes.length===0){d.setAttribute("class","tab-pane active")}else{d.setAttribute("class","tab-pane")}d.setAttribute("id",c);f.appendChild(d);i.innerHTML=k;return d}})();