--- layout: page title: Github JS Widgets minify_content: false navigation: - name: Home link: / icon: fa fa-home - name: Overview link: /github-jquery-widgets icon: fa fa-dashboard - name: Demonstration link: /github-jquery-widgets/demo icon: fa fa-forward - name: Coverage link: /github-jquery-widgets/coverage icon: fa fa-code - name: Namespaces link: "#" icon: fa fa-mortar-board children: - name: githubProfile link: /github-jquery-widgets/radic.githubProfile.html ---
Statements: 11.11% (2 / 18) Branches: 0% (0 / 12) Functions: 11.11% (1 / 9) Lines: 11.11% (2 / 18) Ignored: none
All files » src/ » github-widget.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    551

    1

     (function (factory) {

        factory(jQuery, radic);

    }(function ($, R) {

        R.template.registerHelper('branchName', function (event) {
            return event.payload.ref.replace('refs/heads/', '');
        });
        R.template.registerHelper('pushName', function (event) {
            return event.payload.size > 1 ? 's' : ''
        });

        R.template.registerHelper('repoName', function (repoName) {
            return repoName.replace(/([\w-]*)\/([\w-]*)/, '$2');
        });

        R.template.registerHelper('repoOwner', function (repoName) {
            return repoName.replace(/([\w-]*)\/([\w-]*)/, '$1');
        });
        R.template.registerHelper('evenOdd', function (index, onEven, onOdd) {
            return index % 2 == 0 ? onEven : onOdd;
        });

        $.widget('github.widget', $.radic.base, {
            version: '0.0.1',

            options: {
                spinner: true,
                spinnerOptions: {
                    top: '30px'
                }
            },

            _spin: function (disable) {
                if (this.options.spinner === true) {
                    if (typeof disable === 'boolean' && disable === false) {
                        return this.element.spin(false);
                    }
                    this.element.spin(this.options.spinnerOptions);
                }

            },

            _trigger: function (name, event, param) {
                this._super(name, event, typeof param === 'undefined' ? [this.options, this.data] : param);
            }
        });
    }));