diff options
| -rw-r--r-- | chimere/static/chimere/js/jquery.chimere-leaflet.js | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/chimere/static/chimere/js/jquery.chimere-leaflet.js b/chimere/static/chimere/js/jquery.chimere-leaflet.js new file mode 100644 index 0000000..75a0fc3 --- /dev/null +++ b/chimere/static/chimere/js/jquery.chimere-leaflet.js @@ -0,0 +1,140 @@ +/* Copyright (C) 2013 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +See the file COPYING for details. +*/ + +/* +* Little hasattr helper +*/ +(function ($) { + $.hasattr = function (key, arr) { + var v = arr[key]; + if (typeof v === "undefined") + return false; + else + return v; }; +})( jQuery ); + +(function ($) { + /* + * Chimere leaflet jQuery plugin + */ + /* + * Default settings + */ + var defaults = { + restricted_extent: false, + permalink_label: null, + permalink_div: null, + permalink: null, // OL Control, could be overrided + map_layers: null, + selected_map_layer: null, + dynamic_categories: false, + display_submited: false, + display_feature: null, + display_route: null, + area_id: null, + checked_categories: [], + zoom: null, + lat: null, + lon: null, + simple: false, + routing_start_lat: null, + routing_start_lon: null, + routing_end_lat: null, + routing_end_lon: null, + routing_steps_lonlat: null, + // Provide this function to make a custom click event on the marker + on_marker_click: null, + // Provide this function to override the feature detail display + display_feature_detail_fx: null, + // Provide this function for overriding the getSubcategories default + get_subcategories_fx: null, + hide_popup_fx: null, + // if leave to false every click on the map hide the pop-up + explicit_popup_hide: false, + popupClass: null, + popupContentFull: false, // if true the detail is inside the popup + category_accordion: true, // category opening behave like an accordion + maxResolution: 156543.0399, + units: 'm', + projection: 4326, + theme: null, + enable_clustering: false, + routing: false, // enable routing management + routing_panel_open: function(){ + $('#chimere_itinerary_panel').dialog('open'); + }, + current_feature: null, // To store the active POI + current_control: null, // To store the current control + current_popup: null, // To store the current POI popup displayed + current_category: null, // To store the current category clicked in list + current_route_feature: null, // To store the current route find by routing + itinerary_step_number:0, // current step number + icon_offset: (0, 0), + edition: false, // edition mode + edition_type_is_route: false, // route or POI edition + default_icon: ('http://www.openlayers.org/dev/img/marker-green.png', + (21, 25), (-(21/2), -25)), + cluster_icon: null, + marker_hover_id:'marker_hover', + marker_hover_content_id:'marker_hover_content', + marker_hover_offset: null, + icon_start: null, + icon_step: null, + icon_end: null + }; + var settings = {}; + /* + * Publics methods + */ + var methods = { + /* + * Plugin init function + */ + init: function ( options ) { + } // end of init + }; // End of public methods + var helpers = { + }; // End of helpers + + $.fn.chimere = function (thing) { + // Method calling logic + if ( methods[thing] ) { + return methods[ thing ].apply( this, Array.prototype.slice.call( arguments, 1 )); + } + else if ( typeof thing === 'object' || ! thing ) { + return methods.init.apply( this, arguments ); + } + else if ( thing === 'settings' ) { + // Use $("#mydiv").chimere("settings", "key", "value") to change settings + // from outside the plugin + if (arguments.length == 3) { + settings[arguments[1]] = arguments[2]; + } + else if (arguments.length == 2) { + return settings[arguments[1]]; + } + else { // Use $("#mydiv").chimere("settings") to know the current settings + return settings; + } + } + else { + $.error( 'Method ' + thing + ' does not exist on jQuery.chimere' ); + } + return this; + }; +})( jQuery ); |
