HEX
Server: Apache
System: Linux web2213.uni5.net 5.4.282-1.el8.elrepo.x86_64 #1 SMP Mon Aug 19 18:33:22 EDT 2024 x86_64
User: clinicamaciel (596848)
PHP: 7.3.33
Disabled: apache_child_terminate,c99_buff_prepare,c99_sess_put,dl,eval,exec,leak,link,myshellexec,openlog,passthru,pclose,pcntl_exec,php_check_syntax,php_strip_whitespace,popen,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,symlink,system,socket_listen,socket_create_listen,putenv
Upload Files
File: /home/clinicamaciel/www/wp-content/plugins/motopress-content-editor/jquery/tie/tie.js
steal('jquery/controller').then(function($){

/**
 * @class jQuery.Tie
 * @core
 * 
 * The $.fn.tie plugin binds form elements and controllers with 
 * models and vice versa.  The result is that a change in 
 * a model will automatically update the form element or controller
 * AND a change event on the element will update the model.
 * 
 * 
 * 
 * 
 * 
 */
$.Controller("jQuery.Tie",{
	setup : function(el){
		this._super(el,{})
		return $.makeArray(arguments);
	},
	init : function(el, inst, attr, type){
		// if there's a controller
		if(!type){
			//find the first one that implements val
			var controllers = this.element.data("controllers") || {};
			for(var name in controllers){
				var controller = controllers[name];
				if(typeof controller.val == 'function'){
					type = name;
					break;
				}
			}
		}
		
		this.type = type;
		this.attr = attr;
		this.inst = inst;
		this.bind(inst, attr, "attrChanged");
		
		//destroy this controller if the model instance is destroyed
		this.bind(inst, "destroyed", "modelDestroyed");
		
		var value = inst.attr(attr);
		//set the value
		this.lastValue = value;
		if(type){
			
			//destroy this controller if the controller is destroyed
			this.bind(this.element.data("controllers")[type],"destroyed","destroy");
			this.element[type]("val",value);
			
		}else{
			this.element.val(value)
		}
	},
	attrChanged : function(inst, ev, val){
		if (val !== this.lastValue) {
			this.setVal(val);
			this.lastValue = val;
		}
	},
	modelDestroyed : function(){
		this.destroy()
	},
	setVal : function(val){
		if (this.type) {
			this.element[this.type]("val", val)
		}
		else {
			this.element.val(val)
		}
	},
	change : function(el, ev, val){
		if(!this.type && val === undefined){
			val = this.element.val();
		}
		
		this.inst.attr(this.attr, val, null, this.proxy('setBack'))
		
	},
	setBack : function(){
		this.setVal(this.lastValue);
	},
	destroy : function(){
		this.inst = null;
		if(! this._destroyed ){
			// assume it's because of the https://github.com/jupiterjs/jquerymx/pull/20
			// problem and don't throw an error
			this._super();
		}
		
	}
});


});