| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta http-equiv="Content-type" content="text/html; charset=utf-8"/> |
| 5 | <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/> |
| 6 | <meta name="apple-mobile-web-app-capable" content="yes"/> |
| 7 | <title>Dynamic Icons</title> |
| 8 | |
| 9 | <link href="../../../dijit/themes/tundra/tundra.css" rel="stylesheet"/> |
| 10 | <script type="text/javascript" src="../deviceTheme.js" data-dojo-config="mblThemeFiles: ['base','Button','IconContainer']"></script> |
| 11 | <script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="async: false, parseOnLoad: true"></script> |
| 12 | |
| 13 | <script type="text/javascript"> |
| 14 | require([ |
| 15 | "dojo/_base/connect", |
| 16 | "dojo/dom", |
| 17 | "dojo/ready", |
| 18 | "dijit/registry", |
| 19 | "dojox/mobile/IconItem", |
| 20 | "dojox/mobile/IconContainer", |
| 21 | "dojox/mobile/Button", |
| 22 | "dojox/mobile/parser", |
| 23 | "dojox/mobile", |
| 24 | "dojox/mobile/compat" |
| 25 | ], function(connect, dom, ready, registry, IconItem){ |
| 26 | ready(function(){ |
| 27 | var iconContainer = registry.byId("ic1"); |
| 28 | addIcon = function(e){ |
| 29 | var item = new IconItem({ |
| 30 | icon: "images/icon-1.png", |
| 31 | label: dom.byId("label").value || "new icon", |
| 32 | lazy: true |
| 33 | }); |
| 34 | var s = dom.byId("addIndex").value; |
| 35 | var index = s ? s - 0 : undefined; |
| 36 | iconContainer.addChild(item, index); |
| 37 | item.containerNode.innerHTML = "<div data-dojo-type='dijit._Calendar'></div>"; |
| 38 | }; |
| 39 | removeIcon = function(e){ |
| 40 | var index = dom.byId("removeIndex").value - 0; |
| 41 | iconContainer.removeChild(index); |
| 42 | }; |
| 43 | openIcon = function(e){ |
| 44 | var index = dom.byId("openIndex").value - 0; |
| 45 | iconContainer.getChildren()[index].open(); |
| 46 | }; |
| 47 | closeIcon = function(e){ |
| 48 | var index = dom.byId("closeIndex").value - 0; |
| 49 | iconContainer.getChildren()[index].close(); |
| 50 | }; |
| 51 | closeAll = function(e){ |
| 52 | iconContainer.closeAll(); |
| 53 | }; |
| 54 | }); |
| 55 | }); |
| 56 | </script> |
| 57 | |
| 58 | <style> |
| 59 | .box { |
| 60 | border: 1px solid #A7C0E0; |
| 61 | width: 300px; |
| 62 | height: 250px; |
| 63 | background-image: url(images/widget-bg.png); |
| 64 | background-repeat: no-repeat; |
| 65 | background-color: white; |
| 66 | } |
| 67 | </style> |
| 68 | </head> |
| 69 | <body style="visibility:hidden;" class="tundra"> |
| 70 | <div id="myhome" data-dojo-type="dojox.mobile.View" data-dojo-props='selected:true'> |
| 71 | <table> |
| 72 | <tr><td><input type="button" onclick="addIcon()" value="Add" style="width:70px"></td><td> index:<input id="addIndex" style="width:20px;text-align:right"></td><td> label:<input id="label" value="new icon" style="width:80px"></td> |
| 73 | <tr><td><input type="button" onclick="removeIcon()" value="Remove" style="width:70px"></td><td> index:<input id="removeIndex" style="width:20px;text-align:right" value="0"></td><td></td> |
| 74 | <tr><td><input type="button" onclick="openIcon()" value="Open" style="width:70px"></td><td> index:<input id="openIndex" style="width:20px;text-align:right" value="0"></td><td></td> |
| 75 | <tr><td><input type="button" onclick="closeIcon()" value="Close" style="width:70px"></td><td> index:<input id="closeIndex" style="width:20px;text-align:right" value="0"></td><td></td> |
| 76 | <tr><td><input type="button" onclick="closeAll()" value="CloseAll" style="width:70px"></td><td></td><td></td> |
| 77 | </table> |
| 78 | <ul id="ic1" data-dojo-type="dojox.mobile.IconContainer"> |
| 79 | <li data-dojo-type="dojox.mobile.IconItem" data-dojo-props='label:"test1", icon:"images/icon-1.png", lazy:true'><div class="box"></div></li> |
| 80 | </ul> |
| 81 | </div> |
| 82 | </body> |
| 83 | </html> |