1function DateshiftFieldWidget() { 2 3 this.partsEl = []; 4 5 this.mode = 'edit'; 6 7 this.parts = {"days" : {label: "days", short: window.isPageRedesigned ? "дн" : "d"}, "hours": {label: "hours", short: "h"}, "minutes": {label: "minutes", short: 'min'}}; 8 9 this.initEl = function( $el, field, value ) { 10 11 var widget = this; 12 13 widget.controlEl = $controlEl = $("<div class='field-dateshift'></div>") 14 15 widget.viewEl = $viewEl = $('<span class="view-elem"></span>') 16 17 $viewEl.appendTo( $controlEl ) 18 $viewEl.click( function() { 19 widget.changeMode( 'edit' ); 20 } ) 21 22 for ( var key in widget.parts ) { 23 var part = key 24 var label = window.isPageRedesigned ? widget.parts[key].short : widget.parts[key].label; 25 if (typeof Yii != 'undefined') { 26 label = window.isPageRedesigned ? Yii.t('common', label) + '.' : Yii.t('common', label); 27 } 28 29 var $partEl 30 if(window.isPageRedesigned) { 31 $partEl = $("<input type='text' size=2 placeholder='00'>") 32 } else { 33 $partEl = $("<input type='text' size=3>") 34 } 35 $partEl.on('change', function() { 36 widget.changed(); 37 }) 38 39 var $wrapperEl = $("<span class='dateshift-part'><span>" + label + "</span></span>") 40 $partEl.prependTo( $wrapperEl ); 41 42 this.partsEl[key] = $partEl 43 $partEl.prependTo( $wrapperEl ) 44 $wrapperEl.appendTo( $controlEl ) 45 } 46 47 48 this.initFieldEl( $el, $controlEl, field ) 49 this.setValue( value ) 50 51 setTimeout( function() { 52 widget.changed( value ); 53 }, 10 ); 54 55 this.changeMode('edit') 56 } 57 58 this.onChange = function() { 59 60 } 61 62 this.changeMode = function( mode ) { 63 this.mode = mode; 64 if ( this.mode == "edit" ) { 65 this.controlEl.addClass('edit-mode') 66 } 67 else { 68 this.controlEl.removeClass('edit-mode') 69 } 70 } 71 72 this.getValue = function() { 73 74 var parts = {}; 75 for ( key in this.partsEl ) { 76 parts[key] = this.partsEl[key].val(); 77 } 78 return { 79 parts: parts 80 }; 81 //return { 'checked' : this.yesEl.prop( 'checked' ) ? 1 : 0 }; 82 }; 83 84 this.setValue = function( value ) { 85 let notSpecified = 'not specified'; 86 if (typeof Yii != 'undefined') { 87 notSpecified = Yii.t('common', notSpecified); 88 } 89 if( value && value.parts ) { 90 var stringParts = [] 91 92 for ( key in this.partsEl ) { 93 if ( value.parts[key]) { 94 this.partsEl[key].val(value.parts[key]) 95 let short = this.parts[key].short; 96 if (typeof Yii != 'undefined') { 97 short = Yii.t('common', short); 98 } 99 stringParts.push(value.parts[key] + " " + short + "."); 100 } 101 } 102 103 if ( stringParts.length > 0 ) { 104 this.viewEl.html( stringParts.join( " ") ); 105 } 106 else { 107 this.viewEl.html(notSpecified); 108 } 109 } 110 else { 111 this.viewEl.html(notSpecified); 112 } 113 114 115 } 116 117 118 119} 120 121extend( DateshiftFieldWidget, FieldWidget ) 122DateshiftFieldWidget.prototype = new FieldWidget() 123 124 125window.logicFieldWidgets["dateshift"] = DateshiftFieldWidget 126 127
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.