/*
* angular directive onBlur
*
* @description my ng-blur
* @require jquery
*/
$compileProvider.directive('onBlur', function() {
return {
restrict : 'A',
link : function(scope, elm, attrs) {
elm.bind('blur', function() {
scope.$apply(attrs.onBlur);
});
}
};
});
/* factory function safeApply
*
* @description If you find yourself triggering the '$apply already in progress' error while developing with Angular.JS
* (for me I find I hit most often when integrating third party plugins that trigger a lot of DOM events),
* you can use a 'safeApply' method that checks the current phase before executing your function.
*
* @param scope, the action scope, mostly is the topmost controller
* @param fn, the function which you want to apply into scope
* @see https://coderwall.com/p/ngisma
*/.factory('safeApply', function($rootScope) {
return function(scope, fn) {
var phase = scope.$root.$$phase;
if (phase == '$apply' || phase == '$digest') {
if (fn && ( typeof (fn) === 'function')) {
fn();
}
} else {
scope.$apply(fn);
}
}
});
/*
* angular directive onBlur
*
* @description my ng-blur
* @require jquery
*/
$compileProvider.directive('onBlur', function(safeApply) {
return {
restrict : 'A',
link : function(scope, elm, attrs) {
elm.bind('blur', function() {
safeApply(scope, attrs.onBlur);
});
}
};
});
$('input').iCheck({
labelHover : false,
cursor : true,
checkboxClass : 'icheckbox_square-blue',
radioClass : 'iradio_square-blue',
increaseArea : '20%'
});
/*
* angular directive ng-icheck
*
* @description icheck is a plugin of jquery for beautifying checkbox & radio, now I complied it with angular directive
* @require jquery, icheck
* @example <input type="radio" ng-model="paomian" value="kangshifu" ng-icheck>
* <input type="checkbox" class="icheckbox" name="mantou" ng-model="mantou" ng-icheck checked>
*/
$compileProvider.directive('ngIcheck', function($compile) {
return {
restrict : 'A',
require : '?ngModel',
link : function($scope, $element, $attrs, $ngModel) {
if (!$ngModel) {
return;
}
//using iCheck
$($element).iCheck({
labelHover : false,
cursor : true,
checkboxClass : 'icheckbox_square-blue',
radioClass : 'iradio_square-blue',
increaseArea : '20%'
}).on('ifClicked', function(event) {
if ($attrs.type == "checkbox") {
//checkbox, $ViewValue = true/false/undefined
$scope.$apply(function() {
$ngModel.$setViewValue(!($ngModel.$modelValue == undefined ? false : $ngModel.$modelValue));
});
} else {
// radio, $ViewValue = $attrs.value
$scope.$apply(function() {
$ngModel.$setViewValue($attrs.value);
});
}
});
},
};
});
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有