2017-07-04 01:23:32 +08:00
/ * !
* jsoneditor . js
*
* @ brief
* JSONEditor is a web - based tool to view , edit , format , and validate JSON .
* It has various modes such as a tree editor , a code editor , and a plain text
* editor .
*
* Supported browsers : Chrome , Firefox , Safari , Opera , Internet Explorer 8 +
*
* @ license
* Licensed under the Apache License , Version 2.0 ( the "License" ) ; you may not
* use this file except in compliance with the License . You may obtain a copy
* of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS , WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . See the
* License for the specific language governing permissions and limitations under
* the License .
*
2019-01-05 22:21:54 +08:00
* Copyright ( c ) 2011 - 2019 Jos de Jong , http : //jsoneditoronline.org
2017-07-04 01:23:32 +08:00
*
* @ author Jos de Jong , < wjosdejong @ gmail . com >
2019-06-13 02:53:48 +08:00
* @ version 6.0 . 0
* @ date 2019 - 06 - 12
2017-07-04 01:23:32 +08:00
* /
2019-06-13 02:53:48 +08:00
! function ( e , t ) { "object" == typeof exports && "object" == typeof module ? module . exports = t ( ) : "function" == typeof define && define . amd ? define ( [ ] , t ) : "object" == typeof exports ? exports . JSONEditor = t ( ) : e . JSONEditor = t ( ) } ( window , function ( ) { return n = { } , o . m = i = [ function ( e , t , i ) { "use strict" ; i ( 5 ) ; var o , n = [ "en" , "pt-BR" , "zh-CN" , "tr" ] , r = { en : { array : "Array" , auto : "Auto" , appendText : "Append" , appendTitle : "Append a new field with type 'auto' after this field (Ctrl+Shift+Ins)" , appendSubmenuTitle : "Select the type of the field to be appended" , appendTitleAuto : "Append a new field with type 'auto' (Ctrl+Shift+Ins)" , ascending : "Ascending" , ascendingTitle : "Sort the childs of this ${type} in ascending order" , actionsMenu : "Click to open the actions menu (Ctrl+M)" , collapseAll : "Collapse all fields" , descending : "Descending" , descendingTitle : "Sort the childs of this ${type} in descending order" , drag : "Drag to move this field (Alt+Shift+Arrows)" , duplicateKey : "duplicate key" , duplicateText : "Duplicate" , duplicateTitle : "Duplicate selected fields (Ctrl+D)" , duplicateField : "Duplicate this field (Ctrl+D)" , duplicateFieldError : "Duplicate field name" , cannotParseFieldError : "Cannot parse field into JSON" , cannotParseValueError : "Cannot parse value into JSON" , empty : "empty" , expandAll : "Expand all fields" , expandTitle : "Click to expand/collapse this field (Ctrl+E). \nCtrl+Click to expand/collapse including all childs." , insert : "Insert" , insertTitle : "Insert a new field with type 'auto' before this field (Ctrl+Ins)" , insertSub : "Select the type of the field to be inserted" , object : "Object" , ok : "Ok" , redo : "Redo (Ctrl+Shift+Z)" , removeText : "Remove" , removeTitle : "Remove selected fields (Ctrl+Del)" , removeField : "Remove this field (Ctrl+Del)" , selectNode : "Select a node..." , showAll : "show all" , showMore : "show more" , showMoreStatus : "displaying ${visibleChilds} of ${totalChilds} items." , sort : "Sort" , sortTitle : "Sort the childs of this ${type}" , sortTitleShort : "Sort contents" , sortFieldLabel : "Field:" , sortDirectionLabel : "Direction:" , sortFieldTitle : "Select the nested field by which to sort the array or object" , sortAscending : "Ascending" , sortAscendingTitle : "Sort the selected field in ascending order" , sortDescending : "Descending" , sortDescendingTitle : "Sort the selected field in descending order" , string : "String" , transform : "Transform" , transformTitle : "Filter, sort, or transform the childs of this ${type}" , transformTitleShort : "Filter, sort, or transform contents" , transformQueryTitle : "Enter a JMESPath query" , transformWizardLabel : "Wizard" , transformWizardFilter : "Filter" , transformWizardSortBy : "Sort by" , transformWizardSelectFields : "Select fields" , transformQueryLabel : "Query" , transformPreviewLabel : "Preview" , type : "Type" , typeTitle : "Change the type of this field" , openUrl : "Ctrl+Click or Ctrl+Enter to open url in new window" , undo : "Undo last action (Ctrl+Z)" , validationCannotMove : "Cannot move a field into a child of itself" , autoType : 'Field type "auto". The field type is automatically determined from the value and can be a string, number, boolean, or null.' , objectType : 'Field type "object". An object contains an unordered set of key/value pairs.' , arrayType : 'Field type "array". An array contains an ordered collection of values.' , stringType : 'Field type "string". Field type is not determined from the value, but always returned as string.' , modeCodeText : "Code" , modeCodeTitle : "Switch to code highlighter" , modeFormText : "Form" , modeFormTitle : "Switch to form editor" , modeTextText : "Text" , modeTextTitle : "Switch to plain text editor" , modeTreeText : "Tree" , modeTreeTitle : "Switch to tree editor" , modeViewText : "View" , modeViewTitle : "Switch to tree view" , examples : "Examples" , default : "Default" } , "zh-CN" : { array : "数组" , auto : "自动" , appendText : "追加" , appendTitle : "在此字段后追加一个类型为“auto”的新字段 (Ctrl+Shift+Ins)" , appendSubmenuTitle : "选择要追加的字段类型" , appendTitleAuto : "追加类型为“auto”的新字段 (Ctrl+Shift+Ins)" , ascending : "升序" , ascendingTitle : "升序排列${type}的子节点" , actionsMenu : "点击打开动作菜单(Ctrl+M)" , collapseAll : "缩进所有字段" , descending : "降序" , descendingTitle : "降序排列${type}的子节点" , dra
) + ' </div><div class="jsoneditor-jmespath-block"> <textarea id="query" rows="4" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" title="' + o ( "transformQueryTitle" ) + '">[*]</textarea></div><div class="jsoneditor-jmespath-label">' + o ( "transformPreviewLabel" ) + ' </div><div class="jsoneditor-jmespath-block"> <textarea id="preview" class="jsoneditor-transform-preview" readonly> </textarea></div><div class="jsoneditor-jmespath-block jsoneditor-modal-actions"> <input type="submit" id="ok" value="' + o ( "ok" ) + '" autofocus /></div></div>' ; n ( { parent : e , content : t , overlayClass : "jsoneditor-modal-overlay" , modalClass : "jsoneditor-modal jsoneditor-modal-transform" , focus : ! 1 } ) . afterCreate ( function ( t ) { var e = t . modalElem ( ) , i = e . querySelector ( "#wizard" ) , n = e . querySelector ( "#ok" ) , a = e . querySelector ( "#filterField" ) , l = e . querySelector ( "#filterRelation" ) , c = e . querySelector ( "#filterValue" ) , h = e . querySelector ( "#sortField" ) , d = e . querySelector ( "#sortOrder" ) , u = e . querySelector ( "#selectFields" ) , p = e . querySelector ( "#query" ) , o = e . querySelector ( "#preview" ) ; Array . isArray ( C ) || ( i . style . fontStyle = "italic" , i . innerHTML = "(wizard not available for objects, only for arrays)" ) , _ . getChildPaths ( ) . forEach ( function ( e ) { var t = b ( e ) , i = document . createElement ( "option" ) ; i . text = t , i . value = t , a . appendChild ( i ) ; var n = document . createElement ( "option" ) ; n . text = t , n . value = t , h . appendChild ( n ) } ) ; var r = _ . getChildPaths ( ! 0 ) . filter ( function ( e ) { return "." !== e } ) ; if ( 0 < r . length ) r . forEach ( function ( e ) { var t = b ( e ) , i = document . createElement ( "option" ) ; i . text = t , i . value = t , u . appendChild ( i ) } ) ; else { var s = e . querySelector ( "#selectFieldsPart" ) ; s && ( s . style . display = "none" ) } var f = new S ( a , { defaultSelected : ! 1 , clearable : ! 0 , allowDeselect : ! 0 , placeholder : "field..." } ) , m = new S ( l , { defaultSelected : ! 1 , clearable : ! 0 , allowDeselect : ! 0 , placeholder : "compare..." } ) , g = new S ( h , { defaultSelected : ! 1 , clearable : ! 0 , allowDeselect : ! 0 , placeholder : "field..." } ) , v = new S ( d , { defaultSelected : ! 1 , clearable : ! 0 , allowDeselect : ! 0 , placeholder : "order..." } ) , y = new S ( u , { multiple : ! 0 , clearable : ! 0 , defaultSelected : ! 1 , placeholder : "select fields..." } ) ; function b ( e ) { return "." === e [ 0 ] ? "." === e ? "@" : e . slice ( 1 ) : e } function x ( ) { if ( a . value && l . value && c . value ) { var e = a . value , t = "@" !== e ? [ "0" ] . concat ( N . parsePath ( "." + e ) ) : [ "0" ] , i = "string" == typeof N . get ( C , t ) ? c . value : _ . _stringCast ( c . value ) ; p . value = "[? " + e + " " + l . value + " `" + JSON . stringify ( i ) + "`]" } else p . value = "[*]" ; if ( h . value && d . value ) { var n = h . value ; "desc" === d . value ? p . value += " | reverse(sort_by(@, &" + n + "))" : p . value += " | sort_by(@, &" + n + ")" } if ( u . value ) { for ( var o = [ ] , r = 0 ; r < u . options . length ; r ++ ) if ( u . options [ r ] . selected ) { var s = u . options [ r ] . value ; o . push ( s ) } "]" !== p . value [ p . value . length - 1 ] && ( p . value += " | [*]" ) , 1 === o . length ? p . value += "." + o [ 0 ] : 1 < o . length && ( p . value += ".{" + o . map ( function ( e ) { var t = e . split ( "." ) ; return t [ t . length - 1 ] + ": " + e } ) . join ( ", " ) + "}" ) } w ( ) } f . on ( "selectr.change" , x ) , m . on ( "selectr.change" , x ) , c . oninput = x , g . on ( "selectr.change" , x ) , v . on ( "selectr.change" , x ) , y . on ( "selectr.change" , x ) , e . querySelector ( ".pico-modal-contents" ) . onclick = function ( e ) { "A" !== e . target . nodeName && e . preventDefault ( ) } , p . value = Array . isArray ( C ) ? "[*]" : "@" ; var w = T ( function ( ) { try { var e = E . search ( C , p . value ) , t = JSON . stringify ( e , null , 2 ) . split ( "\n" ) ; 100 < t . length && ( t = t . slice ( 0 , 100 ) . concat ( [ "..." ] ) ) , o . className = "jsoneditor-transform-preview" , o . value = t . join ( "\n" ) , n . disabled = ! 1 } catch ( e ) { o . className = "jsoneditor-transform-preview jsoneditor-error" , o . value = e . toString ( ) , n . disabled = ! 0 } } , 300 ) ; ( p . oninput = w ) ( ) , n . onclick = function ( e ) { e . preventDefault ( ) , e . stopPropagation ( ) , t . close ( ) , _ . transform ( p . value ) } , setTimeout ( function ( ) { p . select ( ) , p . focus ( ) , p . selectionStart = 3 , p . selectionEnd = 3 } ) } ) . afterClose ( function ( e ) { e . destroy ( ) } ) . show ( ) } } , function ( e , t , i ) { "use strict" ; var p = i ( 2 ) , f = i ( 0 ) . translate ; function n ( e , t , i , n ) { for ( var o = { code : { text : f ( "modeCodeText" ) , title : f ( "modeCodeTitle" ) , click : function ( ) { n ( "code" ) } } , form : { text : f ( "modeFormText" ) , title : f ( "modeFormTitle" ) , click : function ( ) { n ( "form" ) } } , text : { text : f ( "modeTextText" ) , title : f ( "modeTextTitle" ) , click : function ( ) { n ( "text" ) } } , tree : { text : f ( "modeTreeText" ) , title : f ( " modeTreeTi
"action" ) ; t && r [ t ] ? r [ t ] ( ) : r . $searchBarKb . commands [ t ] && r . $searchBarKb . commands [ t ] . exec ( r ) , s . stopPropagation ( e ) } ) , s . addCommandKeyListener ( e , function ( e , t , i ) { var n = a . keyCodeToString ( i ) , o = r . $searchBarKb . findKeyCommand ( t , n ) ; o && o . exec && ( o . exec ( r ) , s . stopEvent ( e ) ) } ) , this . $onChange = n . delayedCall ( function ( ) { r . find ( ! 1 , ! 1 ) } ) , s . addListener ( this . searchInput , "input" , function ( ) { r . $onChange . schedule ( 20 ) } ) , s . addListener ( this . searchInput , "focus" , function ( ) { r . activeInput = r . searchInput , r . searchInput . value && r . highlight ( ) } ) , s . addListener ( this . replaceInput , "focus" , function ( ) { r . activeInput = r . replaceInput , r . searchInput . value && r . highlight ( ) } ) } , this . $closeSearchBarKb = new r ( [ { bindKey : "Esc" , name : "closeSearchBar" , exec : function ( e ) { e . searchBox . hide ( ) } } ] ) , this . $searchBarKb = new r , this . $searchBarKb . bindKeys ( { "Ctrl-f|Command-f" : function ( e ) { var t = e . isReplace = ! e . isReplace ; e . replaceBox . style . display = t ? "" : "none" , e . replaceOption . checked = ! 1 , e . $syncOptions ( ) , e . searchInput . focus ( ) } , "Ctrl-H|Command-Option-F" : function ( e ) { e . replaceOption . checked = ! 0 , e . $syncOptions ( ) , e . replaceInput . focus ( ) } , "Ctrl-G|Command-G" : function ( e ) { e . findNext ( ) } , "Ctrl-Shift-G|Command-Shift-G" : function ( e ) { e . findPrev ( ) } , esc : function ( e ) { setTimeout ( function ( ) { e . hide ( ) } ) } , Return : function ( e ) { e . activeInput == e . replaceInput && e . replace ( ) , e . findNext ( ) } , "Shift-Return" : function ( e ) { e . activeInput == e . replaceInput && e . replace ( ) , e . findPrev ( ) } , "Alt-Return" : function ( e ) { e . activeInput == e . replaceInput && e . replaceAll ( ) , e . findAll ( ) } , Tab : function ( e ) { ( e . activeInput == e . replaceInput ? e . searchInput : e . replaceInput ) . focus ( ) } } ) , this . $searchBarKb . addCommands ( [ { name : "toggleRegexpMode" , bindKey : { win : "Alt-R|Alt-/" , mac : "Ctrl-Alt-R|Ctrl-Alt-/" } , exec : function ( e ) { e . regExpOption . checked = ! e . regExpOption . checked , e . $syncOptions ( ) } } , { name : "toggleCaseSensitive" , bindKey : { win : "Alt-C|Alt-I" , mac : "Ctrl-Alt-R|Ctrl-Alt-I" } , exec : function ( e ) { e . caseSensitiveOption . checked = ! e . caseSensitiveOption . checked , e . $syncOptions ( ) } } , { name : "toggleWholeWords" , bindKey : { win : "Alt-B|Alt-W" , mac : "Ctrl-Alt-B|Ctrl-Alt-W" } , exec : function ( e ) { e . wholeWordOption . checked = ! e . wholeWordOption . checked , e . $syncOptions ( ) } } , { name : "toggleReplace" , exec : function ( e ) { e . replaceOption . checked = ! e . replaceOption . checked , e . $syncOptions ( ) } } , { name : "searchInSelection" , exec : function ( e ) { e . searchOption . checked = ! e . searchRange , e . setSearchRange ( e . searchOption . checked && e . editor . getSelectionRange ( ) ) , e . $syncOptions ( ) } } ] ) , this . setSearchRange = function ( e ) { ( this . searchRange = e ) ? this . searchRangeMarker = this . editor . session . addMarker ( e , "ace_active-line" ) : this . searchRangeMarker && ( this . editor . session . removeMarker ( this . searchRangeMarker ) , this . searchRangeMarker = null ) } , this . $syncOptions = function ( e ) { o . setCssClass ( this . replaceOption , "checked" , this . searchRange ) , o . setCssClass ( this . searchOption , "checked" , this . searchOption . checked ) , this . replaceOption . textContent = this . replaceOption . checked ? "-" : "+" , o . setCssClass ( this . regExpOption , "checked" , this . regExpOption . checked ) , o . setCssClass ( this . wholeWordOption , "checked" , this . wholeWordOption . checked ) , o . setCssClass ( this . caseSensitiveOption , "checked" , this . caseSensitiveOption . checked ) , this . replaceBox . style . display = this . replaceOption . checked ? "" : "none" , this . find ( ! 1 , ! 1 , e ) } , this . highlight = function ( e ) { this . editor . session . highlight ( e || this . editor . $search . $options . re ) , this . editor . renderer . updateBackMarkers ( ) } , this . find = function ( e , t , i ) { var n = ! this . editor . find ( this . searchInput . value , { skipCurrent : e , backwards : t , wrap : ! 0 , regExp : this . regExpOption . checked , caseSensitive : this . caseSensitiveOption . checked , wholeWord : this . wholeWordOption . checked , preventScroll : i , range : this . searchRange } ) && this . searchInput . value ; o . setCssClass ( this . searchBox , "ace_nomatch" , n ) , this . editor . _emit ( "findSearchBox" , { match : ! n } ) , this . highlight ( ) , this . updateCounter ( ) } , this . updateCounter = function ( ) { var e = this . editor , t = e . $search . $options . re , i = 0 , n = 0 ; if ( t ) { var o = this . searchRange ? e . session . getTextRange ( this . searchRange ) : e . getValue ( ) , r = e . session . doc . positionToIndex ( e . selection . anchor ) ; this . searchRange && ( r -= e . session . doc . positionToIndex ( this . searchRange . start ) ) ; for ( var s , a = t . lastIndex = 0 ; ( s = t . exec ( o ) ) && ( i ++ , ( a = s . index ) <= r && n ++ , ! ( 999 < i ) ) && ( s [ 0 ] || ( t . lastIndex = a +=
D . prototype . containsNode = function ( e ) { if ( this == e ) return ! 0 ; var t = this . childs ; if ( t ) for ( var i = 0 , n = t . length ; i < n ; i ++ ) if ( t [ i ] . containsNode ( e ) ) return ! 0 ; return ! 1 } , D . prototype . removeChild = function ( e , t ) { if ( this . childs ) { var i = this . childs . indexOf ( e ) ; if ( - 1 !== i ) { i < this . visibleChilds && this . expanded && this . visibleChilds -- , e . hide ( ) , delete e . searchField , delete e . searchValue ; var n = this . childs . splice ( i , 1 ) [ 0 ] ; return n . parent = null , ! 1 !== t && this . updateDom ( { updateIndexes : ! 0 } ) , n } } } , D . prototype . _remove = function ( e ) { this . removeChild ( e ) } , D . prototype . changeType = function ( e ) { var t = this . type ; if ( t != e ) { if ( "string" != e && "auto" != e || "string" != t && "auto" != t ) { var i = this . _detachFromDom ( ) ; this . clearDom ( ) , "object" == ( this . type = e ) ? ( this . childs || ( this . childs = [ ] ) , this . childs . forEach ( function ( e ) { e . clearDom ( ) , delete e . index , e . fieldEditable = ! 0 , null == e . field && ( e . field = "" ) } ) , "string" != t && "auto" != t || ( this . expanded = ! 0 ) ) : "array" == e ? ( this . childs || ( this . childs = [ ] ) , this . childs . forEach ( function ( e , t ) { e . clearDom ( ) , e . fieldEditable = ! 1 , e . index = t } ) , "string" != t && "auto" != t || ( this . expanded = ! 0 ) ) : this . expanded = ! 1 , this . _attachToDom ( i ) } else this . type = e ; "auto" != e && "string" != e || ( this . value = "string" == e ? String ( this . value ) : this . _stringCast ( String ( this . value ) ) , this . focus ( ) ) , this . updateDom ( { updateIndexes : ! 0 } ) } } , D . prototype . deepEqual = function ( e ) { var t ; if ( "array" === this . type ) { if ( ! Array . isArray ( e ) ) return ! 1 ; if ( this . childs . length !== e . length ) return ! 1 ; for ( t = 0 ; t < this . childs . length ; t ++ ) if ( ! this . childs [ t ] . deepEqual ( e [ t ] ) ) return ! 1 } else if ( "object" === this . type ) { if ( "object" != typeof e || ! e ) return ! 1 ; var i = { } , n = 0 ; for ( t = 0 ; t < this . childs . length ; t ++ ) { var o = this . childs [ t ] ; if ( ! i [ o . field ] ) { if ( i [ o . field ] = ! 0 , n ++ , ! ( o . field in e ) ) return ! 1 ; if ( ! o . deepEqual ( e [ o . field ] ) ) return ! 1 } } if ( n !== Object . keys ( e ) . length ) return ! 1 } else if ( this . value !== e ) return ! 1 ; return ! 0 } , D . prototype . _getDomValue = function ( ) { if ( this . _clearValueError ( ) , this . dom . value && "array" != this . type && "object" != this . type && ( this . valueInnerText = A . getInnerText ( this . dom . value ) ) , null != this . valueInnerText ) try { var e ; if ( "string" == this . type ) e = this . _unescapeHTML ( this . valueInnerText ) ; else { var t = this . _unescapeHTML ( this . valueInnerText ) ; e = this . _stringCast ( t ) } e !== this . value && ( this . value = e , this . _debouncedOnChangeValue ( ) ) } catch ( e ) { this . _setValueError ( u ( "cannotParseValueError" ) ) } } , D . prototype . _setValueError = function ( e ) { this . valueError = { message : e } , this . updateError ( ) } , D . prototype . _clearValueError = function ( ) { this . valueError && ( this . valueError = null , this . updateError ( ) ) } , D . prototype . _setFieldError = function ( e ) { this . fieldError = { message : e } , this . updateError ( ) } , D . prototype . _clearFieldError = function ( ) { this . fieldError && ( this . fieldError = null , this . updateError ( ) ) } , D . prototype . _onChangeValue = function ( ) { var e = this . editor . getDomSelection ( ) ; if ( e . range ) { var t = A . textDiff ( String ( this . value ) , String ( this . previousValue ) ) ; e . range . startOffset = t . start , e . range . endOffset = t . end } var i = this . editor . getDomSelection ( ) ; if ( i . range ) { var n = A . textDiff ( String ( this . previousValue ) , String ( this . value ) ) ; i . range . startOffset = n . start , i . range . endOffset = n . end } this . editor . _onAction ( "editValue" , { path : this . getInternalPath ( ) , oldValue : this . previousValue , newValue : this . value , oldSelection : e , newSelection : i } ) , this . previousValue = this . value } , D . prototype . _onChangeField = function ( ) { var e = this . editor . getDomSelection ( ) , t = this . previousField || "" ; if ( e . range ) { var i = A . textDiff ( this . field , t ) ; e . range . startOffset = i . start , e . range . endOffset = i . end } var n = this . editor . getDomSelection ( ) ; if ( n . range ) { var o = A . textDiff ( t , this . field ) ; n . range . startOffset = o . start , n . range . endOffset = o . end } this . editor . _onAction ( "editField" , { parentPath : this . parent . getInternalPath ( ) , index : this . getIndex ( ) , oldValue : this . previousField , newValue : this . field , oldSelection : e , newSelection : n } ) , this . previousField = this . field } , D . prototype . _updateDomValue = function ( ) { var e = this . dom . value ; if ( e ) { var t = [ "jsoneditor-value" ] , i = this . value , n = "auto" == this . type ? A . type ( i ) : this . type , o = "string" == n && A . isUrl ( i ) ; if ( t . push ( "jsoneditor-" + n ) , o && t . push ( "jsoneditor-url" ) , "" == String ( this . value ) && "array" != this . type && "object" != this . type && t . push ( "jsoneditor-empty" ) , this . searchValueActive && t . push ( "jsoneditor-highlight-active" ) , this . searchValue && t . pus
, e . setAttribute ( "aria-selected" , ! 0 ) , l . addClass ( e , "selected" ) , l . addClass ( this . container , "has-selected" ) , i . selected = ! 0 , i . setAttribute ( "selected" , "" ) , this . emit ( "selectr.change" , i ) , this . emit ( "selectr.select" , i ) } , d . prototype . deselect = function ( e , t ) { var i = this . items [ e ] , n = this . options [ e ] ; if ( this . el . multiple ) { var o = this . selectedIndexes . indexOf ( e ) ; this . selectedIndexes . splice ( o , 1 ) ; var r = this . selectedValues . indexOf ( n . value ) ; this . selectedValues . splice ( r , 1 ) , function ( i ) { var n = ! 1 ; l . each ( this . tags , function ( e , t ) { t . idx === i . idx && ( n = t ) } , this ) , n && ( this . label . removeChild ( n ) , this . tags . splice ( this . tags . indexOf ( n ) , 1 ) ) } . call ( this , i ) , this . tags . length || l . removeClass ( this . container , "has-selected" ) } else { if ( ! t && ! this . config . clearable && ! this . config . allowDeselect ) return ! 1 ; this . label . innerHTML = "" , this . selectedValue = null , this . el . selectedIndex = this . selectedIndex = - 1 , l . removeClass ( this . container , "has-selected" ) } this . items [ e ] . setAttribute ( "aria-selected" , ! 1 ) , l . removeClass ( this . items [ e ] , "selected" ) , n . selected = ! 1 , n . removeAttribute ( "selected" ) , this . emit ( "selectr.change" , null ) , this . emit ( "selectr.deselect" , n ) } , d . prototype . setValue = function ( i ) { var n = Array . isArray ( i ) ; if ( n || ( i = i . toString ( ) . trim ( ) ) , ! this . el . multiple && n ) return ! 1 ; l . each ( this . options , function ( e , t ) { ( n && l . includes ( i . toString ( ) , t . value ) || t . value === i ) && this . change ( t . idx ) } , this ) } , d . prototype . getValue = function ( e , t ) { var n ; if ( this . el . multiple ) e ? this . selectedIndexes . length && ( n = { values : [ ] } , l . each ( this . selectedIndexes , function ( e , t ) { var i = this . options [ t ] ; n . values [ e ] = { value : i . value , text : i . textContent } } , this ) ) : n = this . selectedValues . slice ( ) ; else if ( e ) { var i = this . options [ this . selectedIndex ] ; n = { value : i . value , text : i . textContent } } else n = this . selectedValue ; return e && t && ( n = JSON . stringify ( n ) ) , n } , d . prototype . add = function ( i , n ) { if ( i ) { if ( this . data = this . data || [ ] , this . items = this . items || [ ] , this . options = this . options || [ ] , Array . isArray ( i ) ) l . each ( i , function ( e , t ) { this . add ( t , n ) } , this ) ; else if ( "[object Object]" === Object . prototype . toString . call ( i ) ) { if ( n ) { var o = ! 1 ; if ( l . each ( this . options , function ( e , t ) { t . value . toLowerCase ( ) === i . value . toLowerCase ( ) && ( o = ! 0 ) } ) , o ) return ! 1 } var e = l . createElement ( "option" , i ) ; return this . data . push ( i ) , this . options . push ( e ) , e . idx = 0 < this . options . length ? this . options . length - 1 : 0 , h . call ( this , e ) , i . selected && this . select ( e . idx ) , e } return this . setPlaceholder ( ) , this . config . pagination && this . paginate ( ) , ! 0 } } , d . prototype . remove = function ( i ) { var n , o = [ ] ; Array . isArray ( i ) ? l . each ( i , function ( e , t ) { l . isInt ( t ) ? o . push ( this . getOptionByIndex ( t ) ) : "string" == typeof i && o . push ( this . getOptionByValue ( t ) ) } , this ) : l . isInt ( i ) ? o . push ( this . getOptionByIndex ( i ) ) : "string" == typeof i && o . push ( this . getOptionByValue ( i ) ) , o . length && ( l . each ( o , function ( e , t ) { n = t . idx , this . el . remove ( t ) , this . options . splice ( n , 1 ) ; var i = this . items [ n ] . parentNode ; i && i . removeChild ( this . items [ n ] ) , this . items . splice ( n , 1 ) , l . each ( this . options , function ( e , t ) { t . idx = e , this . items [ e ] . idx = e } , this ) } , this ) , this . setPlaceholder ( ) , this . config . pagination && this . paginate ( ) ) } , d . prototype . removeAll = function ( ) { this . clear ( ! 0 ) , l . each ( this . el . options , function ( e , t ) { this . el . remove ( t ) } , this ) , l . truncate ( this . tree ) , this . items = [ ] , this . options = [ ] , this . data = [ ] , this . navIndex = 0 , this . requiresPagination && ( this . requiresPagination = ! 1 , this . pageIndex = 1 , this . pages = [ ] ) , this . setPlaceholder ( ) } , d . prototype . search = function ( n ) { if ( ! this . navigating ) { n = n || this . input . value ; var o = document . createDocumentFragment ( ) ; if ( this . removeMessage ( ) , l . truncate ( this . tree ) , 1 < n . length ) if ( l . each ( this . options , function ( e , t ) { var i = this . items [ t . idx ] ; l . includes ( t . textContent . toLowerCase ( ) , n . toLowerCase ( ) ) && ! t . disabled ? ( r ( i , o , this . customOption ) , l . removeClass ( i , "excluded" ) , this . customOption || ( i . innerHTML = function ( e , t ) { var i = new RegExp ( e , "i" ) . exec ( t . textContent ) ; return ! ! i && t . textContent . replace ( i [ 0 ] , "<span class='selectr-match'>" + i [ 0 ] + "</span>" ) } ( n , t ) ) ) : l . addClass ( i , "excluded" ) } , this ) , o . childElementCount ) { var e = this . items [ this . navIndex ] , t = o . firstElementChild ; l . removeClass ( e , "active" ) , this . navIndex = t . idx , l . addClass ( t , "active" ) } else this . config . taggable || this . setMessage ( "no results." ) ; else s . call ( this ) ; this . tree . appendChild ( o ) } } , d . prototype . toggle = function ( ) { this . disabled || ( this
2017-07-04 01:23:32 +08:00
//# sourceMappingURL=jsoneditor-minimalist.map