Monday, April 16, 2018

Rotate an image n number of times

function AnimateRotate(angle, repeat, elemn) {

 

    var duration = 1000;

    setTimeout(function () {

        if (repeat && repeat == "infinite") {

            AnimateRotate(angle, repeat, elemn);

        } else if (repeat && repeat > 1) {

            AnimateRotate(angle, repeat - 1, elemn);

        }

    }, duration)

    var $elem = elemn;

    $({ deg: 0 }).animate({ deg: angle }, {

        duration: duration,

        step: function (now) {

            $elem.css({

                'transform': 'rotate(' + now + 'deg)'

            });

        }

    });

}

 

function ShowRefreshError() {

 

    var element = document.createElement('div');

    var refresherror = '<div  id="dialog" title="Refresh Failed.">' +

        '  If the problem persists, please contact the <a href="https://google.com/"> HelpDesk</a>' +

        ' <div  align="center"> </br><input onclick="return SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, value);" type="button" value="OK" name="opret_ok"> </div> ' +

        '</div>';

    element.innerHTML = refresherror;

 

    var options = {

        html: element,

        title: 'Refresh Failed.',

        allowMaximize: false,

        showClose: false,

        autoSize: true

    };

 

    SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);

}

 

RefreshLink = function () {

 

    var elemn = $("a[title|='Refresh] > img");

    AnimateRotate(360, 2, elemn);

 

    $.ajax({

        cache: false,

        type: "GET",

        url: "https://google.com?webAddress,

        crossDomain: true,

        xhrFields: {

            withCredentials: true

        },

        success: function (data) {

            }

            else {

                ShowRefreshError();

            }

        },

        error: function (status, error) {

            ShowRefreshError();

        }

    });

};

 

 

 

No comments:

Post a Comment