forked from scottdurow/SparkleXrm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp-client-ui.txt
309 lines (308 loc) · 92.7 KB
/
temp-client-ui.txt
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
// SparkleXrmUI.js
window._loadedScripts=window._loadedScripts||{};window._loadedScripts['xrmui']=true;(function($){
Type.registerNamespace('SparkleXrm.CustomBinding');SparkleXrm.CustomBinding.EnterKeyBinding=function(){SparkleXrm.CustomBinding.EnterKeyBinding.initializeBase(this);}
SparkleXrm.CustomBinding.EnterKeyBinding.prototype={init:function(element,valueAccessor,allBindingsAccessor,viewModel,context){ko.utils.registerEventHandler(element,'keydown',function($p1_0,$p1_1){
var $1_0=$p1_0;if($1_0.keyCode===13){$1_0.preventDefault();$1_0.target.blur();valueAccessor().call(viewModel);}});}}
SparkleXrm.CustomBinding.XrmCurrencySymbolBinding=function(){SparkleXrm.CustomBinding.XrmCurrencySymbolBinding.initializeBase(this);}
SparkleXrm.CustomBinding.XrmCurrencySymbolBinding.getCurrencySymbol=function(valueAccessor){var $0=ko.utils.unwrapObservable(valueAccessor());if($0!=null&&$0.id!=null){return SparkleXrm.NumberEx.getCurrencySymbol($0.id);}return '';}
SparkleXrm.CustomBinding.XrmCurrencySymbolBinding.prototype={init:function(element,valueAccessor,allBindingsAccessor,viewModel,context){},update:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=$(element).find('.sparkle-input-currencyprefix-part');var $1=function(){
var $1_0=SparkleXrm.CustomBinding.XrmCurrencySymbolBinding.getCurrencySymbol(valueAccessor);return $1_0;};ko.bindingHandlers.text.update($0.get(0),$1,allBindingsAccessor,viewModel,context);}}
SparkleXrm.CustomBinding.XrmMoneyBinding=function(){SparkleXrm.CustomBinding.XrmMoneyBinding.initializeBase(this);}
SparkleXrm.CustomBinding.XrmMoneyBinding.$1_0=function($p0){var $0=SparkleXrm.NumberEx.getCurrencyEditFormatInfo();if($p0()['minvalue']==null){$0.minValue=-2147483648;}else{$0.minValue=$p0()['minvalue'];}if($p0()['maxvalue']==null){$0.maxValue=2147483647;}else{$0.maxValue=$p0()['maxvalue'];}return $0;}
SparkleXrm.CustomBinding.XrmMoneyBinding.$1_1=function($p0,$p1){if($p0!=null){return SparkleXrm.NumberEx.format($p0.value,$p1);}else{return '';}}
SparkleXrm.CustomBinding.XrmMoneyBinding.$1_2=function($p0,$p1,$p2,$p3){var $0=$p0();var $1=true;var $2=SparkleXrm.NumberEx.parse($p2,$p3);if(!isNaN($2)&&$2>=$p3.minValue&&$2<=$p3.maxValue){var $3=null;if($2!=null){$2=SparkleXrm.NumberEx.round($2,$p3.precision);$3=new SparkleXrm.Sdk.Money($2);}$0($3);if((typeof($0.isValid))!=='undefined'){$1=!!($0).isValid();}if($1){var $4=SparkleXrm.CustomBinding.XrmMoneyBinding.$1_1($3,$p3);$p1.val($4);}}else{alert(String.format('You must enter a number between {0} and {1}',$p3.minValue,$p3.maxValue));var $5=$0();var $6=SparkleXrm.CustomBinding.XrmMoneyBinding.$1_1($5,$p3);$p1.val($6);$p1.focus();}}
SparkleXrm.CustomBinding.XrmMoneyBinding.prototype={init:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=$(element).find('.sparkle-input-textbox-part');var $1=SparkleXrm.CustomBinding.XrmMoneyBinding.$1_0(allBindingsAccessor);var $2=arguments;var $3=function($p1_0){
var $1_0=valueAccessor();var $1_1=$0.val();SparkleXrm.CustomBinding.XrmMoneyBinding.$1_2(valueAccessor,$0,$1_1,$1);};$0.change($3);},update:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=$(element).find('.sparkle-input-textbox-part');var $1=SparkleXrm.CustomBinding.XrmMoneyBinding.$1_0(allBindingsAccessor);var $2=function(){
var $1_0=(valueAccessor())();if($1_0!=null){return SparkleXrm.NumberEx.format($1_0.value,$1);}else{return '';}};ko.bindingHandlers.value.update($0.get(0),$2,allBindingsAccessor,viewModel,context);}}
SparkleXrm.CustomBinding.XrmNumericBinding=function(){SparkleXrm.CustomBinding.XrmNumericBinding.initializeBase(this);}
SparkleXrm.CustomBinding.XrmNumericBinding.$1_0=function($p0){var $0=SparkleXrm.NumberEx.getNumberFormatInfo();$0.precision=parseInt($p0()['precision']);if($p0()['minvalue']==null){$0.minValue=-2147483648;}else{$0.minValue=$p0()['minvalue'];}if($p0()['maxvalue']==null){$0.maxValue=2147483647;}else{$0.maxValue=$p0()['maxvalue'];}return $0;}
SparkleXrm.CustomBinding.XrmNumericBinding.$1_1=function($p0,$p1){if($p0!=null){return SparkleXrm.NumberEx.format($p0,$p1);}else{return '';}}
SparkleXrm.CustomBinding.XrmNumericBinding.$1_2=function($p0,$p1,$p2,$p3){var $0=$p0();var $1=true;var $2=SparkleXrm.NumberEx.parse($p2,$p3);if(!isNaN($2)&&$2>=$p3.minValue&&$2<=$p3.maxValue){if($2!=null){$2=SparkleXrm.NumberEx.round($2,$p3.precision);}$0($2);if((typeof($0.isValid))!=='undefined'){$1=!!($0).isValid();}if($1){var $3=SparkleXrm.CustomBinding.XrmNumericBinding.$1_1($2,$p3);$p1.val($3);}}else{alert(String.format('You must enter a number between {0} and {1}',$p3.minValue,$p3.maxValue));var $4=$0();var $5=SparkleXrm.CustomBinding.XrmNumericBinding.$1_1($4,$p3);$p1.val($5);$p1.focus();}}
SparkleXrm.CustomBinding.XrmNumericBinding.prototype={init:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=$(element).find('.sparkle-input-textbox-part');var $1=SparkleXrm.CustomBinding.XrmNumericBinding.$1_0(allBindingsAccessor);var $2=function($p1_0){
var $1_0=valueAccessor();var $1_1=$0.val();SparkleXrm.CustomBinding.XrmNumericBinding.$1_2(valueAccessor,$0,$1_1,$1);};$0.change($2);},update:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=$(element).find('.sparkle-input-textbox-part');var $1=SparkleXrm.CustomBinding.XrmNumericBinding.$1_0(allBindingsAccessor);var $2=function(){
var $1_0=(valueAccessor())();if($1_0!=null){return SparkleXrm.NumberEx.format($1_0,$1);}else{return '';}};ko.bindingHandlers.value.update($0.get(0),$2,allBindingsAccessor,viewModel,context);}}
SparkleXrm.CustomBinding.XrmOptionSetBinding=function(){SparkleXrm.CustomBinding.XrmOptionSetBinding.initializeBase(this);}
SparkleXrm.CustomBinding.XrmOptionSetBinding.prototype={init:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=$(element).find('.sparkle-input-optionset-part');var $1=function($p1_0){
var $1_0=valueAccessor();var $1_1=$0.val();var $1_2=null;if(!String.isNullOrEmpty($1_1)){$1_2=parseInt($1_1);}var $1_3=new SparkleXrm.Sdk.OptionSetValue($1_2);$1_3.name=$0.find('option:selected').text();$1_0($1_3);};$0.change($1);allBindingsAccessor()['optionsValue']='value';allBindingsAccessor()['optionsText']='name';var $2=(allBindingsAccessor()['optionSetOptions']);var $3;if($2.getOptionSetsDelegate!=null){$3=function(){
return $2.getOptionSetsDelegate(viewModel);};}else{$3=function(){
return SparkleXrm.Sdk.Metadata.MetadataCache.getOptionSetValues($2.entityLogicalName,$2.attributeLogicalName,$2.allowEmpty);};}ko.bindingHandlers.options.update($0.get(0),$3,allBindingsAccessor,viewModel,context);},update:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=$(element).find('.sparkle-input-optionset-part');var $1=valueAccessor();var $2=$1();var $3='';if($2!=null&&$2.value!=null){$3=$2.value.toString();}$0.val($3);}}
SparkleXrm.CustomBinding.AnimateVisible=function(){SparkleXrm.CustomBinding.AnimateVisible.initializeBase(this);}
SparkleXrm.CustomBinding.AnimateVisible.prototype={init:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=valueAccessor();$(element).toggle(ko.utils.unwrapObservable($0));},update:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=valueAccessor();var $1=(allBindingsAccessor()['effectIn']);var $2=(allBindingsAccessor()['effectOut']);var $3=$(element);var $4=(ko.utils.unwrapObservable($0))?$1:$2;switch($4){case 'fadeIn':$3.fadeIn();break;case 'fadeOut':$3.fadeOut();break;case 'slideUp':$3.slideUp();break;case 'slideDown':$3.slideDown();break;}}}
SparkleXrm.CustomBinding.AutocompleteBinding=function(){SparkleXrm.CustomBinding.AutocompleteBinding.initializeBase(this);}
SparkleXrm.CustomBinding.AutocompleteBinding.$1_0=function($p0,$p1,$p2){var $0=$p0();var $1=true;$0($p2);if((typeof($0.isValid))!=='undefined'){$1=!!($0).isValid();}if($1){$p1.blur();}}
SparkleXrm.CustomBinding.AutocompleteBinding.prototype={init:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=$(element);var $1=(allBindingsAccessor()['autocompleteOptions']);$1.position={collision:'fit'};$1.select=function($p1_0,$p1_1){
var $1_0=($p1_1.item)['value'].toString();SparkleXrm.CustomBinding.AutocompleteBinding.$1_0(valueAccessor,$0,$1_0);};$0=$0.autocomplete($1);var $2=$0.siblings('.timeSelectButton');$2.click(function($p1_0){
$0.autocomplete('search');});ko.utils.registerEventHandler(element,'change',function($p1_0,$p1_1){
var $1_0=$0.val();SparkleXrm.CustomBinding.AutocompleteBinding.$1_0(valueAccessor,$0,$1_0);});var $3=function(){
$(element).autocomplete("destroy");};ko.utils.domNodeDisposal.addDisposeCallback(element, $3);ko.bindingHandlers['validationCore'].init(element,valueAccessor,allBindingsAccessor,null,null);},update:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=ko.utils.unwrapObservable(valueAccessor());$(element).val($0);}}
SparkleXrm.CustomBinding.XrmBooleanBinding=function(){SparkleXrm.CustomBinding.XrmBooleanBinding.initializeBase(this);}
SparkleXrm.CustomBinding.XrmBooleanBinding.prototype={init:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=valueAccessor();var $1={};$1.read=function(){
return $0().toString();};$1.write=function($p1_0){
$0($p1_0==='true');};var $2=(allBindingsAccessor()['targetBinding']);var $3={};$3[$2]=ko.computed($1);ko.applyBindingsToNode(element,$3);}}
SparkleXrm.CustomBinding.XrmLookupBinding=function(){SparkleXrm.CustomBinding.XrmLookupBinding.initializeBase(this);}
SparkleXrm.CustomBinding.XrmLookupBinding.$1_0=function($p0){var $0=$p0.data;return $0!=null&&$0!=='footerlink';}
SparkleXrm.CustomBinding.XrmLookupBinding.$1_1=function($p0,$p1,$p2,$p3){if($p0!=null){var $0=[];var $1=true;var $enum1=ss.IEnumerator.getEnumerator($p0);while($enum1.moveNext()){var $2=$enum1.current;if($1){$1=false;continue;}var $3='';var $4=$p1.get_entities().get_item($p3);if(Object.keyExists($4.formattedValues,$2+'name')){$3=$4.formattedValues[$2+'name'];}else{var $5=$4.getAttributeValue($2);if($5!=null){switch(Type.getInstanceType($5).get_name()){case 'EntityReference':$3=($5).name;break;default:$3=$5.toString();break;}}}if($3!=null&&$3.length>0){$0.add($3);}}$p2[$p3].columnValues=$0;}}
SparkleXrm.CustomBinding.XrmLookupBinding.$1_2=function($p0,$p1,$p2,$p3){var $0=$p0();var $1=true;$0($p2);if((typeof($0.isValid))!=='undefined'){$1=!!($0).isValid();}if($1&&$p3){$p1.blur();$p1.focus();}}
SparkleXrm.CustomBinding.XrmLookupBinding.prototype={init:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=allBindingsAccessor()['footerButton'];var $1=allBindingsAccessor()['showFooter'];var $2=$(element);var $3=$2.find('.sparkle-input-lookup-part');var $4=$2.find('.sparkle-input-lookup-button-part');var $5=new SparkleXrm.Sdk.EntityReference(null,null,null);var $6={};$6.minLength=100000;$6.delay=0;$6.position={collision:'fit'};var $7=false;var $8=0;var $9=function($p1_0,$p1_1){
if($5==null){$5=new SparkleXrm.Sdk.EntityReference(null,null,null);}var $1_0=$p1_0.label;$3.val($1_0);$5.id=($p1_0.value);$5.name=$p1_0.label;$5.logicalName=$p1_0.data;$7=true;SparkleXrm.CustomBinding.XrmLookupBinding.$1_2(valueAccessor,$3,$5,$p1_1);};$6.select=function($p1_0,$p1_1){
var $1_0=$p1_1.item;var $1_1=($1_0.data);if($1_1==='footerlink'||$1_1==null){$0.onClick($1_0);$p1_0.preventDefault();$p1_0.stopImmediatePropagation();return false;;}else{$9($1_0,true);return false;;}};$6.open=function($p1_0,$p1_1){
if($1&&$8>0){var $1_0=$3.autocomplete('widget');SparkleXrm.GridEditor.XrmLookupEditor.addFooter($1_0,$8);}};$6.close=function($p1_0,$p1_1){
var $1_0=$3.autocomplete('widget');var $1_1=$1_0.next();if($1_1.length>0||$1_1.hasClass('sparkle-menu-footer')){$1_1.hide();}};var $A=(allBindingsAccessor()['queryCommand']);var $B=(allBindingsAccessor()['nameAttribute']);var $C=(allBindingsAccessor()['idAttribute']);var $D=(allBindingsAccessor()['typeCodeAttribute']);var $E=null;var $F=$B.split(',');if($F.length>1){$E=$F;$B=$E[0];}var $10=function($p1_0,$p1_1){
var $1_0=function($p2_0){
var $2_0=$p2_0.get_entities().get_count();var $2_1=!$2_0;var $2_2=new Array($2_0+(($0!=null)?1:0)+(($2_1)?1:0));for(var $2_5=0;$2_5<$2_0;$2_5++){$2_2[$2_5]={};$2_2[$2_5].label=$p2_0.get_entities().get_item($2_5).getAttributeValue($B);$2_2[$2_5].value=$p2_0.get_entities().get_item($2_5).getAttributeValue($C);$2_2[$2_5].data=$p2_0.get_entities().get_item($2_5).logicalName;SparkleXrm.CustomBinding.XrmLookupBinding.$1_1($E,$p2_0,$2_2,$2_5);var $2_6=$p2_0.get_entities().get_item($2_5).logicalName;if(!String.isNullOrEmpty($D)){$2_6=$p2_0.get_entities().get_item($2_5).getAttributeValue($D).toString();}$2_2[$2_5].image=SparkleXrm.Sdk.Metadata.MetadataCache.getSmallIconUrl($2_6);}if($p2_0.get_totalRecordCount()>$p2_0.get_entities().get_count()){$8=$p2_0.get_totalRecordCount();}else{$8=$p2_0.get_entities().get_count();}var $2_3=$2_0;if($2_1){var $2_7={};$2_7.label=SparkleResourceStrings.NoRecordsFound;$2_2[$2_3]=$2_7;$2_3++;}if($0!=null){var $2_8={};$2_8.label=$0.label;$2_8.image=$0.image;$2_8.columnValues=null;$2_8.data='footerlink';$2_2[$2_3]=$2_8;}$p1_1($2_2);var $2_4={};$2_4.minLength=100000;$3.autocomplete($2_4);};$A.call(context.$parent,$p1_0.term,$1_0);};$6.source=$10;$6.focus=function($p1_0,$p1_1){
return false;;};$3=$3.autocomplete($6);($3.data('ui-autocomplete'))._renderItem=function($p1_0,$p1_1){
if($p1_1.data==null){return $("<li class='ui-state-disabled'>"+$p1_1.label+'</li>').appendTo($p1_0);}var $1_0="<a class='sparkle-menu-item'><span class='sparkle-menu-item-img'>";if($p1_1.image!=null){$1_0+="<img src='"+$p1_1.image+"'/>";}$1_0+="</span><span class='sparkle-menu-item-label'>"+$p1_1.label+'</span><br>';if($p1_1.columnValues!=null&&$p1_1.columnValues.length>0){var $enum1=ss.IEnumerator.getEnumerator($p1_1.columnValues);while($enum1.moveNext()){var $1_1=$enum1.current;$1_0+="<span class='sparkle-menu-item-moreinfo'>"+$1_1+'</span>';}}$1_0+='</a>';return $('<li>').append($1_0).appendTo($p1_0);};$4.click(function($p1_0){
var $1_0={};$1_0.minLength=0;$3.focus();$3.autocomplete($1_0);$3.autocomplete('search');});$3.change(function($p1_0){
var $1_0=$3.val();if($1_0!==$5.name){SparkleXrm.CustomBinding.XrmLookupBinding.$1_2(valueAccessor,$3,null,false);var $1_1={};$1_1.term=$1_0;var $1_2=function($p2_0){
var $2_0=0;if($p2_0!=null){var $enum1=ss.IEnumerator.getEnumerator($p2_0);while($enum1.moveNext()){var $2_1=$enum1.current;if(SparkleXrm.CustomBinding.XrmLookupBinding.$1_0($2_1)){$2_0++;}if($2_0>2){break;}}}if($2_0===1){$9($p2_0[0],false);}else{$3.val('');}};$10($1_1,$1_2);}});var $11=function(){
if($($3).data('ui-autocomplete')!=undefined){$($3).autocomplete("destroy");}};ko.utils.domNodeDisposal.addDisposeCallback(element, $11);ko.bindingHandlers['validationCore'].init(element,valueAccessor,allBindingsAccessor,null,null);$3.keydown(function($p1_0){
if($p1_0.which===13&&!$7){$4.click();}else if($p1_0.which===13){return;}switch($p1_0.which){case 13:case 38:case 40:$p1_0.preventDefault();$p1_0.stopPropagation();break;}$7=false;});},update:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=$(element);var $1=$0.find('.sparkle-input-lookup-part');var $2=ko.utils.unwrapObservable(valueAccessor());var $3='';if($2!=null){$3=$2.name;}$1.val($3);}}
SparkleXrm.CustomBinding.XrmTextBinding=function(){SparkleXrm.CustomBinding.XrmTextBinding.initializeBase(this);}
SparkleXrm.CustomBinding.XrmTextBinding.prototype={init:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=$(element).find('.sparkle-input-textbox-part');var $1=function($p1_0){
var $1_0=valueAccessor();var $1_1=$0.val();$1_0($1_1);};$0.change($1);$0.keyup($1);},update:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=$(element).find('.sparkle-input-textbox-part');ko.bindingHandlers.value.update($0.get(0),valueAccessor,allBindingsAccessor,viewModel,context);}}
SparkleXrm.CustomBinding.XrmDatePickerBinding=function(){SparkleXrm.CustomBinding.XrmDatePickerBinding.initializeBase(this);}
SparkleXrm.CustomBinding.XrmDatePickerBinding.prototype={init:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=(allBindingsAccessor()['dateOptions']);var $1=$(element);var $2=$1.find('.sparkle-input-datepicker-part');var $3=$1.find('.sparkle-input-datepicker-button-part');var $4={};$4.showOn='';$4.buttonImageOnly=true;$4.firstDay=(SparkleXrm.Sdk.OrganizationServiceProxy.organizationSettings!=null)?SparkleXrm.Sdk.OrganizationServiceProxy.organizationSettings.weekstartdaycode.value:0;var $5='dd/MM/yy';if(SparkleXrm.Sdk.OrganizationServiceProxy.userSettings!=null){$5=SparkleXrm.Sdk.OrganizationServiceProxy.userSettings.dateformatstring;}$4.dateFormat=$5;$2.datepicker($4);$3.click(function($p1_0){
$2.datepicker('show');});ko.utils.registerEventHandler($2.get(0),'change',function($p1_0,$p1_1){
var $1_0=valueAccessor();var $1_1=true;if((typeof($1_0.IsValid))!=='undefined'){$1_1=!!($1_0).isValid();}if($1_1){var $1_2=$2.datepicker('getDate');var $1_3=$1_0();if($1_3==null&&$0!=null){$1_3=new Date(1900,1,1,($0.hour!=null)?$0.hour:0,($0.minute!=null)?$0.minute:0);}SparkleXrm.Sdk.DateTimeEx.setTime($1_2,$1_3);$1_0($1_2);}$2.blur();});var $6=function(){
$(element).datepicker("destroy");};ko.utils.domNodeDisposal.addDisposeCallback(element, $6);},update:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=$(element);var $1=$0.find('.sparkle-input-datepicker-part');var $2=ko.utils.unwrapObservable(valueAccessor());if(typeof($2)==='string'){$2=Date.parseDate($2);}$1.datepicker('setDate',$2);}}
SparkleXrm.CustomBinding.XrmDurationBinding=function(){SparkleXrm.CustomBinding.XrmDurationBinding.initializeBase(this);}
SparkleXrm.CustomBinding.XrmDurationBinding.$1_0=function($p0,$p1,$p2){var $0=$p0();var $1=true;var $2=($p2==null)||(!$p2.length);var $3='/([0-9]*)[ ]?((h(our)?[s]?)|(m(inute)?[s]?)|(d(ay)?[s]?))/g';var $4=RegExp.parse($3);var $5=$4.exec($p2);if($2){$0(null);}else if($5!=null&&$5.length>0){var $6=parseFloat($5[1]);switch($5[2].substr(0,1).toLowerCase()){case 'd':$6=$6*60*24;break;case 'h':$6=$6*60;break;}$0($6);if((typeof($0.isValid))!=='undefined'){$1=!!($0).isValid();}if($1){}}else{alert('Invalid Duration Format');var $7=$0();var $8=SparkleXrm.CustomBinding.XrmDurationBinding.$1_1($7);$p1.val($8);$p1.focus();}}
SparkleXrm.CustomBinding.XrmDurationBinding.$1_1=function($p0){var $0=null;if($p0!=null){if($p0>(60*24)){$0=String.format('{0} d',$p0/(60*24));}else if($p0===(60*24)){$0=String.format('{0} d',$p0/(60*24));}else if($p0>60){$0=String.format('{0} h',$p0/(60));}else if($p0===60){$0=String.format('{0} h',$p0/(60));}else{$0=String.format('{0} m',$p0);}}else{$0=null;}return $0;}
SparkleXrm.CustomBinding.XrmDurationBinding.prototype={init:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=$(element);var $1=$0.find('.sparkle-input-duration-part');var $2=$0.find('.sparkle-input-duration-button-part');var $3={};$3.position={collision:'fit'};$3.source=['1 m','2 m','1 h','2 h','1 d'];$3.delay=0;$3.minLength=0;$3.select=function($p1_0,$p1_1){
var $1_0=($p1_1.item)['value'].toString();SparkleXrm.CustomBinding.XrmDurationBinding.$1_0(valueAccessor,$1,$1_0);};$1=$1.autocomplete($3);$2.click(function($p1_0){
$1.autocomplete('search','');});ko.utils.registerEventHandler(element,'change',function($p1_0,$p1_1){
var $1_0=$1.val();SparkleXrm.CustomBinding.XrmDurationBinding.$1_0(valueAccessor,$1,$1_0);});var $4=function(){
$(element).autocomplete("destroy");};ko.utils.domNodeDisposal.addDisposeCallback(element, $4);},update:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=$(element);var $1=$0.find('.sparkle-input-duration-part');var $2=ko.utils.unwrapObservable(valueAccessor());var $3=$2;var $4=SparkleXrm.CustomBinding.XrmDurationBinding.$1_1($3);$1.val($4);}}
SparkleXrm.CustomBinding.FadeVisibleBinding=function(){SparkleXrm.CustomBinding.FadeVisibleBinding.initializeBase(this);}
SparkleXrm.CustomBinding.FadeVisibleBinding.prototype={init:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=valueAccessor();$(element).toggle(ko.utils.unwrapObservable($0));},update:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=valueAccessor();if(ko.utils.unwrapObservable($0)){$(element).fadeIn();}else{$(element).fadeOut();}}}
SparkleXrm.CustomBinding.ProgressBarBinding=function(){SparkleXrm.CustomBinding.ProgressBarBinding.initializeBase(this);}
SparkleXrm.CustomBinding.ProgressBarBinding.prototype={init:function(element,valueAccessor,allBindingsAccessor,viewModel,context){$(element).progressbar();},update:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=valueAccessor();var $1=ko.utils.unwrapObservable($0);$(element).progressbar('value',$1);}}
SparkleXrm.CustomBinding.XrmTimeOfDayBinding=function(){SparkleXrm.CustomBinding.XrmTimeOfDayBinding.initializeBase(this);}
SparkleXrm.CustomBinding.XrmTimeOfDayBinding.$1_0=function($p0,$p1,$p2){var $0=$p0();var $1=true;var $2=SparkleXrm.Sdk.DateTimeEx.addTimeToDate($0(),$p2);var $3=($2==null)?'':$2.toString();var $4=($0()==null)?'':$0().toString();if($3===$4){return;}if($2==null){alert('Invalid Time');$p1.focus();var $5=$0();SparkleXrm.CustomBinding.XrmTimeOfDayBinding.$1_1($p1,$5);}else{$0($2);if((typeof($0.isValid))!=='undefined'){$1=!!($0).isValid();}if($1){}}}
SparkleXrm.CustomBinding.XrmTimeOfDayBinding.$1_1=function($p0,$p1){var $0=SparkleXrm.CustomBinding.XrmTimeOfDayBinding.$1_2();var $1='';if($p1!=null){$1=$p1.format($0);}$p0.val($1);}
SparkleXrm.CustomBinding.XrmTimeOfDayBinding.$1_2=function(){var $0='h:mm tt';if(SparkleXrm.Sdk.OrganizationServiceProxy.userSettings!=null){$0=SparkleXrm.Sdk.OrganizationServiceProxy.userSettings.timeformatstring;}return $0;}
SparkleXrm.CustomBinding.XrmTimeOfDayBinding.prototype={init:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=SparkleXrm.CustomBinding.XrmTimeOfDayBinding.$1_2();var $1=$(element);var $2=$1.find('.sparkle-input-timeofday-part');var $3=$1.find('.sparkle-input-timeofday-button-part');var $4=SparkleXrm.GridEditor.XrmTimeEditor.getTimePickerAutoCompleteOptions($0);$4.position={collision:'fit'};$4.select=function($p1_0,$p1_1){
var $1_0=($p1_1.item)['value'].toString();SparkleXrm.CustomBinding.XrmTimeOfDayBinding.$1_0(valueAccessor,$2,$1_0);};$2=$2.autocomplete($4);$3.click(function($p1_0){
$2.autocomplete('search','');});ko.utils.registerEventHandler($2.get(0),'change',function($p1_0,$p1_1){
var $1_0=$2.val();SparkleXrm.CustomBinding.XrmTimeOfDayBinding.$1_0(valueAccessor,$2,$1_0);});var $5=function(){
$(element).autocomplete("destroy");};ko.utils.domNodeDisposal.addDisposeCallback(element, $5);},update:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=$(element);var $1=$0.find('.sparkle-input-timeofday-part');var $2=ko.utils.unwrapObservable(valueAccessor());var $3=SparkleXrm.CustomBinding.XrmTimeOfDayBinding.$1_2();var $4=SparkleXrm.Sdk.DateTimeEx.formatTimeSpecific($2,$3);$1.val($4);}}
Type.registerNamespace('SparkleXrm.GridEditor');SparkleXrm.GridEditor.SortCol=function(attributeName,ascending){this.attributeName=attributeName;this.ascending=ascending;}
SparkleXrm.GridEditor.SortCol.prototype={attributeName:null,ascending:false}
SparkleXrm.GridEditor.XrmBooleanEditor=function(args){SparkleXrm.GridEditor.XrmBooleanEditor.initializeBase(this,[args]);this.$0=$("<input type='checkbox' class='editor-boolean'/>").appendTo(args.container).bind('keydown.nav',function($p1_0){
if($p1_0.which===37||$p1_0.which===39){$p1_0.stopImmediatePropagation();}}).focus().select();}
SparkleXrm.GridEditor.XrmBooleanEditor.bindColumn=function(column,TrueOptionDisplayName,FalseOptionDisplayName){column.editor=SparkleXrm.GridEditor.XrmBooleanEditor.booleanEditor;column.formatter=SparkleXrm.GridEditor.XrmBooleanEditor.formatter;var $0={};$0.trueOptionDisplayName=TrueOptionDisplayName;$0.falseOptionDisplayName=FalseOptionDisplayName;column.options=$0;return column;}
SparkleXrm.GridEditor.XrmBooleanEditor.bindReadOnlyColumn=function(column,TrueOptionDisplayName,FalseOptionDisplayName){column.formatter=SparkleXrm.GridEditor.XrmBooleanEditor.formatter;var $0={};$0.trueOptionDisplayName=TrueOptionDisplayName;$0.falseOptionDisplayName=FalseOptionDisplayName;column.options=$0;return column;}
SparkleXrm.GridEditor.XrmBooleanEditor.formatter=function(row,cell,value,columnDef,dataContext){var $0='True';var $1='False';var $2=columnDef.options;if($2!=null&&$2.trueOptionDisplayName!=null){$0=$2.trueOptionDisplayName;}if($2!=null&&$2.falseOptionDisplayName!=null){$1=$2.falseOptionDisplayName;}if(value!=null){return (value)?$0:$1;}else{return $1;}}
SparkleXrm.GridEditor.XrmBooleanEditor.prototype={$0:null,$1:false,destroy:function(){SparkleXrm.GridEditor.XrmBooleanEditor.callBaseMethod(this, 'destroy');this.$0.remove();},focus:function(){SparkleXrm.GridEditor.XrmBooleanEditor.callBaseMethod(this, 'focus');this.$0.focus();},$2:function(){return this.$0.is(':checked');},loadValue:function(item){this.$1=item[this._args.column.field];if(this.$1){this.$0[0].setAttribute('checked','checked');}else{this.$0[0].removeAttribute('checked');}this.$0[0].setAttribute('defaultValue',this.$1);this.$0.select();},serializeValue:function(){return this.$2();},applyValue:function(item,state){item[this._args.column.field]=state;this.raiseOnChange(item);},isValueChanged:function(){var $0=this.$2();return ($0!==this.$1);}}
SparkleXrm.GridEditor.XrmMoneyEditor=function(args){SparkleXrm.GridEditor.XrmMoneyEditor.initializeBase(this,[args]);this.$3=args.column.options;this.$1=$('<SPAN/>').appendTo(args.container);this.$0=$("<INPUT type=text class='editor-text' />").appendTo(args.container).bind('keydown.nav',function($p1_0){
if($p1_0.which===37||$p1_0.which===39){$p1_0.stopImmediatePropagation();}}).focus().select();}
SparkleXrm.GridEditor.XrmMoneyEditor.formatter=function(row,cell,value,columnDef,dataContext){if(value!=null){var $0=SparkleXrm.GridEditor.XrmMoneyEditor.getCurrencySymbol((dataContext).transactioncurrencyid);var $1=value;return $0+' '+SparkleXrm.NumberEx.format($1.value,columnDef.options);}else{return '';}}
SparkleXrm.GridEditor.XrmMoneyEditor.bindColumn=function(column,minValue,maxValue){column.editor=SparkleXrm.GridEditor.XrmMoneyEditor.moneyEditor;column.formatter=SparkleXrm.GridEditor.XrmMoneyEditor.formatter;var $0=SparkleXrm.NumberEx.getCurrencyEditFormatInfo();$0.minValue=minValue;$0.maxValue=maxValue;column.options=$0;return column;}
SparkleXrm.GridEditor.XrmMoneyEditor.bindReadOnlyColumn=function(column){column.formatter=SparkleXrm.GridEditor.XrmMoneyEditor.formatter;var $0=SparkleXrm.NumberEx.getCurrencyEditFormatInfo();column.options=$0;return column;}
SparkleXrm.GridEditor.XrmMoneyEditor.getCurrencySymbol=function(currencyid){if(currencyid!=null&¤cyid.id!=null&¤cyid.id.value!=null){return SparkleXrm.NumberEx.getCurrencySymbol(currencyid.id);}return '';}
SparkleXrm.GridEditor.XrmMoneyEditor.prototype={$0:null,$1:null,$2:null,$3:null,destroy:function(){SparkleXrm.GridEditor.XrmMoneyEditor.callBaseMethod(this, 'destroy');this.$0.remove();this.$1.remove();},focus:function(){SparkleXrm.GridEditor.XrmMoneyEditor.callBaseMethod(this, 'focus');this.$0.focus();},getValue:function(){return this.$0.val();},setValue:function(value){this.$0.val(value);},loadValue:function(item){var $0=SparkleXrm.GridEditor.XrmMoneyEditor.getCurrencySymbol(((item)).transactioncurrencyid);this.$1.text($0+' ');var $1=item[this._args.column.field];this.$2='';if($1!=null){this.$2=SparkleXrm.NumberEx.format($1.value,this.$3);}this.$0.val(this.$2);this.$0[0].setAttribute('defaultValue',this.$2);this.$0.select();},serializeValue:function(){return this.$0.val();},applyValue:function(item,state){var $0=new SparkleXrm.Sdk.Money(SparkleXrm.NumberEx.parse(state,this.$3));item[this._args.column.field]=$0;this.raiseOnChange(item);},isValueChanged:function(){return (!(!this.$0.val()&&this.$2==null))&&(this.$0.val()!==this.$2);},nativeValidation:function(newValue){var $0=true;var $1=SparkleXrm.NumberEx.parse(newValue,this.$3);$0=!isNaN($1);$0=$0&&($1>=this.$3.minValue)&&($1<=this.$3.maxValue);if(!$0){var $2={};$2.valid=false;$2.message=String.format('Please enter a number between {0} and {1}.',this.$3.minValue,this.$3.maxValue);return $2;}return null;}}
SparkleXrm.GridEditor.XrmNumberEditor=function(args){SparkleXrm.GridEditor.XrmNumberEditor.initializeBase(this,[args]);this.$2=args.column.options;this.$0=$("<INPUT type=text class='editor-text' />").appendTo(args.container).bind('keydown.nav',function($p1_0){
if($p1_0.which===37||$p1_0.which===39){$p1_0.stopImmediatePropagation();}}).focus().select();}
SparkleXrm.GridEditor.XrmNumberEditor.formatter=function(row,cell,value,columnDef,dataContext){if(value!=null){var $0=value;return SparkleXrm.NumberEx.format($0,columnDef.options);}else{return '';}}
SparkleXrm.GridEditor.XrmNumberEditor.bindColumn=function(column,minValue,maxValue,precision){column.editor=SparkleXrm.GridEditor.XrmNumberEditor.numberEditor;column.formatter=SparkleXrm.GridEditor.XrmNumberEditor.formatter;var $0=SparkleXrm.NumberEx.getNumberFormatInfo();$0.minValue=minValue;$0.maxValue=maxValue;$0.precision=precision;column.options=$0;return column;}
SparkleXrm.GridEditor.XrmNumberEditor.bindReadOnlyColumn=function(column,precision){column.formatter=SparkleXrm.GridEditor.XrmNumberEditor.formatter;var $0=SparkleXrm.NumberEx.getNumberFormatInfo();$0.precision=precision;column.options=$0;return column;}
SparkleXrm.GridEditor.XrmNumberEditor.prototype={$0:null,$1:null,$2:null,destroy:function(){SparkleXrm.GridEditor.XrmNumberEditor.callBaseMethod(this, 'destroy');this.$0.remove();},focus:function(){SparkleXrm.GridEditor.XrmNumberEditor.callBaseMethod(this, 'focus');this.$0.focus();},getValue:function(){return this.$0.val();},setValue:function(value){this.$0.val(value);},loadValue:function(item){this.$1=SparkleXrm.NumberEx.format(item[this._args.column.field],this.$2);if(this.$1==null){this.$1='';}this.$0.val(this.$1);this.$0[0].setAttribute('defaultValue',this.$1);this.$0.select();},serializeValue:function(){return this.$0.val();},applyValue:function(item,state){item[this._args.column.field]=SparkleXrm.NumberEx.parse(state,this.$2);this.raiseOnChange(item);},isValueChanged:function(){return (!(!this.$0.val()&&this.$1==null))&&(this.$0.val()!==this.$1);},nativeValidation:function(newValue){var $0=true;var $1=SparkleXrm.NumberEx.parse(newValue,this.$2);$0=!isNaN($1);$0=$0&&($1>=this.$2.minValue)&&($1<=this.$2.maxValue);if(!$0){var $2={};$2.valid=false;$2.message=String.format('Please enter a number between {0} and {1}.',this.$2.minValue,this.$2.maxValue);return $2;}return null;}}
SparkleXrm.GridEditor.EntityDataViewModel=function(pageSize,entityType,lazyLoadPages){this._rows=new Array(0);this._sortCols=[];SparkleXrm.GridEditor.EntityDataViewModel.initializeBase(this);this._entityType=entityType;this._lazyLoadPages=lazyLoadPages;this._data=[];this.paging.pageSize=pageSize;this.paging.pageNum=0;this.paging.totalPages=0;this.paging.totalRows=0;this.paging.fromRecord=0;this.paging.toRecord=0;}
SparkleXrm.GridEditor.EntityDataViewModel.prototype={_suspendRefresh:false,_data:null,_entityType:null,_fetchXml:'',_itemAdded:false,_lazyLoadPages:true,errorMessage:'',deleteData:null,add_onBeginClearPageCache:function(value){this.$2=ss.Delegate.combine(this.$2,value);},remove_onBeginClearPageCache:function(value){this.$2=ss.Delegate.remove(this.$2,value);},$2:null,get_fetchXml:function(){return this._fetchXml;},set_fetchXml:function(value){this._fetchXml=value;return value;},getItem:function(index){if(index>=this.paging.pageSize){return null;}else{return this._data[index+(this.paging.pageNum*this.paging.pageSize)];}},reset:function(){this.clearPageCache();this.deleteData=[];},resetPaging:function(){this.paging.pageNum=0;},sort:function(sorting){var $0=new SparkleXrm.GridEditor.SortCol(sorting.sortCol.field,sorting.sortAsc);this.sortBy($0);},getSortColumns:function(){if(this._sortCols==null){return new Array(0);}return this._sortCols;},sortBy:function(col){this._sortCols.clear();this._sortCols.add(col);if(this._lazyLoadPages){this.clearPageCache();this.paging.extraInfo='';this.refresh();}else{if(!col.ascending){this._data.reverse();}this._data.sort(function($p1_0,$p1_1){
return SparkleXrm.Sdk.Entity.sortDelegate(col.attributeName,$p1_0,$p1_1);});if(!col.ascending){this._data.reverse();}}},getDirtyItems:function(){var $0=[];var $enum1=ss.IEnumerator.getEnumerator(this._data);while($enum1.moveNext()){var $1=$enum1.current;if($1!=null&&$1.entityState!==SparkleXrm.Sdk.EntityStates.unchanged){$0.add($1);}}if(this.deleteData!=null){var $enum2=ss.IEnumerator.getEnumerator(this.deleteData);while($enum2.moveNext()){var $2=$enum2.current;if($2.entityState===SparkleXrm.Sdk.EntityStates.deleted){$0.add($2);}}}return $0;},contains:function(Item){var $enum1=ss.IEnumerator.getEnumerator(this._data);while($enum1.moveNext()){var $0=$enum1.current;if(Item.logicalName===$0.logicalName&&Item.id===$0.id){return true;}}return false;},preProcessResultsData:function(results){},refresh:function(){if(String.isNullOrEmpty(this._fetchXml)){return;}if(this._suspendRefresh){return;}this._suspendRefresh=true;var $0=this.paging.pageNum*this.paging.pageSize;var $1=(!this.paging.totalRows)&&(this.deleteData!=null)&&(this.deleteData.length>0);if(this._data[$0]==null&&!$1){this.onDataLoading.notify(null,null,null);var $2=this.applySorting();var $3;if(this._lazyLoadPages){$3=this.paging.pageSize;}else{$3=1000;this.paging.extraInfo='';this.paging.pageNum=0;$0=0;}var $4=String.format(this._fetchXml,$3,SparkleXrm.Sdk.XmlHelper.encode(this.paging.extraInfo),this.paging.pageNum+1,$2);SparkleXrm.Sdk.OrganizationServiceProxy.beginRetrieveMultiple($4,ss.Delegate.create(this,function($p1_0){
try{var $1_0=SparkleXrm.Sdk.OrganizationServiceProxy.endRetrieveMultiple($p1_0,this._entityType);this.preProcessResultsData($1_0);var $1_1=$0;if(this._lazyLoadPages){var $enum1=ss.IEnumerator.getEnumerator($1_0.get_entities());while($enum1.moveNext()){var $1_3=$enum1.current;this._data[$1_1]=$1_3;$1_1=$1_1+1;}}else{this._data=$1_0.get_entities().items();}var $1_2={};$1_2.from=0;$1_2.to=this.paging.pageSize-1;this.paging.totalRows=$1_0.get_totalRecordCount();this.paging.extraInfo=$1_0.get_pagingCookie();this.paging.fromRecord=$0+1;this.paging.totalPages=Math.ceil($1_0.get_totalRecordCount()/this.paging.pageSize);this.paging.toRecord=Math.min($1_0.get_totalRecordCount(),$0+this.paging.pageSize);if(this._itemAdded){this.paging.totalRows++;this.paging.toRecord++;this._itemAdded=false;}this.calculatePaging(this.getPagingInfo());this.onPagingInfoChanged.notify(this.paging,null,this);this.onDataLoaded.notify($1_2,null,null);}catch($1_4){this.errorMessage=$1_4.message;var $1_5={};$1_5.errorMessage=$1_4.message;this.onDataLoaded.notify($1_5,null,null);}}));}else{var $5={};$5.from=0;$5.to=this.paging.pageSize-1;this.paging.fromRecord=$0+1;this.paging.toRecord=Math.min(this.paging.totalRows,$0+this.paging.pageSize);this.calculatePaging(this.getPagingInfo());this.onPagingInfoChanged.notify(this.paging,null,this);this.onDataLoaded.notify($5,null,null);this._itemAdded=false;}this.onRowsChanged.notify(null,null,this);this._suspendRefresh=false;},newItemFactory:null,removeItem:function(id){if(id!=null){if(this.deleteData==null){this.deleteData=[];}this.deleteData.add(id);this._data.remove(id);this.paging.totalRows--;this.setPagingOptions(this.getPagingInfo());this._selectedRows=null;this.raiseOnSelectedRowsChanged(null);}},addItem:function(newItem){if(!this.paging.totalPages){this.paging.pageNum=0;this.paging.totalPages=1;}var $0;if(this.newItemFactory==null){$0=new this._entityType();$.extend($0,newItem);}else{$0=this.newItemFactory(newItem);}this._data[this.paging.totalRows]=($0);this._itemAdded=true;var $1=(this.paging.totalRows%this.paging.pageSize);if($1===this.paging.pageSize){this.paging.totalPages++;this.paging.pageNum=this.paging.totalPages-1;}else{this.paging.totalRows++;this.paging.pageNum=this.getTotalPages();}$0.raisePropertyChanged(null);this.setPagingOptions(this.getPagingInfo());},applySorting:function(){var $0='';var $enum1=ss.IEnumerator.getEnumerator(this._sortCols);while($enum1.moveNext()){var $1=$enum1.current;$0=$0+String.format('<order attribute="{0}" descending="{1}" />',$1.attributeName,(!$1.ascending)?'true':'false');}return $0;},clearPageCache:function(){if(this.$2!=null){this.$2();}this._data=[];this.paging.extraInfo=null;},get_data:function(){return this._data;}}
SparkleXrm.GridEditor.XrmDateEditor=function(args){SparkleXrm.GridEditor.XrmDateEditor.initializeBase(this,[args]);var $0=this;this.$1=$("<div ><table class='inline-edit-container' cellspacing='0' cellpadding='0'><tr>"+"<td><INPUT type=text class='sparkle-input-inline' /></td>"+"<td class='lookup-button-td'><input type=button class='sparkle-imagestrip-inlineedit_calendar_icon' /></td></tr></table></div>");this.$1.appendTo(this._args.container);this.$0=this.$1.find('.sparkle-input-inline');this.$0.bind('keydown.nav',ss.Delegate.create(this,function($p1_0){
if(!this.$3&&($p1_0.which===38||$p1_0.which===40)&&$p1_0.ctrlKey){this.$0.datepicker('show');$p1_0.stopImmediatePropagation();}else if(this.$3&&$p1_0.which===13){$p1_0.preventDefault();}}));var $1=this.$1.find('.sparkle-imagestrip-inlineedit_calendar_icon');this.$0.focus().select();var $2={};$2.showOtherMonths=true;$2.showOn='';$2.firstDay=(SparkleXrm.Sdk.OrganizationServiceProxy.organizationSettings!=null)?SparkleXrm.Sdk.OrganizationServiceProxy.organizationSettings.weekstartdaycode.value:0;$2.beforeShow=ss.Delegate.create(this,function(){
this.$3=true;});$2.onClose=ss.Delegate.create(this,function(){
this.$3=false;this.$4=this.$6();});$2.onSelect=ss.Delegate.create(this,function($p1_0,$p1_1){
this.focus();});if(SparkleXrm.Sdk.OrganizationServiceProxy.userSettings!=null){this.$5=SparkleXrm.Sdk.OrganizationServiceProxy.userSettings.dateformatstring;}$2.dateFormat=this.$5;this.$0.datepicker($2);$1.click(ss.Delegate.create(this,function($p1_0){
this.$0.datepicker('show');this.focus();}));}
SparkleXrm.GridEditor.XrmDateEditor.formatterDateOnly=function(row,cell,value,columnDef,dataContext){var $0=SparkleXrm.GridEditor.XrmDateEditor.getDateFormat(columnDef);var $1=value;return SparkleXrm.Sdk.DateTimeEx.formatDateSpecific($1,$0);}
SparkleXrm.GridEditor.XrmDateEditor.getDateBindingOptions=function(columnDef){var $0=columnDef.options;var $1=null;if($0!=null&&Type.getInstanceType($0)===String){$1={};$1.overrideUserDateFormat=columnDef.options;return $1;}else if($0!=null){$1=$0;}else{$1={};}return $1;}
SparkleXrm.GridEditor.XrmDateEditor.getDateFormat=function(columnDef){var $0=SparkleXrm.GridEditor.XrmDateEditor.getDateBindingOptions(columnDef).overrideUserDateFormat;if($0==null&&SparkleXrm.Sdk.OrganizationServiceProxy.userSettings!=null){$0=SparkleXrm.Sdk.OrganizationServiceProxy.userSettings.dateformatstring;}return $0;}
SparkleXrm.GridEditor.XrmDateEditor.formatterDateAndTime=function(row,cell,value,columnDef,dataContext){var $0=SparkleXrm.GridEditor.XrmDateEditor.getDateFormat(columnDef);if($0!=null&&SparkleXrm.Sdk.OrganizationServiceProxy.userSettings!=null){$0=SparkleXrm.Sdk.OrganizationServiceProxy.userSettings.dateformatstring+' '+SparkleXrm.Sdk.OrganizationServiceProxy.userSettings.timeformatstring;}var $1=value;return SparkleXrm.Sdk.DateTimeEx.formatDateSpecific($1,$0);}
SparkleXrm.GridEditor.XrmDateEditor.bindColumn=function(column,dateOnly){column.editor=SparkleXrm.GridEditor.XrmDateEditor.crmDateEditor;column.formatter=SparkleXrm.GridEditor.XrmDateEditor.formatterDateOnly;return column;}
SparkleXrm.GridEditor.XrmDateEditor.bindReadOnlyColumn=function(column,dateOnly){column.formatter=SparkleXrm.GridEditor.XrmDateEditor.formatterDateOnly;return column;}
SparkleXrm.GridEditor.XrmDateEditor.prototype={$0:null,$1:null,$2:null,$3:false,$4:null,$5:'dd/mm/yy',destroy:function(){($.datepicker.dpDiv).stop(true,true);this.$0.datepicker('hide');this.$0.datepicker('destroy');this.hide();this.$1.remove();},show:function(){if(this.$3){($.datepicker.dpDiv).stop(true,true).show();}},hide:function(){if(this.$3){($.datepicker.dpDiv).stop(true,true).hide();}},position:function(position){if(!this.$3){return;}($.datepicker.dpDiv).css('top',(position.top+30).toString()).css('left',position.left.toString());},focus:function(){this.$0.focus();},loadValue:function(item){var $0=item[this._args.column.field];this.$2=($0!=null)?$0:null;var $1=(this.$2!=null)?this.$2.toLocaleDateString():'';if(this._args.column.formatter!=null){$1=this._args.column.formatter(0,0,this.$2,this._args.column,null);}this.$7(this.$2);this.$0.select();},serializeValue:function(){return this.$6();},applyValue:function(item,state){var $0=item[this._args.column.field];var $1=state;if($0==null){var $2=SparkleXrm.GridEditor.XrmDateEditor.getDateBindingOptions(this._args.column);$0=new Date(1900,1,1,($2.hour!=null)?$2.hour:0,($2.minute!=null)?$2.minute:0);}SparkleXrm.Sdk.DateTimeEx.setTime($1,$0);item[this._args.column.field]=$1;this.raiseOnChange(item);},isValueChanged:function(){var $0=this.$6();var $1=($0==null)?'':$0.toString();var $2=(this.$2==null)?'':this.$2.toString();return ($1!==$2);},$6:function(){var $0=null;if(!this.$3){$0=SparkleXrm.Sdk.DateTimeEx.parseDateSpecific(this.$0.val(),this.$5);}else{$0=this.$0.datepicker('getDate');}return $0;},$7:function($p0){this.$0.datepicker('setDate',$p0);}}
SparkleXrm.GridEditor.XrmDurationEditor=function(args){SparkleXrm.GridEditor.XrmDurationEditor.initializeBase(this,[args]);this._args=args;this.$0=$("<INPUT type=text class='editor-text' />");this.$0.appendTo(this._args.container);this.focus();}
SparkleXrm.GridEditor.XrmDurationEditor.formatter=function(row,cell,value,columnDef,dataContext){var $0=value;return SparkleXrm.Sdk.DateTimeEx.formatDuration($0);}
SparkleXrm.GridEditor.XrmDurationEditor.bindColumn=function(column){column.editor=SparkleXrm.GridEditor.XrmDurationEditor.durationEditor;column.formatter=SparkleXrm.GridEditor.XrmDurationEditor.formatter;return column;}
SparkleXrm.GridEditor.XrmDurationEditor.prototype={$0:null,$1:null,destroy:function(){this.$0.remove();},focus:function(){this.$0.focus().select();},loadValue:function(item){var $0=item[this._args.column.field];this.$0.val(SparkleXrm.Sdk.DateTimeEx.formatDuration($0));this.$1=$0;this.focus();},serializeValue:function(){var $0=this.$0.val();if(!$0){return null;}var $1=SparkleXrm.Sdk.DateTimeEx.parseDuration($0);return $1;},applyValue:function(item,state){item[this._args.column.field]=state;this.raiseOnChange(item);},isValueChanged:function(){var $0=this.$0.val();var $1=SparkleXrm.Sdk.DateTimeEx.formatDuration(this.$1);return $1!==$0;}}
SparkleXrm.GridEditor.XrmLookupEditorOptions=function(){}
SparkleXrm.GridEditor.XrmLookupEditorOptions.prototype={queryCommand:null,nameAttribute:null,idAttribute:null,typeCodeAttribute:null,columns:null,showImage:true,showFooter:false,footerButton:null,useQuickCreate:false}
SparkleXrm.GridEditor.XrmLookupEditorButton=function(){}
SparkleXrm.GridEditor.XrmLookupEditorButton.prototype={label:'',tooltip:'',onClick:null,image:null}
SparkleXrm.GridEditor.XrmLookupEditor=function(args){this.$4=new SparkleXrm.Sdk.EntityReference(null,null,'');this.$5=new SparkleXrm.Sdk.EntityReference(null,null,'');SparkleXrm.GridEditor.XrmLookupEditor.initializeBase(this,[args]);var $0=this;this._args=args;this.$1=$("<div><table class='inline-edit-container' cellspacing='0' cellpadding='0'><tr><td><INPUT type=text class='sparkle-input-inline' /></td><td class='lookup-button-td'><input type=button class='sparkle-lookup-button' /></td></tr></table></div>");this.$1.appendTo(this._args.container);var $1=this.$1.find('.sparkle-input-inline');var $2=this.$1.find('.sparkle-lookup-button');this.$0=$1;this.$0.focus().select();this.$2=$1;var $3={};$3.position={collision:'fit'};$3.minLength=100000;$3.delay=0;var $4=args.column.options;var $5=false;$3.select=ss.Delegate.create(this,function($p1_0,$p1_1){
if(this.$4==null){this.$4=new SparkleXrm.Sdk.EntityReference(null,null,null);}var $1_0=$p1_1.item;var $1_1=$1_0.value;if($1_1.logicalName==='footerlink'){var $1_2=$4.footerButton;$1_2.onClick($1_0);}else{var $1_3=$1_0.label;this.$0.val($1_3);this.$4.id=$1_1.id;this.$4.name=$1_1.name;this.$4.logicalName=($1_0.value).logicalName;$5=true;}return false;;});$3.focus=function($p1_0,$p1_1){
return false;;};$3.open=ss.Delegate.create(this,function($p1_0,$p1_1){
$0.$3=true;if($4.showFooter&&this.$6>0){var $1_0=this.$0.autocomplete('widget');SparkleXrm.GridEditor.XrmLookupEditor.addFooter($1_0,this.$6);}});$3.close=ss.Delegate.create(this,function($p1_0,$p1_1){
$0.$3=false;var $1_0=this.$0.autocomplete('widget');var $1_1=$1_0.next();if($1_1.length>0||$1_1.hasClass('sparkle-menu-footer')){$1_1.hide();}});var $6=$4.nameAttribute.split(',');if($6.length>1){$4.columns=$6;$4.nameAttribute=$6[0];}var $7=ss.Delegate.create(this,function($p1_0,$p1_1){
$4.queryCommand($p1_0.term,ss.Delegate.create(this,function($p2_0){
if($p2_0.get_totalRecordCount()>$p2_0.get_entities().get_count()){this.$6=$p2_0.get_totalRecordCount();}else{this.$6=$p2_0.get_entities().get_count();}var $2_0=$p2_0.get_entities().get_count();var $2_1=!$2_0;var $2_2=$4.footerButton;var $2_3=($2_2!=null);var $2_4=new Array($2_0+(($2_3)?1:0)+(($2_1)?1:0));for(var $2_7=0;$2_7<$2_0;$2_7++){$2_4[$2_7]={};$2_4[$2_7].label=$p2_0.get_entities().get_item($2_7).getAttributeValue($4.nameAttribute);var $2_8=new SparkleXrm.Sdk.EntityReference(null,null,null);$2_8.name=$2_4[$2_7].label;$2_8.logicalName=$p2_0.get_entities().get_item($2_7).logicalName;$2_8.id=$p2_0.get_entities().get_item($2_7).getAttributeValue($4.idAttribute);$2_4[$2_7].value=$2_8;SparkleXrm.CustomBinding.XrmLookupBinding.$1_1($4.columns,$p2_0,$2_4,$2_7);var $2_9=$p2_0.get_entities().get_item($2_7).logicalName;if(!String.isNullOrEmpty($4.typeCodeAttribute)){$2_9=$p2_0.get_entities().get_item($2_7).getAttributeValue($4.typeCodeAttribute).toString();}if($4.showImage){$2_4[$2_7].image=SparkleXrm.Sdk.Metadata.MetadataCache.getSmallIconUrl($2_9);}}var $2_5=$2_0;if($2_1){var $2_A={};$2_A.label=SparkleResourceStrings.NoRecordsFound;$2_4[$2_5]=$2_A;$2_5++;}if($2_3){var $2_B={};$2_B.label=$2_2.label;$2_B.image=$2_2.image;$2_B.columnValues=null;$2_B.value=new SparkleXrm.Sdk.Entity('footerlink');$2_4[$2_5]=$2_B;}$p1_1($2_4);var $2_6={};$2_6.minLength=100000;this.$2.autocomplete($2_6);}));});$3.source=$7;$1=this.$2.autocomplete($3);var $8=($1.data('ui-autocomplete'));$8._renderItem=function($p1_0,$p1_1){
if($p1_1.value===$p1_1.label){return $("<li class='ui-state-disabled'>"+$p1_1.label+'</li>').appendTo($p1_0);}var $1_0="<a class='sparkle-menu-item'>";if($p1_1.image!=null){$1_0+="<span class='sparkle-menu-item-img'><img src='"+$p1_1.image+"'/></span>";}$1_0+="<span class='sparkle-menu-item-label'>"+$p1_1.label+'</span><br/>';if($p1_1.columnValues!=null&&$p1_1.columnValues.length>0){var $enum1=ss.IEnumerator.getEnumerator($p1_1.columnValues);while($enum1.moveNext()){var $1_1=$enum1.current;$1_0+="<span class='sparkle-menu-item-moreinfo'>"+$1_1+'</span>';}}$1_0+='</a>';return $('<li>').append($1_0).appendTo($p1_0);};$2.click(ss.Delegate.create(this,function($p1_0){
var $1_0={};$1_0.minLength=0;this.$2.autocomplete($1_0);this.$2.autocomplete('search',$1.val());}));this.$0.keydown(ss.Delegate.create(this,function($p1_0){
if($p1_0.which===13&&!$5){if($1.val().length>0){$2.click();}else{this.$4=null;return;}}else if($p1_0.which===13){return;}if($0.$3){switch($p1_0.which){case 9:case 13:case 38:case 40:$p1_0.preventDefault();$p1_0.stopPropagation();break;}}else{switch($p1_0.which){case 13:$p1_0.preventDefault();$p1_0.stopPropagation();break;}}$5=false;}));}
SparkleXrm.GridEditor.XrmLookupEditor.formatter=function(row,cell,value,columnDef,dataContext){if(value!=null){var $0=value;return "<a href='#' class='sparkle-lookup-link' entityid='"+$0.id+"' typename='"+$0.logicalName+"'>"+SparkleXrm.Sdk.XmlHelper.encode($0.name)+'</a>';}else{return '';}}
SparkleXrm.GridEditor.XrmLookupEditor.addFooter=function(menu,recordCount){var $0=menu.next();if(!$0.length||!$0.hasClass('sparkle-menu-footer')){$0=$("<div class='sparkle-menu-footer ui-front'></div>");menu.parent().append($0);}if($0!=null){$0.html('');var $4=$("<span class='sparkle-menu-footer-content'></span>");var $5=$("<span class='sparkle-menu-footer-left'></span>");var $6=$("<span class='sparkle-menu-footer-right'></span>");$4.append($5);$4.append($6);$5.append(String.format(SparkleResourceStrings.LookupFooter,recordCount));$0.append($4);}var $1=menu.position();var $2=menu.height();var $3=menu.width();if($0!=null&&$0.length>0){$0.show();$0.css('top',($1.top+$2+4).toString()+'px');$0.css('left',$1.left.toString()+'px');$0.width($3);}}
SparkleXrm.GridEditor.XrmLookupEditor.bindColumn=function(column,queryCommand,idAttribute,nameAttribute,typeCodeAttribute){column.editor=SparkleXrm.GridEditor.XrmLookupEditor.lookupEditor;var $0=new SparkleXrm.GridEditor.XrmLookupEditorOptions();$0.queryCommand=queryCommand;$0.idAttribute=idAttribute;$0.nameAttribute=nameAttribute;$0.typeCodeAttribute=typeCodeAttribute;column.options=$0;column.formatter=SparkleXrm.GridEditor.XrmLookupEditor.formatter;return column;}
SparkleXrm.GridEditor.XrmLookupEditor.bindReadOnlyColumn=function(column,typeCodeAttribute){var $0=new SparkleXrm.GridEditor.XrmLookupEditorOptions();$0.typeCodeAttribute=typeCodeAttribute;column.options=$0;column.formatter=SparkleXrm.GridEditor.XrmLookupEditor.formatter;return column;}
SparkleXrm.GridEditor.XrmLookupEditor.prototype={$0:null,$1:null,$2:null,$3:false,$6:0,destroy:function(){this.$0.autocomplete('close');this.$0.autocomplete('destroy');this.$1.remove();this.$2.remove();this.$2=null;},show:function(){},hide:function(){},position:function(position){},focus:function(){this.$0.focus();},loadValue:function(item){this.$5=item[this._args.column.field];if(this.$5!=null){this.$4=new SparkleXrm.Sdk.EntityReference(this.$5.id,this.$5.logicalName,this.$5.name);this.$0.val(this.$5.name);}},serializeValue:function(){if(this.$4!=null&&this.$4.id==null){return null;}else{return this.$4;}},applyValue:function(item,state){item[this._args.column.field]=state;this.raiseOnChange(item);},isValueChanged:function(){if(this.$5!=null&&this.$4!=null){var $0=(this.$5.id!=null)?this.$5.id.toString():'';var $1=(this.$4.id!=null)?this.$4.id.toString():'';return $0!==$1;}else{return ((this.$5!=null)||(this.$4!=null));}}}
SparkleXrm.GridEditor.CrmPagerControl=function(dataView,grid,container){this.$0=dataView;this.$1=grid;this.$2=container;$(ss.Delegate.create(this,function(){
this.init();}));}
SparkleXrm.GridEditor.CrmPagerControl.prototype={$0:null,$1:null,$2:null,init:function(){this.$0.onPagingInfoChanged.subscribe(ss.Delegate.create(this,function($p1_0,$p1_1){
this.updatePager($p1_1);}));this.$0.add_onSelectedRowsChanged(ss.Delegate.create(this,this.$3));this.constructPagerUI();this.updatePager(this.$0.getPagingInfo());},$3:function(){this.updatePager(this.$0.getPagingInfo());},getNavState:function(){var $0=!Slick.GlobalEditorLock.commitCurrentEdit();var $1=this.$0.getPagingInfo();var $2=$1.totalPages-1;var $3={};$3.canGotoFirst=!$0&&!!$1.pageSize&&$1.pageNum>0;$3.canGotoLast=!$0&&!!$1.pageSize&&$1.pageNum!==$2;$3.canGotoPrev=!$0&&!!$1.pageSize&&$1.pageNum>0;$3.canGotoNext=!$0&&!!$1.pageSize&&$1.pageNum<$2;$3.pagingInfo=$1;return $3;},setPageSize:function(n){this.$0.setRefreshHints({isFilterUnchanged: true});var $0={};$0.pageSize=n;this.$0.setPagingOptions($0);},gotoFirst:function(e){if(this.getNavState().canGotoFirst){var $0={};$0.pageNum=0;this.$0.setPagingOptions($0);}},gotoLast:function(e){var $0=this.getNavState();if($0.canGotoLast){var $1={};$1.pageNum=$0.pagingInfo.totalPages-1;this.$0.setPagingOptions($1);}},gotoPrev:function(e){var $0=this.getNavState();if($0.canGotoPrev){var $1={};$1.pageNum=$0.pagingInfo.pageNum-1;this.$0.setPagingOptions($1);this.$1.scrollRowToTop(0);}},gotoNext:function(e){var $0=this.getNavState();if($0.canGotoNext){var $1={};$1.pageNum=$0.pagingInfo.pageNum+1;this.$0.setPagingOptions($1);this.$1.scrollRowToTop(0);}},constructPagerUI:function(){this.$2.empty();var $0=$("<table cellspacing='0' cellpadding='0' class='sparkle-grid-status'><tbody><tr>"+"<td class='sparkle-grid-status-label'>1 - 1 of 1 (0 selected)</td>"+"<td class='sparkle-grid-status-paging'>"+"<img src='../../sparkle_/css/images/transparent_spacer.gif' class='sparkle-grid-paging-first'>"+"<img src='../../sparkle_/css/images/transparent_spacer.gif' class='sparkle-grid-paging-back'>"+"<span class='sparkle-grid-status-paging-page'>Page 1</span>"+"<img src='../../sparkle_/css/images/transparent_spacer.gif' class='sparkle-grid-paging-next'>"+' </td></tr></tbody></table>');var $1=$0.find('.sparkle-grid-paging-first');var $2=$0.find('.sparkle-grid-paging-back');var $3=$0.find('.sparkle-grid-paging-next');var $4=$0.find('.sparkle-grid-status-label');var $5=$0.find('.sparkle-grid-status-paging-page');this.$2.append($0);$1.click(ss.Delegate.create(this,this.gotoFirst));$2.click(ss.Delegate.create(this,this.gotoPrev));$3.click(ss.Delegate.create(this,this.gotoNext));},updatePager:function(pagingInfo){var $0=this.getNavState();var $1=this.$2.find('.sparkle-grid-paging-first');var $2=this.$2.find('.sparkle-grid-paging-back');var $3=this.$2.find('.sparkle-grid-paging-next');var $4=this.$2.find('.sparkle-grid-status-label');var $5=this.$2.find('.sparkle-grid-status-paging-page');var $6=this.$2.find('.sparkle-grid-status-label');if($0.canGotoFirst){$1.removeClass('disabled');}else{$1.addClass('disabled');}if($0.canGotoPrev){$2.removeClass('disabled');}else{$2.addClass('disabled');}if($0.canGotoNext){$3.removeClass('disabled');}else{$3.addClass('disabled');}$6.text(String.format('{0} - {1} of {2} ({3} selected)',pagingInfo.fromRecord,pagingInfo.toRecord,pagingInfo.totalRows,this.$0.getSelectedRows().length.toString()));$5.text(String.format('Page {0}',pagingInfo.pageNum+1));}}
SparkleXrm.GridEditor.XrmTextEditor=function(args){SparkleXrm.GridEditor.XrmTextEditor.initializeBase(this,[args]);this.$0=$("<INPUT type=text class='editor-text' />").appendTo(args.container).bind('keydown.nav',function($p1_0){
if($p1_0.which===37||$p1_0.which===39){$p1_0.stopImmediatePropagation();}}).focus().select();}
SparkleXrm.GridEditor.XrmTextEditor.bindColumn=function(column){column.editor=SparkleXrm.GridEditor.XrmTextEditor.textEditor;column.formatter=SparkleXrm.GridEditor.XrmTextEditor.formatter;return column;}
SparkleXrm.GridEditor.XrmTextEditor.bindReadOnlyColumn=function(column){column.formatter=SparkleXrm.GridEditor.XrmTextEditor.formatter;return column;}
SparkleXrm.GridEditor.XrmTextEditor.formatter=function(row,cell,value,columnDef,dataContext){if(value!=null){return value;}else{return '';}}
SparkleXrm.GridEditor.XrmTextEditor.prototype={$0:null,$1:null,destroy:function(){SparkleXrm.GridEditor.XrmTextEditor.callBaseMethod(this, 'destroy');this.$0.remove();},focus:function(){SparkleXrm.GridEditor.XrmTextEditor.callBaseMethod(this, 'focus');this.$0.focus();},getValue:function(){return this.$0.val();},setValue:function(value){this.$0.val(value);},loadValue:function(item){this.$1=item[this._args.column.field];if(this.$1==null){this.$1='';}this.$0.val(this.$1);this.$0[0].setAttribute('defaultValue',this.$1);this.$0.select();},serializeValue:function(){return this.$0.val();},applyValue:function(item,state){item[this._args.column.field]=state;this.raiseOnChange(item);},isValueChanged:function(){return (!(!this.$0.val()&&this.$1==null))&&(this.$0.val()!==this.$1);}}
SparkleXrm.GridEditor.XrmTimeEditor=function(args){SparkleXrm.GridEditor.XrmTimeEditor.initializeBase(this,[args]);var $0=false;var $1=this;if(SparkleXrm.Sdk.OrganizationServiceProxy.userSettings!=null){this.$6=SparkleXrm.Sdk.OrganizationServiceProxy.userSettings.timeformatstring;}this.$2=$("<div ><table class='inline-edit-container' cellspacing='0' cellpadding='0'><tr><td><INPUT type=text class='sparkle-input-inline' /></td><td class='lookup-button-td'><input type=button class='autocompleteButton' /></td></tr></table></div>");this.$2.appendTo(this._args.container);var $2=this.$2.find('.sparkle-input-inline');this.$1=$2;this.$1.focus().select();var $3=this.$6;var $4=SparkleXrm.GridEditor.XrmTimeEditor.getTimePickerAutoCompleteOptions($3);$4.select=function($p1_0,$p1_1){
$0=true;};$4.open=function($p1_0,$p1_1){
$1.$3=true;};$4.close=function($p1_0,$p1_1){
$1.$3=false;};$2=$2.autocomplete($4);var $5=this.$2.find('.autocompleteButton');$5.click(function($p1_0){
$2.autocomplete('search','');});this.$1.keydown(function($p1_0){
if($1.$3){switch($p1_0.which){case 13:case 38:case 40:$p1_0.preventDefault();$p1_0.stopPropagation();break;}}$0=false;});}
SparkleXrm.GridEditor.XrmTimeEditor.formatter=function(row,cell,value,columnDef,dataContext){var $0=value;return SparkleXrm.GridEditor.XrmTimeEditor.$0($0,columnDef.options);}
SparkleXrm.GridEditor.XrmTimeEditor.$0=function($p0,$p1){var $0='';if($p0!=null){$0=$p0.format($p1);}return $0;}
SparkleXrm.GridEditor.XrmTimeEditor.getTimePickerAutoCompleteOptions=function(timeFormatString){var $0={};var $1=new Array(48);var $2=Date.parseDate('2000-01-01T00:00:00');for(var $3=0;$3<48;$3++){$1[$3]=SparkleXrm.GridEditor.XrmTimeEditor.$0($2,timeFormatString);$2=SparkleXrm.Sdk.DateTimeEx.dateAdd('minutes',30,$2);}$0.source=$1;$0.minLength=0;$0.delay=0;$0.position={collision:'fit'};return $0;}
SparkleXrm.GridEditor.XrmTimeEditor.bindColumn=function(column){column.editor=SparkleXrm.GridEditor.XrmTimeEditor.timeEditor;column.formatter=SparkleXrm.GridEditor.XrmTimeEditor.formatter;column.options=SparkleXrm.Sdk.OrganizationServiceProxy.userSettings.timeformatstring;return column;}
SparkleXrm.GridEditor.XrmTimeEditor.bindReadOnlyColumn=function(column){column.formatter=SparkleXrm.GridEditor.XrmTimeEditor.formatter;column.options=SparkleXrm.Sdk.OrganizationServiceProxy.userSettings.timeformatstring;return column;}
SparkleXrm.GridEditor.XrmTimeEditor.prototype={$1:null,$2:null,$3:false,$4:null,$5:null,$6:'h:mm tt',destroy:function(){this.$1.autocomplete('close');this.$1.autocomplete('destroy');this.$2.remove();},show:function(){},hide:function(){},position:function(position){},focus:function(){this.$1.focus();},loadValue:function(item){SparkleXrm.GridEditor.XrmTimeEditor.callBaseMethod(this, 'loadValue',[item]);this.$4=item[this._args.column.field];this.$5=this.$4;this.$1.val(SparkleXrm.GridEditor.XrmTimeEditor.$0(this.$4,this.$6));this.$1.select();},serializeValue:function(){var $0=this.$1.val();if(!$0){return null;}var $1=SparkleXrm.Sdk.DateTimeEx.addTimeToDate(this.$4,$0);return $1;},applyValue:function(item,state){item[this._args.column.field]=state;this.raiseOnChange(item);},isValueChanged:function(){var $0=this.$1.val();var $1=SparkleXrm.GridEditor.XrmTimeEditor.$0(this.$5,this.$6);var $2='';if(!!$0){var $3=SparkleXrm.Sdk.DateTimeEx.addTimeToDate(this.$4,$0);$2=SparkleXrm.GridEditor.XrmTimeEditor.$0($3,this.$6);}return $1!==$2;}}
SparkleXrm.GridEditor.DataViewBase=function(){this.onRowsChanged=new Slick.Event();this.onPagingInfoChanged=new Slick.Event();this.onDataLoading=new Slick.Event();this.onDataLoaded=new Slick.Event();this.paging={};this.validationBinder=new SparkleXrm.DataViewValidationBinder();}
SparkleXrm.GridEditor.DataViewBase.rangesToRows=function(ranges){var $0=[];for(var $1=0;$1<ranges.length;$1++){for(var $2=ranges[$1].fromRow;$2<=ranges[$1].toRow;$2++){$0.add($2);}}return $0;}
SparkleXrm.GridEditor.DataViewBase.prototype={add_onGetItemMetaData:function(value){this.$0=ss.Delegate.combine(this.$0,value);},remove_onGetItemMetaData:function(value){this.$0=ss.Delegate.remove(this.$0,value);},$0:null,add_onSelectedRowsChanged:function(value){this.$1=ss.Delegate.combine(this.$1,value);},remove_onSelectedRowsChanged:function(value){this.$1=ss.Delegate.remove(this.$1,value);},$1:null,_selectedRows:null,raiseOnSelectedRowsChanged:function(rows){this._selectedRows=rows;if(this.$1!=null){this.$1();}},getSelectedRows:function(){if(this._selectedRows==null){this._selectedRows=new Array(0);}return this._selectedRows;},raisePropertyChanged:function(propertyName){this.onRowsChanged.notify(null,null,null);},getPagingInfo:function(){return this.paging;},calculatePaging:function(p){if(p.pageSize!=null){this.paging.pageSize=p.pageSize;this.paging.pageNum=(!!this.paging.pageSize)?Math.min(this.paging.pageNum,Math.max(0,Math.ceil(this.paging.totalRows/this.paging.pageSize)-1)):0;}if(p.pageNum!=null){this.paging.pageNum=Math.min(p.pageNum,Math.max(0,Math.ceil(this.paging.totalRows/this.paging.pageSize)-1));}this.paging.totalPages=this.getTotalPages();this.paging.fromRecord=(this.paging.pageNum*this.paging.pageSize)+1;this.paging.toRecord=Math.min(this.paging.totalRows,this.paging.fromRecord+this.paging.pageSize-1);},setPagingOptions:function(p){this.calculatePaging(p);this._selectedRows=null;this.raiseOnSelectedRowsChanged(null);this.onPagingInfoChanged.notify(this.paging,null,this);this.refresh();},getTotalPages:function(){return Math.ceil(this.paging.totalRows/this.paging.pageSize);},refresh:function(){},reset:function(){},insertItem:function(insertBefore,item){},addItem:function(item){},removeItem:function(id){},getLength:function(){return Math.min(this.paging.pageSize,this.paging.toRecord-this.paging.fromRecord+1);},getItem:function(index){return null;},getItemMetadata:function(i){if(this.$0!=null){return this.$0(this.getItem(i));}else{return null;}},sort:function(sorting){},getSortColumns:function(){return null;},gridValidationIndexer:function(){return ss.Delegate.create(this.validationBinder,this.validationBinder.gridValidationIndexer);},onBeforeEdit:function(item){return true;}}
SparkleXrm.GridEditor.Formatters=function(){}
SparkleXrm.GridEditor.Formatters.defaultFormatter=function(row,cell,value,columnDef,dataContext){if(value==null){return '';}else{return value.toString().replaceAll('&','&').replaceAll('<','<').replaceAll('>','>');}}
SparkleXrm.GridEditor.GridDataViewBinder=function(){}
SparkleXrm.GridEditor.GridDataViewBinder.$2=function($p0,$p1){var $0=$p0.getColumns();for(var $1=0;$1<$0.length-1;$1++){var $2=$0[$1];if($p1){$2.maxWidth=$2.width;$2.minWidth=$2.width;}else{$2.maxWidth=null;$2.minWidth=null;}}}
SparkleXrm.GridEditor.GridDataViewBinder.$3=function($p0,$p1){var $0=$('#'+$p1);var $1=$('#'+$p1+' > .slick-viewport');$p0=$0;var $2={};$2.showOverlay=false;$2.ignoreIfBlocked=true;var $3={};$3.border='0px';$3.backgroundColor='transparent';var $4={};$4.opacity='0';$2.css=$3;$2.message="<span class='loading-indicator'><label>Loading...</label></span>";$p0.block($2);return $p0;}
SparkleXrm.GridEditor.GridDataViewBinder.addColumn=function(cols,displayName,width,field){var $0=SparkleXrm.GridEditor.GridDataViewBinder.newColumn(field,displayName,width);SparkleXrm.ArrayEx.add(cols,$0);return $0;}
SparkleXrm.GridEditor.GridDataViewBinder.parseLayout=function(layout){var $0=layout.split(',');var $1=[];for(var $2=0;$2<$0.length;$2=$2+3){var $3=$0[$2+1];var $4=$0[$2];var $5=parseInt($0[$2+2]);var $6=SparkleXrm.GridEditor.GridDataViewBinder.newColumn($3,$4,$5);SparkleXrm.ArrayEx.add($1,$6);}return $1;}
SparkleXrm.GridEditor.GridDataViewBinder.newColumn=function(field,name,width){var $0={};$0.id=field;$0.name=name;$0.width=width;$0.minWidth=$0.width;$0.field=field;$0.sortable=true;$0.formatter=SparkleXrm.GridEditor.GridDataViewBinder.columnFormatter;return $0;}
SparkleXrm.GridEditor.GridDataViewBinder.columnFormatter=function(row,cell,value,columnDef,dataContext){var $0;var $1='';if(columnDef.dataType!=null){$0=columnDef.dataType;}else{$0=Type.getInstanceType(value).get_name();}var $2=dataContext;var $3=($2.entityState==null)||($2.entityState===SparkleXrm.Sdk.EntityStates.unchanged);if($3&&$2.formattedValues!=null&&Object.keyExists($2.formattedValues,columnDef.field+'name')){$1=$2.formattedValues[columnDef.field+'name'];return $1;}if(value!=null){switch($0.toLowerCase()){case 'string':$1=value.toString();break;case 'boolean':case 'bool':$1=value.toString();break;case 'dateTime':case 'date':var $4=value;var $5='dd/mm/yy';var $6='hh:MM';if(SparkleXrm.Sdk.OrganizationServiceProxy.userSettings!=null){$5=SparkleXrm.Sdk.OrganizationServiceProxy.userSettings.dateformatstring;$6=SparkleXrm.Sdk.OrganizationServiceProxy.userSettings.timeformatstring;}$1=SparkleXrm.Sdk.DateTimeEx.formatDateSpecific($4,$5)+' '+SparkleXrm.Sdk.DateTimeEx.formatTimeSpecific($4,$6);break;case 'decimal':$1=value.toString();break;case 'double':$1=value.toString();break;case 'int':$1=value.toString();break;case 'guid':$1=value.toString();break;case 'money':var $7=value;$1=$7.value.toString();break;case 'customer':case 'owner':case 'lookup':case 'entityreference':var $8=value;$1='<a class="sparkle-grid-link" href="#" logicalName="'+$8.logicalName+'" id="'+$8.id+'">'+$8.name+'</a>';break;case 'picklist':case 'status':case 'state':case 'optionsetvalue':var $9=value;$1=$9.name;break;case 'primarynamelookup':var $A=(value==null)?'':value.toString();$1='<a class="sparkle-grid-link" href="#" primaryNameLookup="1">'+$A+'</a>';break;}}return $1;}
SparkleXrm.GridEditor.GridDataViewBinder.bindRowIcon=function(column,entityLogicalName){column.formatter=SparkleXrm.GridEditor.GridDataViewBinder.rowIcon;column.options=entityLogicalName;return column;}
SparkleXrm.GridEditor.GridDataViewBinder.rowIcon=function(row,cell,value,columnDef,dataContext){var $0=dataContext;if($0==null){return '';}else{var $1=$0[columnDef.options];if($1==null||$1.logicalName==null){return '';}else{return "<span class='sparkle-grid-row-img'><img src='"+SparkleXrm.Sdk.Metadata.MetadataCache.getSmallIconUrl($1.logicalName)+"'/></span>";}}}
SparkleXrm.GridEditor.GridDataViewBinder.addEditIndicatorColumn=function(columns){SparkleXrm.GridEditor.GridDataViewBinder.addColumn(columns,'',20,'entityState').formatter=function($p1_0,$p1_1,$p1_2,$p1_3,$p1_4){
var $1_0=$p1_2;switch($1_0){case SparkleXrm.Sdk.EntityStates.created:case SparkleXrm.Sdk.EntityStates.changed:return "<span class='grid-edit-indicator'></span>";case SparkleXrm.Sdk.EntityStates.readOnly:return "<span class='grid-readonly-indicator'></span>";default:return '';}};}
SparkleXrm.GridEditor.GridDataViewBinder.prototype={selectActiveRow:true,addCheckBoxSelectColumn:true,multiSelect:true,validationPopupUseFitPosition:false,$0:null,$1:null,dataBindXrmGrid:function(dataView,columns,gridId,pagerId,editable,allowAddNewRow){SparkleXrm.ArrayEx.add(columns,{});var $0={};$0.enableCellNavigation=true;$0.autoEdit=editable;$0.editable=editable;$0.asyncEditorLoading=true;$0.enableAddRow=allowAddNewRow;$0.rowHeight=(SparkleXrm.Xrm.PageEx.majorVersion===2013)?30:20;$0.headerRowHeight=25;$0.enableColumnReorder=false;var $1=null;if(this.addCheckBoxSelectColumn){var $3={};$3.cssClass='sparkle-checkbox-column';$1=new Slick.CheckboxSelectColumn($3);var $4=$1.getColumnDefinition();columns.insert(0,$4);}var $2=new Slick.Grid('#'+gridId,dataView,columns,$0);if(this.addCheckBoxSelectColumn){$2.registerPlugin($1);}this.dataBindSelectionModel($2,dataView);if(!String.isNullOrEmpty(pagerId)){var $5=new SparkleXrm.GridEditor.CrmPagerControl(dataView,$2,$('#'+pagerId));}this.dataBindEvents($2,dataView,gridId);this.addValidation($2,dataView);this.addRefreshButton(gridId,dataView);$(window).resize(function($p1_0){
SparkleXrm.GridEditor.GridDataViewBinder.$2($2,true);$2.resizeCanvas();SparkleXrm.GridEditor.GridDataViewBinder.$2($2,false);});dataView.onDataLoaded.subscribe(function($p1_0,$p1_1){
SparkleXrm.GridEditor.GridDataViewBinder.$2($2,false);});this.$1=$2;return $2;},dataBindDataViewGrid:function(dataView,columns,gridId,pagerId,editable,allowAddNewRow){SparkleXrm.ArrayEx.add(columns,{});var $0={};$0.enableCellNavigation=true;$0.autoEdit=editable;$0.editable=editable;$0.enableAddRow=allowAddNewRow;$0.rowHeight=20;$0.headerRowHeight=25;$0.enableColumnReorder=false;var $1=null;if(this.addCheckBoxSelectColumn){var $7={};$7.cssClass='sparkle-checkbox-column';$1=new Slick.CheckboxSelectColumn($7);var $8=$1.getColumnDefinition();columns.insert(0,$8);}var $2=new Slick.Grid('#'+gridId,dataView,columns,$0);$2.registerPlugin($1);dataView.onRowsChanged.subscribe(function($p1_0,$p1_1){
var $1_0=$p1_1;if($1_0!=null&&$1_0.rows!=null){$2.invalidateRows($1_0.rows);$2.render();}});$(window).resize(function($p1_0){
SparkleXrm.GridEditor.GridDataViewBinder.$2($2,true);$2.resizeCanvas();SparkleXrm.GridEditor.GridDataViewBinder.$2($2,false);});var $3=function(){
};dataView.reset=$3;this.addRefreshButton(gridId,dataView);var $4={};$4.selectActiveRow=true;var $5=new Slick.RowSelectionModel($4);$2.setSelectionModel($5);var $6=ss.Delegate.create(this,function($p1_0,$p1_1){
var $1_0=$p1_1;this.$0=$1_0.sortCol.field;dataView.sort(ss.Delegate.create(this,this.comparer),$1_0.sortAsc);});$2.onSort.subscribe($6);return $2;},comparer:function(l,r){var $0=l;var $1=r;var $2=$0[this.$0],$3=$1[this.$0];return (($2===$3)?0:(($2 > $3)?1:-1));},bindClickHandler:function(grid){var $0=function($p1_0,$p1_1){
Xrm.Utility.openEntityForm($p1_0,$p1_1,null);};grid.onClick.subscribe(function($p1_0,$p1_1){
var $1_0=$p1_1;var $1_1=false;var $1_2=$p1_0.srcElement;var $1_3=$1_2.getAttribute('logicalName');var $1_4=$1_2.getAttribute('id');var $1_5=$1_2.getAttribute('primaryNameLookup');if(($1_3!=null&$1_4!=null)===1){$1_1=true;}else if($1_5!=null){$1_1=true;var $1_6=$1_0.grid.getDataItem($1_0.row);$1_3=$1_6.logicalName;var $1_7=$1_6.getAttributeValueString('activitytypecode');if($1_7!=null){$1_3=$1_7;}$1_4=$1_6.id;}if($1_1){$0($1_3,$1_4);$p1_0.stopImmediatePropagation();$p1_0.stopPropagation();}});grid.onDblClick.subscribe(function($p1_0,$p1_1){
var $1_0=$p1_1;var $1_1=$1_0.grid.getDataItem($1_0.row);var $1_2=$1_1.logicalName;var $1_3=$1_1.getAttributeValueString('activitytypecode');if($1_3!=null){$1_2=$1_3;}$0($1_2,$1_1.id);$p1_0.stopImmediatePropagation();$p1_0.stopPropagation();});},addValidation:function(grid,dataView){var $0=function($p1_0,$p1_1){
$p1_1.validator=function($p2_0,$p2_1){
var $2_0=dataView.gridValidationIndexer();var $2_1=$2_0($p1_0);if($2_1!=null){return $2_1($p2_0,$p2_1);}else{var $2_2={};$2_2.valid=true;return $2_2;}};};if(dataView.gridValidationIndexer()!=null){var $enum1=ss.IEnumerator.getEnumerator(grid.getColumns());while($enum1.moveNext()){var $1=$enum1.current;var $2=$1.field;$0($2,$1);}}},dataBindSelectionModel:function(grid,dataView){var $0={};$0.selectActiveRow=this.selectActiveRow;$0.multiRowSelect=this.multiSelect;var $1=new Slick.RowSelectionModel($0);var $2=false;$1.onSelectedRangesChanged.subscribe(function($p1_0,$p1_1){
if($2){return;}$2=true;var $1_0=dataView.getSelectedRows();var $1_1=$p1_1;var $1_2=$1_0.length!==$1_1.length;if(!$1_2){for(var $1_3=0;$1_3<$1_0.length;$1_3++){if($1_0[$1_3].fromRow!==$1_1[$1_3].fromRow){$1_2=true;break;}}}if($1_2){dataView.raiseOnSelectedRowsChanged($1_1);}$2=false;});dataView.add_onSelectedRowsChanged(function(){
if($2){return;}$2=true;var $1_0=dataView.getSelectedRows();var $1_1=new Array($1_0.length);for(var $1_2=0;$1_2<$1_1.length;$1_2++){$1_1[$1_2]=$1_0[$1_2].fromRow;}grid.setSelectedRows($1_1);$2=false;});grid.setSelectionModel($1);},addRefreshButton:function(gridId,dataView){var $0=$('#'+gridId);var $1=$("<div id='refreshButton' class='sparkle-grid-refresh-button' style='left: auto; right: 0px; display: inline;'><a href='#' id='refreshButtonLink' tabindex='0'><span id='grid_refresh' class='sparkle-grid-refresh-button-img' style='cursor:pointer'></span></a></div>").appendTo($0);$1.find('#refreshButtonLink').click(function($p1_0){
dataView.reset();dataView.refresh();});},dataBindEvents:function(grid,dataView,gridContainerDivId){grid.onSort.subscribe(function($p1_0,$p1_1){
var $1_0=$p1_1;dataView.sort($1_0);grid.invalidate();grid.render();});grid.onAddNewRow.subscribe(function($p1_0,$p1_1){
var $1_0=$p1_1;dataView.addItem($1_0.item);var $1_1=$1_0.column;grid.invalidateRow(dataView.getLength()-1);grid.updateRowCount();grid.render();});dataView.onRowsChanged.subscribe(function($p1_0,$p1_1){
var $1_0=$p1_1;if($1_0!=null&&$1_0.rows!=null){grid.invalidateRows($1_0.rows);grid.render();}else{grid.invalidateRow(dataView.getLength());grid.updateRowCount();grid.render();}grid.resizeCanvas();});var $0=null;var $1=null;var $2=function($p1_0,$p1_1){
if($1!=null){$1.hide();$1.remove();}};grid.onCellChange.subscribe($2);grid.onActiveCellChanged.subscribe($2);grid.onBeforeCellEditorDestroy.subscribe($2);grid.onValidationError.subscribe(ss.Delegate.create(this,function($p1_0,$p1_1){
var $1_0=$p1_1;var $1_1=$1_0.validationResults;var $1_2=$1_0.cellNode;var $1_3=$1_0.editor;var $1_4='';if($1_1.message!=null){$1_4=$1_1.message;}var $1_5=$1_1.valid;if(!$1_5){$($1_2).attr('title',$1_4);$2($p1_0,$p1_1);$1=$("<div class='popup-box-container'><div width='16px' height='16px' class='sparkle-imagestrip-inlineedit_warning popup-box-icon' alt='Error' id='icon'/><div class='popup-box validation-text'/></div>").appendTo(document.body);$1.find('.validation-text').text($1_4);var $1_6=(this.validationPopupUseFitPosition)?'fit fit':'none none';$1.position({
my: 'left bottom',
at: 'left top',
collision: '$1_6',
of: $1_2
})
.show({
effect: 'blind'
})
.delay( 500000 )
.hide({
effect: 'fade',
duration: 'slow'
},
function() {
$( this ).remove();
});
;}else{$2($p1_0,$p1_1);$($1_2).attr('title','');}}));dataView.onDataLoading.subscribe(function($p1_0,$p1_1){
$0=SparkleXrm.GridEditor.GridDataViewBinder.$3($0,gridContainerDivId);var $enum1=ss.IEnumerator.getEnumerator(grid.getColumns());while($enum1.moveNext()){var $1_0=$enum1.current;if($1_0.maxWidth!=null){$1_0.maxWidth=400;}}});dataView.onDataLoaded.subscribe(function($p1_0,$p1_1){
var $1_0=grid.getSortColumns();var $1_1=$1_0==null||!$1_0.length;var $1_2=dataView.getSortColumns();var $1_3=$1_2==null||!$1_2.length;if($1_1&&!$1_3){grid.setSortColumn($1_2[0].attributeName,$1_2[0].ascending);}var $1_4=$p1_1;if($1_4!=null){if($1_4.errorMessage==null){for(var $1_5=$1_4.from;$1_5<=$1_4.to;$1_5++){grid.invalidateRow($1_5);}grid.updateRowCount();grid.render();}else{alert('There was a problem refreshing the grid.\nPlease contact your system administrator:\n'+$1_4.errorMessage);}}if($0!=null){$0.unblock();}});grid.onCellChange.subscribe(function($p1_0,$p1_1){
var $1_0=$p1_1;dataView.raisePropertyChanged('');});},bindCommitEdit:function(vm){vm.add_onCommitEdit(ss.Delegate.create(this,function($p1_0,$p1_1){
if(this.$1.getEditorLock().isActive()){$p1_1.cancel=!this.$1.getEditorLock().commitCurrentEdit();}}));}}
SparkleXrm.GridEditor.GridEditorBase=function(args){this._args=args;}
SparkleXrm.GridEditor.GridEditorBase.prototype={_args:null,_item:null,destroy:function(){},show:function(){},hide:function(){},position:function(position){},focus:function(){},loadValue:function(item){this._item=item;},serializeValue:function(){return null;},applyValue:function(item,state){},raiseOnChange:function(item){var $0=Type.safeCast(item,SparkleXrm.ComponentModel.INotifyPropertyChanged);if($0!=null){$0.raisePropertyChanged(this._args.column.field);}},isValueChanged:function(){return false;},nativeValidation:function(newValue){return null;},validate:function(){var $0=this.serializeValue();var $1=this.nativeValidation($0);if($1==null&&this._args.column.validator!=null){var $2=this._args.column.validator($0,this._args.item);if(!$2.valid){$1=$2;}}if($1==null){$1={};$1.valid=true;$1.message=null;}return $1;}}
SparkleXrm.GridEditor.XrmOptionSetEditor=function(args){this.$2=new SparkleXrm.Sdk.OptionSetValue(null);SparkleXrm.GridEditor.XrmOptionSetEditor.initializeBase(this,[args]);var $0=this;var $1=args.column.options;if(this.$0==null){if($1.getOptionSetsDelegate!=null){this.$0=$1.getOptionSetsDelegate(args.item);}else{this.$0=SparkleXrm.Sdk.Metadata.MetadataCache.getOptionSetValues($1.entityLogicalName,$1.attributeLogicalName,$1.allowEmpty);}}this.createSelect($0);}
SparkleXrm.GridEditor.XrmOptionSetEditor.formatter=function(row,cell,value,columnDef,dataContext){var $0=value;return ($0==null)?'':$0.name;}
SparkleXrm.GridEditor.XrmOptionSetEditor.bindColumn=function(column,entityLogicalName,attributeLogicalName,allowEmpty){column.editor=SparkleXrm.GridEditor.XrmOptionSetEditor.editorFactory;column.formatter=SparkleXrm.GridEditor.XrmOptionSetEditor.formatter;var $0={};$0.attributeLogicalName=attributeLogicalName;$0.entityLogicalName=entityLogicalName;$0.allowEmpty=allowEmpty;column.options=$0;return column;}
SparkleXrm.GridEditor.XrmOptionSetEditor.bindColumnWithOptions=function(column,options){column.editor=SparkleXrm.GridEditor.XrmOptionSetEditor.editorFactory;column.formatter=SparkleXrm.GridEditor.XrmOptionSetEditor.formatter;column.options=options;return column;}
SparkleXrm.GridEditor.XrmOptionSetEditor.prototype={$0:null,$1:null,createSelect:function(self){var $0='<SELECT>';var $enum1=ss.IEnumerator.getEnumerator(this.$0);while($enum1.moveNext()){var $1=$enum1.current;$0+=String.format('<OPTION title="{0}" value="{1}" {2}>{0}</OPTION>',$1.name,$1.value,(self.$2.value===$1.value)?'selected':'');}$0+='</SELECT>';self.$1=$($0);self.$1.bind('keydown.nav',function($p1_0){
if($p1_0.which===40||$p1_0.which===38){$p1_0.stopImmediatePropagation();}});self.$1.appendTo(this._args.container);self.$1.focus().select();},destroy:function(){if(this.$1!=null){this.$1.remove();}},focus:function(){this.$1.focus();},loadValue:function(item){var $0=item[this._args.column.field];this.$2=$0;this.$4();},serializeValue:function(){if(this.$1!=null){var $0=new SparkleXrm.Sdk.OptionSetValue(this.$3());$0.name=$('option:selected',this.$1).text();return $0;}else{return null;}},applyValue:function(item,state){var $0=state;item[this._args.column.field]=$0;item[this._args.column.field+'name']=$0.name;var $1=Type.safeCast((item),SparkleXrm.ComponentModel.INotifyPropertyChanged);if($1!=null){$1.raisePropertyChanged(this._args.column.field);}},isValueChanged:function(){if(this.$1!=null){var $0=(this.$2!=null&&this.$2.value!=null)?this.$2.value.toString():'';return (this.$1.val()!==$0);}else{return false;}},$3:function(){var $0=this.$1.val();if(String.isNullOrEmpty($0)){return null;}else{return parseInt($0);}},$4:function(){if(this.$1!=null){this.$1.val((this.$2!=null&&this.$2.value!=null)?this.$2.value.toString():null);this.$1.select();}}}
Type.registerNamespace('SparkleXrm');SparkleXrm.LocalisedContentLoader=function(){}
SparkleXrm.LocalisedContentLoader.loadContent=function(webresourceFileName,lcid,callback){var $0=SparkleXrm.LocalisedContentLoader.supportedLCIDs.contains(0)||SparkleXrm.LocalisedContentLoader.supportedLCIDs.contains(lcid);if(!$0||(lcid===SparkleXrm.LocalisedContentLoader.fallBackLCID)){callback();return;}var $1=webresourceFileName.lastIndexOf('.');var $2=Xrm.Page.context.getClientUrl()+'/'+SparkleXrm.Xrm.PageEx.getCacheKey()+'WebResources/'+webresourceFileName.substr(0,$1)+'_'+lcid.toString()+webresourceFileName.substr($1);var $3={};$3.type='GET';$3.url=$2;$3.dataType='script';$3.cache=true;$3.success=function($p1_0,$p1_1,$p1_2){
callback();};$3.error=function($p1_0,$p1_1,$p1_2){
alert(String.format("Could not load resource file '{0}'. Please contact your system adminsitrator.\n\n{1}:{2}",$2,$p1_1,$p1_2.message));callback();};$.ajax($3);}
SparkleResourceStrings=function(){}
SparkleXrm.ValidationRules=function(){}
SparkleXrm.ValidationRules.areValid=function(fields){var $0=true;var $enum1=ss.IEnumerator.getEnumerator(fields);while($enum1.moveNext()){var $1=$enum1.current;$0=$0&&($1).isValid();if(!$0){break;}}return $0;}
SparkleXrm.ValidationRules.createRules=function(){return new SparkleXrm.ValidationRules();}
SparkleXrm.ValidationRules.convertToGridValidation=function(ruleDelegate){var $0=function($p1_0,$p1_1){
var $1_0=new SparkleXrm.ValidationRules();$1_0=ruleDelegate($1_0,$p1_1,null);var $1_1={};$1_1.valid=true;var $1_2=$1_0;var $enum1=ss.IEnumerator.getEnumerator(Object.keys($1_2));while($enum1.moveNext()){var $1_3=$enum1.current;if(Object.keyExists(ko.validation.rules,$1_3)){var $1_4=ko.validation.rules[$1_3];var $1_5=$1_2[$1_3];$1_1.valid=$1_4.validator($p1_0,($1_5.params==null)?$1_4.params:$1_5.params);$1_1.message=(String.isNullOrEmpty($1_4.message))?$1_5.message:$1_4.message;}else if($1_3==='validation'){var $1_6=$1_2[$1_3];var $enum2=ss.IEnumerator.getEnumerator($1_6);while($enum2.moveNext()){var $1_7=$enum2.current;$1_1.valid=$1_7.validator($p1_0);$1_1.message=$1_7.message;if(!$1_1.valid){break;}}}if(!$1_1.valid){break;}}return $1_1;};return $0;}
SparkleXrm.ValidationRules.prototype={register:function(model){(model).extend(this);},addRequired:function(){this['required']=true;return this;},addRequiredMsg:function(message){this['required']=new SparkleXrm.ValidationMessage(message);return this;},addRule:function(message,validator){var $0=new SparkleXrm.AnonymousRule();var $1=this['validation'];if($1==null){$1=[];this['validation']=$1;}$0.message=message;$0.validator=validator;$1.add($0);return this;},addPattern:function(message,pattern){var $0={};$0.message=message;$0.params=pattern;this['pattern']=$0;return this;},addCustom:function(type,options){this[type]=options;return this;}}
SparkleXrm.AnonymousRule=function(){}
SparkleXrm.AnonymousRule.prototype={validator:null,message:null}
SparkleXrm.ValidationMessage=function(message){this.message=message;}
SparkleXrm.ValidationMessage.prototype={message:null}
SparkleXrm.ValidationBinder=function(){}
SparkleXrm.ValidationBinder.prototype={register:function(fieldName,rule){}}
SparkleXrm.DataViewValidationBinder=function(){this.$0={};SparkleXrm.DataViewValidationBinder.initializeBase(this);}
SparkleXrm.DataViewValidationBinder.prototype={register:function(fieldName,rule){this.$0[fieldName]=rule;},gridValidationIndexer:function(attributeLogicalName){if(this.$0[attributeLogicalName]!=null){return SparkleXrm.ValidationRules.convertToGridValidation(this.$0[attributeLogicalName]);}else{return null;}}}
SparkleXrm.ObservableValidationBinder=function(observable){SparkleXrm.ObservableValidationBinder.initializeBase(this);this.$0=observable;}
SparkleXrm.ObservableValidationBinder.prototype={$0:null,register:function(fieldName,ruleDelegate){var $0=ko.utils.unwrapObservable(this.$0);var $1=$0[fieldName];var $2=ruleDelegate(SparkleXrm.ValidationRules.createRules(),this.$0,null);($1).extend($2);}}
SparkleXrm.ViewBase=function(){}
SparkleXrm.ViewBase.registerViewModel=function(viewModel){$(function(){
if(!SparkleXrm.ViewBase.$0){$.get(SparkleXrm.ViewBase.sparkleXrmTemplatePath,function($p2_0){
$('body').append($p2_0);ko.validation.registerExtenders();SparkleXrm.Sdk.OrganizationServiceProxy.getUserSettings();SparkleXrm.ViewBase.$0=true;ko.applyBindings(viewModel);});}else{ko.applyBindings(viewModel);}});}
SparkleXrm.ViewModelBase=function(){this.isBusy=ko.observable(false);this.isBusyProgress=ko.observable(null);this.isBusyMessage=ko.observable('Please Wait...');}
SparkleXrm.ViewModelBase.prototype={add_onCommitEdit:function(value){this.$0=ss.Delegate.combine(this.$0,value);},remove_onCommitEdit:function(value){this.$0=ss.Delegate.remove(this.$0,value);},$0:null,commitEdit:function(){if(this.$0!=null){var $0=new ss.CancelEventArgs();this.$0(this,$0);return !$0.cancel;}return true;}}
SparkleXrm.DoubleClickBindingHandler=function(){SparkleXrm.DoubleClickBindingHandler.initializeBase(this);}
SparkleXrm.DoubleClickBindingHandler.prototype={$1_0:400,$1_1:0,init:function(element,valueAccessor,allBindingsAccessor,viewModel,context){var $0=valueAccessor;$(null,element).click(ss.Delegate.create(this,function($p1_0){
if(!!this.$1_1){window.clearTimeout(0);this.$1_1=0;}else{this.$1_1=window.setTimeout(ss.Delegate.create(this,function(){
this.$1_1=0;$0();}),this.$1_0);}}));}}
Type.registerNamespace('SparkleXrm.Validation');SparkleXrm.Validation.DurationValidation=function(){}
SparkleXrm.Validation.DurationValidation.validator=function(val,otherval){var $0=SparkleXrm.Sdk.DateTimeEx.addTimeToDate(Date.get_now(),val);return $0!=null;}
SparkleXrm.Validation.TimeValidation=function(){}
SparkleXrm.Validation.TimeValidation.validator=function(val,otherval){var $0=SparkleXrm.Sdk.DateTimeEx.addTimeToDate(Date.get_now(),val);return $0!=null;}
SparkleXrm.CustomBinding.EnterKeyBinding.registerClass('SparkleXrm.CustomBinding.EnterKeyBinding',Object);SparkleXrm.CustomBinding.XrmCurrencySymbolBinding.registerClass('SparkleXrm.CustomBinding.XrmCurrencySymbolBinding',Object);SparkleXrm.CustomBinding.XrmMoneyBinding.registerClass('SparkleXrm.CustomBinding.XrmMoneyBinding',Object);SparkleXrm.CustomBinding.XrmNumericBinding.registerClass('SparkleXrm.CustomBinding.XrmNumericBinding',Object);SparkleXrm.CustomBinding.XrmOptionSetBinding.registerClass('SparkleXrm.CustomBinding.XrmOptionSetBinding',Object);SparkleXrm.CustomBinding.AnimateVisible.registerClass('SparkleXrm.CustomBinding.AnimateVisible',Object);SparkleXrm.CustomBinding.AutocompleteBinding.registerClass('SparkleXrm.CustomBinding.AutocompleteBinding',Object);SparkleXrm.CustomBinding.XrmBooleanBinding.registerClass('SparkleXrm.CustomBinding.XrmBooleanBinding',Object);SparkleXrm.CustomBinding.XrmLookupBinding.registerClass('SparkleXrm.CustomBinding.XrmLookupBinding',Object);SparkleXrm.CustomBinding.XrmTextBinding.registerClass('SparkleXrm.CustomBinding.XrmTextBinding',Object);SparkleXrm.CustomBinding.XrmDatePickerBinding.registerClass('SparkleXrm.CustomBinding.XrmDatePickerBinding',Object);SparkleXrm.CustomBinding.XrmDurationBinding.registerClass('SparkleXrm.CustomBinding.XrmDurationBinding',Object);SparkleXrm.CustomBinding.FadeVisibleBinding.registerClass('SparkleXrm.CustomBinding.FadeVisibleBinding',Object);SparkleXrm.CustomBinding.ProgressBarBinding.registerClass('SparkleXrm.CustomBinding.ProgressBarBinding',Object);SparkleXrm.CustomBinding.XrmTimeOfDayBinding.registerClass('SparkleXrm.CustomBinding.XrmTimeOfDayBinding',Object);SparkleXrm.GridEditor.SortCol.registerClass('SparkleXrm.GridEditor.SortCol');SparkleXrm.GridEditor.GridEditorBase.registerClass('SparkleXrm.GridEditor.GridEditorBase');SparkleXrm.GridEditor.XrmBooleanEditor.registerClass('SparkleXrm.GridEditor.XrmBooleanEditor',SparkleXrm.GridEditor.GridEditorBase);SparkleXrm.GridEditor.XrmMoneyEditor.registerClass('SparkleXrm.GridEditor.XrmMoneyEditor',SparkleXrm.GridEditor.GridEditorBase);SparkleXrm.GridEditor.XrmNumberEditor.registerClass('SparkleXrm.GridEditor.XrmNumberEditor',SparkleXrm.GridEditor.GridEditorBase);SparkleXrm.GridEditor.DataViewBase.registerClass('SparkleXrm.GridEditor.DataViewBase',null,Object,Object);SparkleXrm.GridEditor.EntityDataViewModel.registerClass('SparkleXrm.GridEditor.EntityDataViewModel',SparkleXrm.GridEditor.DataViewBase);SparkleXrm.GridEditor.XrmDateEditor.registerClass('SparkleXrm.GridEditor.XrmDateEditor',SparkleXrm.GridEditor.GridEditorBase);SparkleXrm.GridEditor.XrmDurationEditor.registerClass('SparkleXrm.GridEditor.XrmDurationEditor',SparkleXrm.GridEditor.GridEditorBase);SparkleXrm.GridEditor.XrmLookupEditorOptions.registerClass('SparkleXrm.GridEditor.XrmLookupEditorOptions');SparkleXrm.GridEditor.XrmLookupEditorButton.registerClass('SparkleXrm.GridEditor.XrmLookupEditorButton');SparkleXrm.GridEditor.XrmLookupEditor.registerClass('SparkleXrm.GridEditor.XrmLookupEditor',SparkleXrm.GridEditor.GridEditorBase);SparkleXrm.GridEditor.CrmPagerControl.registerClass('SparkleXrm.GridEditor.CrmPagerControl');SparkleXrm.GridEditor.XrmTextEditor.registerClass('SparkleXrm.GridEditor.XrmTextEditor',SparkleXrm.GridEditor.GridEditorBase);SparkleXrm.GridEditor.XrmTimeEditor.registerClass('SparkleXrm.GridEditor.XrmTimeEditor',SparkleXrm.GridEditor.GridEditorBase);SparkleXrm.GridEditor.Formatters.registerClass('SparkleXrm.GridEditor.Formatters');SparkleXrm.GridEditor.GridDataViewBinder.registerClass('SparkleXrm.GridEditor.GridDataViewBinder');SparkleXrm.GridEditor.XrmOptionSetEditor.registerClass('SparkleXrm.GridEditor.XrmOptionSetEditor',SparkleXrm.GridEditor.GridEditorBase);SparkleXrm.LocalisedContentLoader.registerClass('SparkleXrm.LocalisedContentLoader');SparkleResourceStrings.registerClass('SparkleResourceStrings');SparkleXrm.ValidationRules.registerClass('SparkleXrm.ValidationRules');SparkleXrm.AnonymousRule.registerClass('SparkleXrm.AnonymousRule');SparkleXrm.ValidationMessage.registerClass('SparkleXrm.ValidationMessage');SparkleXrm.ValidationBinder.registerClass('SparkleXrm.ValidationBinder');SparkleXrm.DataViewValidationBinder.registerClass('SparkleXrm.DataViewValidationBinder',SparkleXrm.ValidationBinder);SparkleXrm.ObservableValidationBinder.registerClass('SparkleXrm.ObservableValidationBinder',SparkleXrm.ValidationBinder);SparkleXrm.ViewBase.registerClass('SparkleXrm.ViewBase');SparkleXrm.ViewModelBase.registerClass('SparkleXrm.ViewModelBase');SparkleXrm.DoubleClickBindingHandler.registerClass('SparkleXrm.DoubleClickBindingHandler',Object);SparkleXrm.Validation.DurationValidation.registerClass('SparkleXrm.Validation.DurationValidation');SparkleXrm.Validation.TimeValidation.registerClass('SparkleXrm.Validation.TimeValidation');(function(){if(typeof(ko)!=='undefined'){ko.bindingHandlers['enterKey']=new SparkleXrm.CustomBinding.EnterKeyBinding();}})();
(function(){if(typeof(ko)!=='undefined'){ko.bindingHandlers['xrmcurrencysymbol']=new SparkleXrm.CustomBinding.XrmCurrencySymbolBinding();ko.validation.makeBindingHandlerValidatable('xrmcurrencysymbol');}})();
(function(){if(typeof(ko)!=='undefined'){ko.bindingHandlers['xrmmoney']=new SparkleXrm.CustomBinding.XrmMoneyBinding();ko.validation.makeBindingHandlerValidatable('xrmmoney');}})();
(function(){if(typeof(ko)!=='undefined'){ko.bindingHandlers['xrmnumeric']=new SparkleXrm.CustomBinding.XrmNumericBinding();ko.validation.makeBindingHandlerValidatable('xrmnumeric');}})();
(function(){if(typeof(ko)!=='undefined'){ko.bindingHandlers['optionset']=new SparkleXrm.CustomBinding.XrmOptionSetBinding();ko.validation.makeBindingHandlerValidatable('optionset');}})();
(function(){if(typeof(ko)!=='undefined'){ko.bindingHandlers['animateVisible']=new SparkleXrm.CustomBinding.AnimateVisible();}})();
(function(){if(typeof(ko)!=='undefined'){ko.bindingHandlers['autocomplete']=new SparkleXrm.CustomBinding.AutocompleteBinding();}})();
(function(){if(typeof(ko)!=='undefined'){ko.bindingHandlers['booleanValue']=new SparkleXrm.CustomBinding.XrmBooleanBinding();ko.validation.makeBindingHandlerValidatable('booleanValue');}})();
(function(){if(typeof(ko)!=='undefined'){ko.bindingHandlers['lookup']=new SparkleXrm.CustomBinding.XrmLookupBinding();}})();
(function(){if(typeof(ko)!=='undefined'){ko.bindingHandlers['xrmtextbox']=new SparkleXrm.CustomBinding.XrmTextBinding();ko.validation.makeBindingHandlerValidatable('xrmtextbox');}})();
(function(){if(typeof(ko)!=='undefined'){ko.bindingHandlers['datepicker']=new SparkleXrm.CustomBinding.XrmDatePickerBinding();ko.validation.makeBindingHandlerValidatable('datepicker');}})();
(function(){if(typeof(ko)!=='undefined'){ko.bindingHandlers['duration']=new SparkleXrm.CustomBinding.XrmDurationBinding();ko.validation.makeBindingHandlerValidatable('duration');}})();
(function(){if(typeof(ko)!=='undefined'){ko.bindingHandlers['fadeVisible']=new SparkleXrm.CustomBinding.FadeVisibleBinding();}})();
(function(){if(typeof(ko)!=='undefined'){ko.bindingHandlers['progressBar']=new SparkleXrm.CustomBinding.ProgressBarBinding();}})();
(function(){if(typeof(ko)!=='undefined'){ko.bindingHandlers['timeofday']=new SparkleXrm.CustomBinding.XrmTimeOfDayBinding();}})();
SparkleXrm.GridEditor.XrmBooleanEditor.booleanEditor=null;(function(){SparkleXrm.GridEditor.XrmBooleanEditor.booleanEditor=function($p1_0){
var $1_0=new SparkleXrm.GridEditor.XrmBooleanEditor($p1_0);return $1_0;};})();
SparkleXrm.GridEditor.XrmMoneyEditor.moneyEditor=null;(function(){SparkleXrm.GridEditor.XrmMoneyEditor.moneyEditor=function($p1_0){
var $1_0=new SparkleXrm.GridEditor.XrmMoneyEditor($p1_0);return $1_0;};})();
SparkleXrm.GridEditor.XrmNumberEditor.numberEditor=null;(function(){SparkleXrm.GridEditor.XrmNumberEditor.numberEditor=function($p1_0){
var $1_0=new SparkleXrm.GridEditor.XrmNumberEditor($p1_0);return $1_0;};})();
SparkleXrm.GridEditor.XrmDateEditor.crmDateEditor=null;(function(){SparkleXrm.GridEditor.XrmDateEditor.crmDateEditor=function($p1_0){
var $1_0=new SparkleXrm.GridEditor.XrmDateEditor($p1_0);return $1_0;};})();
SparkleXrm.GridEditor.XrmDurationEditor.durationEditor=null;(function(){SparkleXrm.GridEditor.XrmDurationEditor.durationEditor=function($p1_0){
var $1_0=new SparkleXrm.GridEditor.XrmDurationEditor($p1_0);return $1_0;};})();
SparkleXrm.GridEditor.XrmLookupEditor.lookupEditor=null;(function(){SparkleXrm.GridEditor.XrmLookupEditor.lookupEditor=function($p1_0){
var $1_0=new SparkleXrm.GridEditor.XrmLookupEditor($p1_0);return $1_0;};})();
SparkleXrm.GridEditor.XrmTextEditor.textEditor=null;(function(){SparkleXrm.GridEditor.XrmTextEditor.textEditor=function($p1_0){
var $1_0=new SparkleXrm.GridEditor.XrmTextEditor($p1_0);return $1_0;};})();
SparkleXrm.GridEditor.XrmTimeEditor.timeEditor=null;(function(){SparkleXrm.GridEditor.XrmTimeEditor.timeEditor=function($p1_0){
var $1_0=new SparkleXrm.GridEditor.XrmTimeEditor($p1_0);return $1_0;};})();
SparkleXrm.GridEditor.XrmOptionSetEditor.editorFactory=null;(function(){SparkleXrm.GridEditor.XrmOptionSetEditor.editorFactory=function($p1_0){
var $1_0=new SparkleXrm.GridEditor.XrmOptionSetEditor($p1_0);return $1_0;};})();
SparkleXrm.LocalisedContentLoader.supportedLCIDs=new Array(1033);SparkleXrm.LocalisedContentLoader.fallBackLCID=1033;SparkleResourceStrings.LookupFooter='{0} Result(s)';SparkleResourceStrings.NoRecordsFound='No records found.';SparkleXrm.ViewBase.$0=false;SparkleXrm.ViewBase.sparkleXrmTemplatePath='../../sparkle_/html/form.templates.htm';(function(){if(typeof(ko)!=='undefined'){ko.bindingHandlers['singleClick']=new SparkleXrm.DoubleClickBindingHandler();}})();
(function(){if(typeof(ko)!=='undefined'){var $0={};$0.message='{0} is an invalid duration.';$0.validator=SparkleXrm.Validation.DurationValidation.validator;ko.validation.rules['durationValidation']=$0;}})();
(function(){if(typeof(ko)!=='undefined'){var $0={};$0.message='{0} is an invalid time.';$0.validator=SparkleXrm.Validation.TimeValidation.validator;ko.validation.rules['timeValidation']=$0;}})();
})(window.xrmjQuery);