[483] | 1 | define([ |
---|
| 2 | "dojo/_base/declare", |
---|
| 3 | "dojo/_base/lang", |
---|
| 4 | "dojo/dom-class", |
---|
| 5 | "dojo/dom-construct", |
---|
| 6 | "./iconUtils" |
---|
| 7 | ], function(declare, lang, domClass, domConstruct, iconUtils){ |
---|
| 8 | |
---|
| 9 | // module: |
---|
| 10 | // dojox/mobile/Icon |
---|
| 11 | |
---|
| 12 | return declare("dojox.mobile.Icon", null, { |
---|
| 13 | // summary: |
---|
| 14 | // A wrapper for image icon, CSS sprite icon, or DOM Button. |
---|
| 15 | // description: |
---|
| 16 | // Icon is a simple utility class for creating an image icon, a CSS sprite icon, |
---|
| 17 | // or a DOM Button. It calls dojox/mobile/iconUtils.createIcon() with the |
---|
| 18 | // appropriate parameters to create an icon. |
---|
| 19 | // Note that this module is not a widget, that is it does not inherit |
---|
| 20 | // from dijit/_WidgetBase. |
---|
| 21 | // example: |
---|
| 22 | // Image icon: |
---|
| 23 | // | <div data-dojo-type="dojox.mobile.Icon" |
---|
| 24 | // | data-dojo-props='icon:"images/tab-icon-12h.png"'></div> |
---|
| 25 | // |
---|
| 26 | // CSS sprite icon: |
---|
| 27 | // | <div data-dojo-type="dojox.mobile.Icon" |
---|
| 28 | // | data-dojo-props='icon:"images/tab-icons.png",iconPos:"29,116,29,29"'></div> |
---|
| 29 | // |
---|
| 30 | // DOM Button: |
---|
| 31 | // | <div data-dojo-type="dojox.mobile.Icon" |
---|
| 32 | // | data-dojo-props='icon:"mblDomButtonBlueCircleArrow"'></div> |
---|
| 33 | |
---|
| 34 | // icon: [const] String |
---|
| 35 | // An icon to display. The value can be either a path for an image |
---|
| 36 | // file or a class name of a DOM button. |
---|
| 37 | // Note that changing the value of the property after the icon |
---|
| 38 | // creation has no effect. |
---|
| 39 | icon: "", |
---|
| 40 | |
---|
| 41 | // iconPos: [const] String |
---|
| 42 | // The position of an aggregated icon. IconPos is comma separated |
---|
| 43 | // values like top,left,width,height (ex. "0,0,29,29"). |
---|
| 44 | // Note that changing the value of the property after the icon |
---|
| 45 | // creation has no effect. |
---|
| 46 | iconPos: "", |
---|
| 47 | |
---|
| 48 | // alt: [const] String |
---|
| 49 | // An alt text for the icon image. |
---|
| 50 | // Note that changing the value of the property after the icon |
---|
| 51 | // creation has no effect. |
---|
| 52 | alt: "", |
---|
| 53 | |
---|
| 54 | // tag: String |
---|
| 55 | // The name of the HTML tag to create as this.domNode. |
---|
| 56 | tag: "div", |
---|
| 57 | |
---|
| 58 | constructor: function(/*Object?*/args, /*DomNode?*/node){ |
---|
| 59 | // summary: |
---|
| 60 | // Creates a new instance of the class. |
---|
| 61 | // args: |
---|
| 62 | // Contains properties to be set. |
---|
| 63 | // node: |
---|
| 64 | // The DOM node. If none is specified, it is automatically created. |
---|
| 65 | if(args){ |
---|
| 66 | lang.mixin(this, args); |
---|
| 67 | } |
---|
| 68 | this.domNode = node || domConstruct.create(this.tag); |
---|
| 69 | iconUtils.createIcon(this.icon, this.iconPos, null, this.alt, this.domNode); |
---|
| 70 | } |
---|
| 71 | }); |
---|
| 72 | }); |
---|