1/** 2 * Copyright (c) 2011-2013 Felix Gnass 3 * Licensed under the MIT license 4 */ 5 6/* 7 8Basic Usage: 9============ 10 11$('#el').spin(); // Creates a default Spinner using the text color of #el. 12$('#el').spin({ ... }); // Creates a Spinner using the provided options. 13 14$('#el').spin(false); // Stops and removes the spinner. 15 16Using Presets: 17============== 18 19$('#el').spin('small'); // Creates a 'small' Spinner using the text color of #el. 20$('#el').spin('large', '#fff'); // Creates a 'large' white Spinner. 21 22Adding a custom preset: 23======================= 24 25$.fn.spin.presets.flower = { 26 lines: 9 27 length: 10 28 width: 20 29 radius: 0 30} 31 32$('#el').spin('flower', 'red'); 33 34*/ 35 36(function(factory) { 37 38 if (typeof exports == 'object') { 39 // CommonJS 40 factory(require('jquery'), require('spin')) 41 } 42 else if (typeof define == 'function' && define.amd) { 43 // AMD, register as anonymous module 44 define(['jquery', 'spin'], factory) 45 } 46 else { 47 // Browser globals 48 if (!window.Spinner) throw new Error('Spin.js not present') 49 factory(window.jQuery, window.Spinner) 50 } 51 52}(function($, Spinner) { 53 54 $.fn.spin = function(opts, color) { 55 56 return this.each(function() { 57 var $this = $(this), 58 data = $this.data(); 59 60 if (data.spinner) { 61 data.spinner.stop(); 62 delete data.spinner; 63 } 64 if (opts !== false) { 65 opts = $.extend( 66 { color: color || $this.css('color') }, 67 $.fn.spin.presets[opts] || opts 68 ) 69 // Begin WordPress Additions 70 // To use opts.right, you need to have specified a length, width, and radius. 71 if ( typeof opts.right !== 'undefined' && typeof opts.length !== 'undefined' 72 && typeof opts.width !== 'undefined' && typeof opts.radius !== 'undefined' ) { 73 var pad = $this.css( 'padding-left' ); 74 pad = ( typeof pad === 'undefined' ) ? 0 : parseInt( pad, 10 ); 75 opts.left = $this.outerWidth() - ( 2 * ( opts.length + opts.width + opts.radius ) ) - pad - opts.right; 76 delete opts.right; 77 } 78 // End WordPress Additions 79 data.spinner = new Spinner(opts).spin(this) 80 } 81 }) 82 } 83 84 $.fn.spin.presets = { 85 tiny: { lines: 8, length: 2, width: 2, radius: 3 }, 86 small: { lines: 8, length: 4, width: 3, radius: 5 }, 87 large: { lines: 10, length: 8, width: 4, radius: 8 } 88 } 89 90})); 91 92// Jetpack Presets Overrides: 93(function($){ 94 $.fn.spin.presets.wp = { trail: 60, speed: 1.3 }; 95 $.fn.spin.presets.small = $.extend( { lines: 8, length: 2, width: 2, radius: 3 }, $.fn.spin.presets.wp ); 96 $.fn.spin.presets.medium = $.extend( { lines: 8, length: 4, width: 3, radius: 5 }, $.fn.spin.presets.wp ); 97 $.fn.spin.presets.large = $.extend( { lines: 10, length: 6, width: 4, radius: 7 }, $.fn.spin.presets.wp ); 98 $.fn.spin.presets['small-left'] = $.extend( { left: 5 }, $.fn.spin.presets.small ); 99 $.fn.spin.presets['small-right'] = $.extend( { right: 5 }, $.fn.spin.presets.small ); 100 $.fn.spin.presets['medium-left'] = $.extend( { left: 5 }, $.fn.spin.presets.medium ); 101 $.fn.spin.presets['medium-right'] = $.extend( { right: 5 }, $.fn.spin.presets.medium ); 102 $.fn.spin.presets['large-left'] = $.extend( { left: 5 }, $.fn.spin.presets.large ); 103 $.fn.spin.presets['large-right'] = $.extend( { right: 5 }, $.fn.spin.presets.large ); 104})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.