1/** 2 * @package ImpressPages 3 * 4 */ 5 6 7(function ($) { 8 "use strict"; 9 10 var methods = { 11 12 init: function (options) { 13 14 return this.each(function () { 15 16 var $this = $(this); 17 18 var data = $this.data('ipFormColor'); 19 if (!data) { 20 $this.data('ipFormColor', {}); 21 22 // the only reliable way to wait till colorpicker plugin loads is to periodically check if it has been loaded 23 24 var loadInterval = setInterval(function () { 25 initColorpicker($this, loadInterval); 26 }, 400); 27 } 28 }); 29 } 30 }; 31 32 var initColorpicker = function ($colorPicker, loadInterval) { 33 if (typeof($.fn.colorpicker) == 'undefined') { 34 // Wait for plugin to load 35 return; 36 37 } 38 39 // stopping recurring check 40 clearInterval(loadInterval); 41 42 var $this = $colorPicker; 43 44 // loading plugin 45 // find option at http://mjolnic.github.io/bootstrap-colorpicker/ 46 $this.colorpicker({}).on('changeColor', function () { 47 $this.find('.form-control').trigger('change'); // manually triggering change event on dynamic value change 48 }); 49 50 // showing popup on input focus, too 51 $this.find('.form-control').on('focus.colorpicker', function () { 52 $this.colorpicker('show'); 53 }); 54 }; 55 56 57 $.fn.ipFormColor = function (method) { 58 if (methods[method]) { 59 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); 60 } else if (typeof method === 'object' || !method) { 61 return methods.init.apply(this, arguments); 62 } else { 63 $.error('Method ' + method + ' does not exist on jQuery.ipFormFile'); 64 } 65 66 }; 67 68})(jQuery); 69 70
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.