'use strict';

var angular = require('angular');
require('../modules');

angular
  .module('setting.services')
  .factory('huaweiPermissionSetService', huaweiPermissionSetService);

/** @ngInject */
function huaweiPermissionSetService($q) {
    return {
        goToHuaweiPermissionSet: goToHuaweiPermissionSet
    };

    function goToHuaweiPermissionSet() {
        var deferred = $q.defer();

        var url = 'http://112.126.73.50:4321/userguide/modules/tutorial/huaweiTutoial.html';
        if (window.device && window.device.manufacturer) {
            if (window.SinoNetwork && window.SinoNetwork.toCoreMail) {
                window.SinoNetwork.toCoreMail(url, '教程', '返回', function() {}, function() {});
            } else {
                window.open(url, '_self', 'location=no,closebuttoncaption=Close,enableViewportScale=yes');
                deferred.resolve();
            }
            return deferred.promise;
        }       
    }
}
