Вход Регистрация
Файл: usr/tpl/admin/assets/js/radio.js
Строк: 95
<?php
!function($){var old=$.fn.radio;var Radio=function(element,options){this.$element=$(element);this.options=$.extend({},$.fn.radio.defaults,options);this.$label=this.$element.parent();this.$icon=this.$label.find("i");this.$radio=this.$label.find("input[type=radio]");this.groupName=this.$radio.attr("name");this.setState(this.$radio);this.$radio.on("change",$.proxy(this.itemchecked,this))};Radio.prototype={constructor:Radio,setState:function($radio){$radio=$radio||this.$radio;var checked=$radio.is(":checked");var disabled=!!$radio.prop("disabled");this.$icon.removeClass("checked disabled");this.$label.removeClass("checked");if(checked===true){this.$icon.addClass("checked");this.$label.addClass("checked")}if(disabled===true){this.$icon.addClass("disabled")}},resetGroup:function(){var group=$('input[name="'+this.groupName+'"]');group.next().removeClass("checked");group.parent().removeClass("checked")},enable:function(){this.$radio.attr("disabled",false);this.$icon.removeClass("disabled")},disable:function(){this.$radio.attr("disabled",true);this.$icon.addClass("disabled")},itemchecked:function(e){var radio=$(e.target);this.resetGroup();this.setState(radio)},check:function(){this.resetGroup();this.$radio.prop("checked",true);this.setState(this.$radio)},uncheck:function(){this.$radio.prop("checked",false);this.setState(this.$radio)},isChecked:function(){return this.$radio.is(":checked")}};$.fn.radio=function(option){var args=Array.prototype.slice.call(arguments,1);var methodReturn;var $set=this.each(function(){var $this=$(this);var data=$this.data("radio");var options=typeof option==="object"&&option;if(!data){$this.data("radio",(data=new Radio(this,options)))}if(typeof option==="string"){methodReturn=data[option].apply(data,args)}});return(methodReturn===undefined)?$set:methodReturn};$.fn.radio.defaults={};$.fn.radio.Constructor=Radio;$.fn.radio.noConflict=function(){$.fn.radio=old;return this};$(function(){$(window).on("load",function(){$(".radio-custom > input[type=radio]").each(function(){var $this=$(this);if($this.data("radio")){return}$this.radio($this.data())})})})}(window.jQuery);
?>
Онлайн: 2
Реклама