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