Changeset 201101
- Timestamp:
- 02/02/2010 03:46:56 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
woopra/trunk/js/jquery.tracking.js
r201072 r201101 12 12 * 13 13 * Copyright (c) 2009 Pranshu Arya 14 * Modif ed by Shane <shane@bugssite.org> to work for the WordPress Woopra Plugin14 * Modifed by Shane <shane@bugssite.org> to work for the WordPress Woopra Plugin 15 15 * 16 * Version 1. 116 * Version 1. 17 17 ** 18 18 * Licensed under the MIT license: … … 70 70 _load_woopra(); 71 71 } 72 73 /** 74 * Tracks an event using the given parameters. 75 * 76 * The woopraEvent method takes as few or as many property pairs as you provide: 77 * http://www.woopra.com/forums/topic/how-do-i-title-a-custom-event) 78 * 79 * Defaults for title, event_name, and skip_internal are specified at the bottom 80 * 81 * title - name of custom event 82 * var1, var2, var3, ... 83 * event_name - name of the event you want to track 84 * skip_internal - optional boolean value. If true then internal links are not tracked. 85 * 86 */ 87 $.woopraEvent = function(title, woopra_options) { 72 73 /** 74 * Process a Woopra Event Manually 75 */ 76 $.woopraEvent = function(title, woopra_options) { 88 77 if ( woopraTracker == 'undefined' ) { 89 78 debug('FATAL: woopraTracker is not defined'); // blocked by whatever … … 91 80 var w_event = new WoopraEvent(title); 92 81 // For each property pair passed to woopraEvent, add it to w_event 93 $.each(woopra_options, function(i, val){94 w_event.addProperty(i, val);82 $.each(woopra_options, function(i,val){ 83 w_event.addProperty(i,val); 95 84 }); 96 85 w_event.fire(); … … 98 87 }; 99 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 100 106 $.fn.trackEvent = function(woopra_options) { 101 107 102 // Add event handler to all matching elements 103 return this.each(function() { 108 /** 109 * 110 */ 111 return this.each( function() { 104 112 var element = $(this); 105 113 var parent = $(element).parent(); … … 122 130 // text, evaluate them if they are functions. 123 131 var options = {}; 124 $.each(woopra_options, function(i, val){125 options[i] = evaluate(element, val);132 $.each(woopra_options, function(i,val){ 133 options[i] = evaluate(element,val); 126 134 }); 127 135 } … … 147 155 var title = evaluate($(parent).children().eq(index), woopra_settings.title); 148 156 options = {} 149 $.each(woopra_options, function(i, val){157 $.each(woopra_options, function(i,val){ 150 158 options[i] = evaluate($(parent).children().eq(index), val); 151 159 }); … … 159 167 }); 160 168 161 162 169 /** 163 * Checks whether a setting value is a string or a function.164 170 * 165 * If second parameter is a string: returns the value of the second parameter.166 * If the second parameter is a function: passes the element to the function and returns function's return value.167 171 */ 168 172 function evaluate(element, text_or_function) { … … 173 177 }; 174 178 }; 175 179 176 180 /** 177 * Prints to Firebug console, if available. To enable: 178 * $.fn.track.trackEvent.debug = true; 179 */ 181 * Debug Information 182 */ 180 183 function debug(message) { 181 184 if (typeof console != 'undefined' && typeof console.debug != 'undefined' && $.fn.trackEvent.defaults.debug) { … … 183 186 } 184 187 }; 185 188 186 189 /** 187 * Default (overridable) settings.188 */190 191 */ 189 192 $.fn.trackEvent.defaults = { 190 193 title : function(element) { return (element[0].hostname == location.hostname) ? 'internal' : 'external'; }, … … 193 196 debug : true 194 197 }; 198 195 199 })(jQuery);
Note: See TracChangeset
for help on using the changeset viewer.