'use strict';

/* Services */


// Demonstrate how to register services
// In this case it is a simple value service.
angular.module('myApp.services', [])
    .factory("$commonbox", function($rootScope, $uibModal, $q){
        var success_tpl = '<div class="recharge-modal common">'+
            '<div class="common-content">{{message}}</div>'+
            '<div class="recharge-foot1" data-ng-click="cancel($event)">确定</div>'+
            '</div>'
        var scope = $rootScope.$new();

        return {
            show: function(msg, opts){
                var defer = $q.defer();
                opts = opts || {};

                $uibModal.open({
                    template: success_tpl,
                    scope: scope,
                    controller: function($scope, $uibModalInstance){
                        $scope.message = msg;
                        $scope.cancel = function($event){
                            $event.preventDefault();
                            $uibModalInstance.close();
                            defer.reject();
                        };
                    },
                    size:'sm',
                    backdrop: "static",
                    keyboard: false
                });
                return defer.promise;
            }
        }
    })
    //结案终止时间
    .factory("$Popupbox", function($rootScope, $uibModal, $q){
        var success_tpl = '<div class="recharge-modal Popup">'+
            '<div class="Popup-content">{{message}}</div>'+
            '<div class="recharge-Popupfoot" data-ng-click="cancel($event)">确定</div>'+
            '</div>'
        var scope = $rootScope.$new();

        return {
            show: function(msg, opts){
                var defer = $q.defer();
                opts = opts || {};

                $uibModal.open({
                    template: success_tpl,
                    scope: scope,
                    controller: function($scope, $uibModalInstance){
                        $scope.message = msg;
                        $scope.cancel = function($event){
                            $event.preventDefault();
                            $uibModalInstance.close();
                            defer.reject();
                        };
                    },
                    size:'sm',
                    backdrop: "static",
                    keyboard: false
                });
                return defer.promise;
            }
        }
    })
//分值区间
.factory("$Scorebox", function($rootScope, $uibModal, $q){
    var success_tpl = '<div class="recharge-modal Score">'+
        '<div class="Score-content">{{message}}</div>'+
        '<div class="recharge-Scorefoot" data-ng-click="cancel($event)">确定</div>'+
        '</div>'
    var scope = $rootScope.$new();

    return {
        show: function(msg, opts){
            var defer = $q.defer();
            opts = opts || {};

            $uibModal.open({
                template: success_tpl,
                scope: scope,
                controller: function($scope, $uibModalInstance){
                    $scope.message = msg;
                    $scope.cancel = function($event){
                        $event.preventDefault();
                        $uibModalInstance.close();
                        defer.reject();
                    };
                },
                size:'sm',
                backdrop: "static",
                keyboard: false
            });
            return defer.promise;
        }
    }
})
//选择提示框
.factory("$Chargebox", function($rootScope, $uibModal, $q){
    var success_tpl = '<div class="recharge-modal Charge">'+
        '<div class="Charge-content">{{message}}</div>'+
        '<div class="recharge-Chargefoot" data-ng-click="cancel($event)">确定</div>'+
        '</div>'
    var scope = $rootScope.$new();

    return {
        show: function(msg, opts){
            var defer = $q.defer();
            opts = opts || {};

            $uibModal.open({
                template: success_tpl,
                scope: scope,
                controller: function($scope, $uibModalInstance){
                    $scope.message = msg;
                    $scope.cancel = function($event){
                        $event.preventDefault();
                        $uibModalInstance.close();
                        defer.reject();
                    };
                },
                size:'sm',
                backdrop: "static",
                keyboard: false
            });
            return defer.promise;
        }
    }
});