json-object-editor 0.10.624 → 0.10.632

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/js/joe.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /* --------------------------------------------------------
2
2
  *
3
- * json-object-editor - v0.10.623
3
+ * json-object-editor - v0.10.632
4
4
  * Created by: Corey Hadden
5
5
  *
6
6
  * -------------------------------------------------------- */
@@ -572,8 +572,11 @@ function JsonObjectEditor(specs){
572
572
  window.onkeydown = function (e) {
573
573
  var code = e.keyCode
574
574
  var nonBackElements = ['input','select','textarea'];
575
- var isInputElement = nonBackElements.indexOf(e.target.tagName.toLowerCase()) != -1;
576
- var isEditable = e.target.isContentEditable || $(e.target).closest('joe-ai-chatbox').length;
575
+ var isInputElement = nonBackElements.indexOf((e.target && e.target.tagName && e.target.tagName.toLowerCase()) || '') != -1;
576
+ var isEditable =
577
+ e.target.isContentEditable ||
578
+ $(e.target).closest('joe-ai-chatbox').length ||
579
+ $(e.target).closest('joe-ai-widget').length;
577
580
 
578
581
  if (code == 8) {//BACKBUTTON PRESSED
579
582
  if(isInputElement || isEditable){
@@ -3488,6 +3491,25 @@ this.renderHTMLContent = function(specs){
3488
3491
  break;
3489
3492
  }
3490
3493
 
3494
+ // AI autofill helper button: when a field has an `ai` config and the
3495
+ // global `_joe.Ai.populateField` helper is available, render a small
3496
+ // inline button that triggers the autofill flow for this field.
3497
+ if (prop.ai) {
3498
+ try{
3499
+ var aiLabel = self.propAsFuncOrValue(prop.ai.label) || 'AI';
3500
+ var fieldName = prop.name || '';
3501
+ html +=
3502
+ '<button type="button" class="joe-ai-autofill-button joe-iconed-button joe-button" ' +
3503
+ 'onclick="if(window._joe && _joe.Ai && _joe.Ai.populateField){_joe.Ai.populateField(\''+fieldName+'\');}" ' +
3504
+ 'title="Let AI suggest a value for this field">'+
3505
+ aiLabel+
3506
+ '</button>'
3507
+ +'<div class="clear"></div>';
3508
+ }catch(_e){
3509
+ // fail silently if something about the ai config is invalid
3510
+ }
3511
+ }
3512
+
3491
3513
  //_bmResponse(joeFieldBenchmarker,'Joe rendered '+(prop.name||"a field"));
3492
3514
  //logit('Joe rendered '+(prop.name||"a field")+' in '+joeFieldBenchmarker.stop()+' seconds');
3493
3515
  return html;
@@ -9932,7 +9954,16 @@ logit(intent)
9932
9954
 
9933
9955
  return html;
9934
9956
  },
9935
-
9957
+ userBar:function(userid,cssclass,dataset,nameprop){
9958
+ var user = _joe.Data[dataset || 'user'].where({_id:userid})[0] || false;
9959
+ if(!user){
9960
+ return '';
9961
+ }
9962
+ var name = user[nameprop || 'name'] || user.fullname || user.name;
9963
+ return '<joe-user-bar title="'+ name+'" style="background-color:'+user.color+'" class="joe-initials '+css+'">'
9964
+ +name
9965
+ +'</joe-user-bar>';
9966
+ },
9936
9967
  }
9937
9968
  },
9938
9969
  handleUpdate:function(payload){