Sha256: b5e203e36649d8c638cbd0705a304ac6028b1d1a568576daeddc52763cdedea2

Contents?: true

Size: 1.25 KB

Versions: 15

Compression:

Stored size: 1.25 KB

Contents

/*global Application Client */
;(function($){
    var MIN = 13;
    var MAX = 17;
    var DEFAULT = 15;
    var p = Application.params.font_size;
    var pi = parseInt(p,10);
    var size = ((!isNaN(p) && pi <= MAX && pi >= MIN)) ? pi : DEFAULT;

    $.fn.resizeable = function() {
        function set(size, notify) {
            // set size
            $('.resizeable_text').css('font-size', size + "px");

            // reset disabled state
            $('.resizeable').removeClass('disabled');
            // set disabled state
            if (size === MIN) $('.resizeable.down').addClass('disabled');
            if (size === MAX) $('.resizeable.up').addClass('disabled');

            // notify the client of the size
            if (notify) Client.notify({ 'font_size': size });
            return size;
        }
        function handlers(el) {
            el
                .off("click")
                .on("click", function() {
                    var new_size = size + parseInt($(this).data('dir'), 10);
                    if (new_size <= MAX && new_size >= MIN) {
                        size = set(new_size, true);
                    }
                });
        }

        set(size, false);
        handlers(this);

        return this;
    };
})(Zepto);

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
sports_db-0.2.18 app/assets/javascripts/plugins/resizeable.js
sports_db-0.2.17 app/assets/javascripts/plugins/resizeable.js
sports_db-0.2.16 app/assets/javascripts/plugins/resizeable.js
sports_db-0.2.15 app/assets/javascripts/plugins/resizeable.js
sports_db-0.2.14 app/assets/javascripts/plugins/resizeable.js
sports_db-0.2.13 app/assets/javascripts/plugins/resizeable.js
sports_db-0.2.12 app/assets/javascripts/plugins/resizeable.js
sports_db-0.2.11 app/assets/javascripts/plugins/resizeable.js
sports_db-0.2.10 app/assets/javascripts/plugins/resizeable.js
sports_db-0.2.9 app/assets/javascripts/plugins/resizeable.js
sports_db-0.2.8 app/assets/javascripts/plugins/resizeable.js
sports_db-0.2.7 app/assets/javascripts/plugins/resizeable.js
sports_db-0.2.6 app/assets/javascripts/plugins/resizeable.js
sports_db-0.2.5 app/assets/javascripts/plugins/resizeable.js
sports_db-0.2.4 app/assets/javascripts/plugins/resizeable.js