%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/news/public/scripts/controllers/socials/
Upload File :
Create Path :
Current File : /var/www/html/news/public/scripts/controllers/socials/socials.controller.js

'use strict';

angular.module('controllers').controller('socialsController', function ($scope, socials, resource, notification, $uibModal) {

    $scope.socials = socials;

    $scope.save = function () {
        resource.forResource('users').update($scope.user.id, $scope.user).then(function (res) {
            notification.success('Profile information updated successfully');
            $scope.refreshUserInfo();
        }, function (error) {
            notification.error(error);
        });
    };

    $scope.getBackgroundClass = function (social) {
        switch (social) {
            case 'Facebook': return 'bg-blue';
            case 'Instagram': return 'bg-maroon';
            case 'Twitter': return 'bg-aqua';
            case 'Linkedin': return 'bg-blue';
            case 'Google+': return 'bg-red';
            case 'YouTube': return 'bg-red';
            case 'Pinterest': return 'bg-maroon';
        }
    };

    $scope.getSocialIcon = function (social) {
        switch (social) {
            case 'Facebook': return 'fa-facebook';
            case 'Instagram': return 'fa-instagram';
            case 'Twitter': return 'fa-twitter';
            case 'Linkedin': return 'fa-linkedin';
            case 'Google+': return 'fa-google-plus';
            case 'YouTube': return 'fa-youtube';
            case 'Pinterest': return 'fa-pinterest';
        }
    };

    $scope.updateSocial = function (social) {
        var req = angular.copy(social);
        resource.forResource('socials').update(req.id, req).then(function (response) {

        }, function (error) {
            social.is_active = !social.is_active;
            notification.error(error);
        });
    };

    $scope.updateUrl = function (social) {
        $uibModal.open({
            animation: true,
            templateUrl: 'views/modals/socialUrl.html',
            size: 'md',
            controller: 'modalSocialUrlController',
            resolve: {
                social: function () {
                    return social;
                }
            }
        }).result.then(function (res) {
            if (res && res.id) {
                $scope.socials[$scope.socials.indexOf(social)] = res;
            }
        });
    }

});

Zerion Mini Shell 1.0