-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAppTagWidget.js
153 lines (147 loc) · 4.91 KB
/
AppTagWidget.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
define(['dojo/_base/declare',
'dojo/_base/lang',
'dojo/dom-construct',
'dojo/dom',
'dojo/dom-style',
"dijit/_WidgetBase",
"dijit/_TemplatedMixin",
'dojo/html',
"dojo/Deferred",
'dojo/text!./templates/AppTagWidgetTemplate.html',
"dojo/domReady!"], function(declare, lang, domConstruct, dom, domStyle, WidgetBase, TemplatedMixin, html,Deferred, template) {
return declare('AppTagWidget', [WidgetBase, TemplatedMixin], {
//id for AspireWidget.
id: '',
//tag get by user and used by templete
tag:'',
style:'',
//tag value set by user
value:'',
propertyDom:{},
//Some string value of class.
baseClass: 'appTagWidget',
templateString: '',
constructor: function(param) {
attr='',
this.id ='';
this.createWidget();
},
createWidget: function() {
this.templateString = template;
},
postCreate: function() {
this.inherited(arguments);
},
buildRendering: function() {
this.inherited(arguments);
if (!this.widgetNode) {
this.widgetNode = this.domNode;
}
},
startup: function() {
// summary:
// Call startup() on all children including non _Widget ones like dojo/dnd/Source objects
// This starts all the widgets
this.inherited(arguments);
// And this catches stuff like dojo/dnd/Source
if (this._contentSetter) {
array.forEach(this._contentSetter.parseResults, function(obj) {
if (!obj._started && !obj._destroyed && lang.isFunction(obj.startup)) {
obj.startup();
obj._started = true;
}
}, this);
}
},
/**
* funtion to get the value of the widget ie tag value
*/
getValue: function(){
return this.get('value');
},
_getValueAttr:function(value){
this.value=value;
},
_setValueAttr:function(value){
this.value=value;
html.set(this.valueNode,this.value)
},
_getTagAttr:function(value){
return this.tag;
},
_setTagAttr:function(value){
this.tag=value;
},_getIdAttr:function(value){
return this.id;
},
_setIdAttr:function(value){
this.id=value;
},
_setPropertyDomAttr:function(value){
var _this=this;
_this.propertyDom=value;
for(each in value){
_this.valueNode.setAttribute(each,value[each])
}
},
_getPropertyDomAttr:function(){
return this.propertyDom;
},
_setStyleAttr:function(value){
var _this=this;
_this.style=value;
domStyle.set(this.parentNode,_this.style)
/*for(each in value){
_this.valueNode.setAttribute(each,value[each])
}*/
},
_getStyleAttr:function(){
return this.style;
},
/**
* funtion to refresh the widget to effect the value same as startup
*/
/*refresh: function() {
html.set(this.valueNode, this.value)
//this._set(this.tag,this.value)
},*/
getWidgetValue: function() {
var result = this.getValue();
return result;
},
/*addTag: function(tag, options, placeAt) {
if ((typeof tag && typeof placeAt == "String") && (typeof options == 'Object')) {
domConstruct(tag, options, placeAt)
} else {
console.log("error")
}
},*/
addChild: function(widget, insertIndex) {
var refNode = this.widgetNode.children[0];
if (insertIndex && typeof insertIndex == "number") {
var children = this.getChildren();
if (children && children.length >= insertIndex) {
refNode = children[insertIndex - 1].domNode;
insertIndex = 'after';
}
}
domConstruct.place(widget.domNode, refNode, insertIndex);
widget.startup();
},
removeChild: function( /*Widget|integer*/ widget) {
if (typeof widget == "number") {
widget = this.getChildren()[widget];
}
if (widget) {
var node = widget.domNode;
if (node && node.parentNode) {
node.parentNode.removeChild(node); // detach but don't destroy
}
}
},
destroy: function() {
delete this.widgetNode;
this.inherited(arguments);
}
}) //End of Delcare
}) //End of Define