1 /** 2 * @license jQuery jlocator Plugin ##VERSION## 3 * Copyright 2012-2013 Miriam Zusin. All rights reserved. 4 * To use this file you must to buy a licence at http://codecanyon.net/user/no81no/portfolio 5 */ 6 7 (function(jQuery){ 8 'use strict'; 9 10 /** 11 * jQuery Library 12 * @see <a href="http://jquery.com/" title="" target="_blank">jquery.com</a> 13 * @name jQuery 14 * @class jQuery Library 15 */ 16 17 /** 18 * jQuery 'fn' definition 19 * @see <a href="http://jquery.com/" title="" target="_blank">jquery.com</a> 20 * @name fn 21 * @class jQuery Library 22 * @memberOf jQuery 23 */ 24 25 /** 26 * jPList definition 27 * @see <a href="http://jplist.no81no.com/" title="" target="_blank">jQuery jPList Plugin</a> 28 * @name jQuery.fn.jplist 29 * @class jQuery jPList Plugin 30 */ 31 32 /** 33 * jPList Controls definition 34 * @see <a href="http://jplist.no81no.com/html/controls.html" title="" target="_blank">jQuery jPList Plugin Controls</a> 35 * @name jQuery.fn.jplist.controls 36 * @class jQuery jPList Plugin Controls 37 */ 38 39 /** 40 * jlocator constructor 41 * @param {Object} userOptions - jlocator user options 42 * @param {jQueryObject} $root - jlocator container 43 * @constructor 44 */ 45 var Init = function(userOptions, $root){ 46 47 var self = { 48 options: userOptions 49 ,$root: $root 50 ,controller: null 51 }; 52 53 //init user options 54 self.options = $.extend(true, { 55 56 //map defauls 57 startZoom: 2 58 ,storeZoom: 17 59 ,latitude: 0 60 ,longitude: 90 61 62 ,geolocation: true 63 ,markerIcon: '' //'' for default 64 ,markerText: 'Click to Zoom' 65 ,directionsType: 'DRIVING' //BICYCLING, TRANSIT, WALKING 66 ,mapTypeId: 'ROADMAP' //ROADMAP, SATELLITE, HYBRID, TERRAIN 67 68 //jplist options: http://jplist.no81no.com/ 69 ,jplist: { 70 71 items_box: '[data-type="stores"]' 72 ,item_path: '[data-type="store"]' 73 ,panel_path: '[data-type="controls"]' 74 ,no_results: '[data-type="no-results"]' 75 ,redraw_callback: function(){ 76 77 } 78 79 //panel controls 80 ,control_types: { 81 82 'autocomplete':{ 83 class_name: 'Autocomplete' 84 ,options: { 85 86 } 87 } 88 89 ,'autocomplete-radius':{ 90 class_name: 'AutocompleteRadius' 91 ,options: {} 92 } 93 94 } 95 } 96 97 //if info window should be opened on store click 98 ,openInfoWindowOnStoreClick: false 99 100 //info window content 101 ,infoWindow: function(html, title, address, city, state, zipcode, country){ 102 return '<div class="info-window">' + html + '</div>'; 103 } 104 105 //events 106 ,storeClickEvent: 'storeClickEvent' 107 ,pinClickEvent: 'pinClickEvent' 108 ,sendStoreListEvent: 'sendStoreListEvent' 109 ,getStoresListEvent: 'getStoresListEvent' 110 ,setDirectionsEvent: 'setDirectionsEvent' 111 ,jumpEvent: 'jumpEvent' 112 ,initZoomEvent: 'initZoomEvent' 113 114 }, userOptions); 115 116 //init controller 117 self.controller = new $.fn.jlocator.controller($root, self.options); 118 119 return jQuery.extend(this, self); 120 }; 121 122 /** 123 * jlocator main contructor 124 * @example 125 * <pre> 126 * $('#jlocator').jlocator(); 127 * </pre> 128 * @param {Object} userOptions - jlocator user options 129 * @name jlocator 130 * @class jQuery jlocator Plugin 131 * @memberOf jQuery.fn 132 * @property {jQueryObject} $root - jlocator root element 133 * @property {Object} options - jlocator user options 134 * @property {jQuery.fn.jlocator.controller} controller - jlocator controller 135 */ 136 jQuery.fn.jlocator = function(userOptions){ 137 138 return this.each(function(){ 139 140 var self; 141 142 //init constructor 143 self = new Init(userOptions, $(this)); 144 145 //save in data 146 $(this).data('jlocator', self); 147 }); 148 }; 149 })(jQuery);