deviceTheme.js
2.92 KB
//>>built
("undefined"===typeof define?function(e,a){a()}:define)(["dojo/_base/config","dojo/_base/lang","dojo/_base/window","require"],function(e,a,g,r){var d=a&&a.getObject("dojox.mobile",!0)||{};a=new function(){g||(g=window,g.doc=document,g._no_dojo_dm=d);e=e||g.mblConfig||{};for(var a=g.doc.getElementsByTagName("script"),n=0;n<a.length;n++){var p=a[n],m=p.getAttribute("src")||"";if(m.match(/\/deviceTheme\.js/i)){e.baseUrl=m.replace("deviceTheme.js","../../dojo/");if(a=p.getAttribute("data-dojo-config")||
p.getAttribute("djConfig")){var a=eval("({ "+a+" })"),q;for(q in a)e[q]=a[q]}break}else if(m.match(/\/dojo\.js/i)){e.baseUrl=m.replace("dojo.js","");break}}this.loadCssFile=function(a){var b=g.doc.createElement("link");b.href=a;b.type="text/css";b.rel="stylesheet";a=g.doc.getElementsByTagName("head")[0];a.insertBefore(b,a.firstChild);d.loadedCssFiles.push(b)};this.toUrl=function(a){return r?r.toUrl(a):e.baseUrl+"../"+a};this.setDm=function(a){d=a};this.themeMap=e.themeMap||[["Holodark","holodark",
[]],["Android [3-9]","holodark",[]],["Android","android",[]],["BlackBerry","blackberry",[]],["BB10","blackberry",[]],["ios7","ios7",[]],["iPhone;.*OS ([7-9]|1[0-9])_","ios7",[]],["iPad;.*OS ([7-9]|1[0-9])_","ios7",[]],["iPhone","iphone",[]],["iPad","iphone",[this.toUrl("dojox/mobile/themes/iphone/ipad.css")]],["WindowsPhone","windows",[]],["Windows Phone","windows",[]],["Trident","ios7",[]],["Custom","custom",[]],[".*","ios7",[]]];d.loadedCssFiles=[];this.loadDeviceTheme=function(a){var b=e.mblThemeFiles||
d.themeFiles||["@theme"],f,c;c=this.themeMap;var h=a||e.mblUserAgent||(location.search.match(/theme=(\w+)/)?RegExp.$1:navigator.userAgent);for(f=0;f<c.length;f++)if(h.match(new RegExp(c[f][0]))){var k=c[f][1];if("windows"!=k||!e.mblDisableWindowsTheme){h=g.doc.documentElement.className;h=h.replace(new RegExp(" *"+d.currentTheme+"_theme"),"")+" "+k+"_theme";g.doc.documentElement.className=h;d.currentTheme=k;f=[].concat(c[f][2]);for(c=0;c<b.length;c++){var l=b[c]instanceof Array||"array"==typeof b[c];
l||-1===b[c].indexOf("/")?(h=l?(b[c][0]||"").replace(/\./g,"/"):"dojox/mobile",l=(l?b[c][1]:b[c]).replace(/\./g,"/"),h=h+"/"+("themes/"+k+"/"+("@theme"===l?k:l)+".css")):h=b[c];f.unshift(this.toUrl(h))}for(b=0;b<d.loadedCssFiles.length;b++)k=d.loadedCssFiles[b],k.parentNode.removeChild(k);d.loadedCssFiles=[];for(c=0;c<f.length;c++)b=f[c].toString(),1==e["dojo-bidi"]&&-1==b.indexOf("_rtl")&&(k=b.substr(b.lastIndexOf("/")+1),-1!="android.css blackberry.css custom.css iphone.css holodark.css base.css Carousel.css ComboBox.css IconContainer.css IconMenu.css ListItem.css RoundRectCategory.css SpinWheel.css Switch.css TabBar.css ToggleButton.css ToolBarButton.css ProgressIndicator.css Accordion.css GridLayout.css FormLayout.css".indexOf(k)&&
this.loadCssFile(b.replace(".css","_rtl.css"))),this.loadCssFile(f[c].toString());a&&d.loadCompatCssFiles&&d.loadCompatCssFiles();break}}}};a.loadDeviceTheme();return window.deviceTheme=d.deviceTheme=a});