WordPress.org

Plugin Directory

Changeset 1208892


Ignore:
Timestamp:
07/29/15 10:24:34 (2 years ago)
Author:
gyrus
Message:

Version 1.3 release

Location:
developers-custom-fields/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • developers-custom-fields/trunk/css/slt-cf-admin.css

    r1154478 r1208892  
    154154  cursor: pointer !important; 
    155155} 
     156/* Gmap max markers error highlighting*/ 
     157#markers_max_message { 
     158  display:inline-block; 
     159  padding:2px 4px; 
     160} 
     161.markers_max_message_error { 
     162  background:#f00; 
     163  color:#fff; 
     164} 
    156165/* Timepicker related styles */ 
    157166.ui-timepicker-div .ui-widget-header { 
  • developers-custom-fields/trunk/css/slt-cf-admin.less

    r1154478 r1208892  
    167167    color: #fff !important; 
    168168    cursor: pointer !important; 
     169} 
     170 
     171/* Gmap max markers errors */ 
     172#markers_max_message { 
     173    font-weight:bold; 
     174} 
     175#markers_max_message.markers_max_message_error { 
     176  background:#c00; 
     177    border-radius:3px; 
     178  color:#fff; 
     179  padding:3px 6px 4px 6px; 
    169180} 
    170181 
  • developers-custom-fields/trunk/css/slt-cf-admin.min.css

    r1154478 r1208892  
    1 .slt-cf-cf:before,.slt-cf-cf:after{content:"\0020";display:block;height:0;overflow:hidden}.slt-cf-cf:after{clear:both}.slt-cf-cf{zoom:1}.slt-cf-dismiss{padding:0;border:0;background-color:transparent;color:#0073aa;cursor:pointer}.slt-cf-dismiss:before{margin:.1em .1em 0 0;color:#c00;font-size:16px}.slt-cf-dismiss:hover,.slt-cf-dismiss:focus{color:#00a0d2}div.slt-cf-fixed-width{float:left;margin:0 7px 7px 0}table.mceLayout{border-left:1px solid #dfdfdf !important;border-right:1px solid #dfdfdf !important}form#post div.slt-cf{margin:20px 10px}form#post div.slt-cf label.slt-cf-label,form#post div.slt-cf legend,form#post div.slt-cf h4.slt-cf-label{font-size:14px;font-weight:bold}form#post div.slt-cf h4.slt-cf-label{display:inline;margin:0}form#post div.slt-cf legend{padding:0 0 7px}form#post div.slt-cf.clone label.slt-cf-label,form#post div.slt-cf.clone legend{font-size:11px}form#post div.slt-cf-text.label-block .slt-cf-input,form#post div.slt-cf-textarea.label-block .slt-cf-input,form#post div.slt-cf-textile.label-block .slt-cf-input{width:97%}form#post div.slt-cf-textarea label.slt-cf-label,form#post div.slt-cf-textile label.slt-cf-label,form#post div.slt-cf-wysiwyg label.slt-cf-label{display:block;margin-bottom:5px}form#post div.slt-cf-select label.slt-cf-label,form#post div.slt-cf-file label.slt-cf-label,form#post div.slt-cf-text label.slt-cf-label{padding-right:10px}form#post div.slt-cf-select.label-block label.slt-cf-label,form#post div.slt-cf-file.label-block label.slt-cf-label,form#post div.slt-cf-text.label-block label.slt-cf-label,form#post div.slt-cf-colorpicker.label-block label.slt-cf-label,form#post div.slt-cf-notice.label-block h4.slt-cf-label,form#post div.slt-cf-date.label-block label.slt-cf-label,form#post div.slt-cf-datetime.label-block label.slt-cf-label,form#post div.slt-cf-time.label-block label.slt-cf-label{display:block;margin-bottom:3px}form#post div.slt-cf-multifield{margin-bottom:7px}form#post div.slt-cf-colorpicker input{width:8em;text-transform:lowercase}.colorpicker input[type=text]{line-height:1;height:13px}ul.slt-cf-sortable li{margin-bottom:6px}ul.slt-cf-sortable li span.ui-icon{display:inline-block;position:relative;top:2px;cursor:move}div.slt-cf-checkboxes.thumbnails ul.slt-cf-sortable li.ui-state-default{background-image:none}div.slt-cf-checkboxes.thumbnails ul.slt-cf-sortable li.ui-state-default img{display:inline-block;vertical-align:middle;padding:5px}#profile-page span.mceEditor{display:block;width:70%}.ui-autocomplete{margin-top:20px;padding:0;width:300px !important;background:#fff !important;border:1px solid #999 !important;border-radius:5px !important;-moz-border-radius:5px !important;-webkit-border-radius:5px !important;box-shadow:3px 3px 4px #666;-moz-box-shadow:3px 3px 4px #666;-webkit-box-shadow:3px 3px 4px #666;font-size:11px !important;list-style-type:none}.ui-menu-item a{display:block !important;padding:5px 7px !important;border-radius:5px !important;-moz-border-radius:5px !important;-webkit-border-radius:5px !important}.ui-menu-item a:hover,.ui-menu-item a:focus,.ui-menu-item a:active,#ui-active-menuitem{background:#69c !important;color:#fff !important;cursor:pointer !important}.ui-timepicker-div .ui-widget-header{margin-bottom:8px}.ui-timepicker-div dl{text-align:left}.ui-timepicker-div dl dt{height:25px;margin-bottom:-25px}.ui-timepicker-div dl dd{margin:0 10px 10px 65px}.ui-timepicker-div td{font-size:90%}.ui-tpicker-grid-label{background:0;border:0;margin:0;padding:0}.slt-cf-color-preview{display:inline-block;padding:.3em 1em;margin:.4em;vertical-align:top;text-align:center;border:1px solid #666}ul.slt-cf-attachments-list li{float:left;margin:0 20px 20px 0}ul.slt-cf-attachments-list li .slt-cf-attachment{display:block;overflow:hidden}ul.slt-cf-attachments-list li .slt-cf-attachment.file{box-sizing:border-box;padding:10px;min-height:80px;-moz-box-shadow:inset 0 0 10px 1px #999;-webkit-box-shadow:inset 0 0 10px 1px #999;box-shadow:inset 0 0 10px 1px #999}ul.slt-cf-attachments-list li .slt-cf-attachment.file p{margin:0;padding-top:45px}ul.slt-cf-attachments-list li label{display:block;text-align:center}ul.slt-cf-attachments-list li label .slt-cf-attachment{margin-bottom:.6em}.slt-fs-preview img{max-width:100%;height:auto} 
     1/* Developer's Custom Fields admin CSS 
     2*********************************************************************/ 
     3/* Clearfix */ 
     4.slt-cf-cf:before, 
     5.slt-cf-cf:after { 
     6  content: "\0020"; 
     7  display: block; 
     8  height: 0; 
     9  overflow: hidden; 
     10} 
     11.slt-cf-cf:after { 
     12  clear: both; 
     13} 
     14.slt-cf-cf { 
     15  zoom: 1; 
     16} 
     17/* Notices */ 
     18.slt-cf-dismiss { 
     19  padding: 0; 
     20  border: none; 
     21  background-color: transparent; 
     22  color: #0073aa; 
     23  cursor: pointer; 
     24} 
     25.slt-cf-dismiss:before { 
     26  margin: .1em .1em 0 0; 
     27  color: #c00; 
     28  font-size: 16px; 
     29} 
     30.slt-cf-dismiss:hover, 
     31.slt-cf-dismiss:focus { 
     32  color: #00a0d2; 
     33} 
     34/* Multiple input fields */ 
     35div.slt-cf-fixed-width { 
     36  float: left; 
     37  margin: 0 7px 7px 0; 
     38} 
     39/* TinyMCE */ 
     40table.mceLayout { 
     41  border-left: 1px solid #dfdfdf !important; 
     42  border-right: 1px solid #dfdfdf !important; 
     43} 
     44/* Post meta fields */ 
     45form#post div.slt-cf { 
     46  margin: 20px 10px; 
     47} 
     48form#post div.slt-cf label.slt-cf-label, 
     49form#post div.slt-cf legend, 
     50form#post div.slt-cf h4.slt-cf-label { 
     51  font-size: 14px; 
     52  font-weight: bold; 
     53} 
     54form#post div.slt-cf h4.slt-cf-label { 
     55  display: inline; 
     56  margin: 0; 
     57} 
     58form#post div.slt-cf legend { 
     59  padding: 0 0 7px; 
     60} 
     61form#post div.slt-cf.clone label.slt-cf-label, 
     62form#post div.slt-cf.clone legend { 
     63  font-size: 11px; 
     64} 
     65form#post div.slt-cf-text.label-block .slt-cf-input, 
     66form#post div.slt-cf-textarea.label-block .slt-cf-input, 
     67form#post div.slt-cf-textile.label-block .slt-cf-input { 
     68  width: 97%; 
     69} 
     70form#post div.slt-cf-textarea label.slt-cf-label, 
     71form#post div.slt-cf-textile label.slt-cf-label, 
     72form#post div.slt-cf-wysiwyg label.slt-cf-label { 
     73  display: block; 
     74  margin-bottom: 5px; 
     75} 
     76form#post div.slt-cf-select label.slt-cf-label, 
     77form#post div.slt-cf-file label.slt-cf-label, 
     78form#post div.slt-cf-text label.slt-cf-label { 
     79  padding-right: 10px; 
     80} 
     81form#post div.slt-cf-select.label-block label.slt-cf-label, 
     82form#post div.slt-cf-file.label-block label.slt-cf-label, 
     83form#post div.slt-cf-text.label-block label.slt-cf-label, 
     84form#post div.slt-cf-colorpicker.label-block label.slt-cf-label, 
     85form#post div.slt-cf-notice.label-block h4.slt-cf-label, 
     86form#post div.slt-cf-date.label-block label.slt-cf-label, 
     87form#post div.slt-cf-datetime.label-block label.slt-cf-label, 
     88form#post div.slt-cf-time.label-block label.slt-cf-label { 
     89  display: block; 
     90  margin-bottom: 3px; 
     91} 
     92form#post div.slt-cf-multifield { 
     93  margin-bottom: 7px; 
     94} 
     95form#post div.slt-cf-colorpicker input { 
     96  width: 8em; 
     97  text-transform: lowercase; 
     98} 
     99.colorpicker input[type=text] { 
     100  line-height: 1; 
     101  height: 13px; 
     102} 
     103ul.slt-cf-sortable li { 
     104  margin-bottom: 6px; 
     105} 
     106ul.slt-cf-sortable li span.ui-icon { 
     107  display: inline-block; 
     108  position: relative; 
     109  top: 2px; 
     110  cursor: move; 
     111} 
     112div.slt-cf-checkboxes.thumbnails ul.slt-cf-sortable li.ui-state-default { 
     113  background-image: none; 
     114} 
     115div.slt-cf-checkboxes.thumbnails ul.slt-cf-sortable li.ui-state-default img { 
     116  display: inline-block; 
     117  vertical-align: middle; 
     118  padding: 5px; 
     119} 
     120/* User profile fields */ 
     121#profile-page span.mceEditor { 
     122  display: block; 
     123  width: 70%; 
     124} 
     125/* Gmap Geocoding autocomplete */ 
     126.ui-autocomplete { 
     127  margin-top: 20px; 
     128  padding: 0; 
     129  width: 300px !important; 
     130  background: #fff !important; 
     131  border: 1px solid #999 !important; 
     132  border-radius: 5px !important; 
     133  -moz-border-radius: 5px !important; 
     134  -webkit-border-radius: 5px !important; 
     135  box-shadow: 3px 3px 4px #666; 
     136  -moz-box-shadow: 3px 3px 4px #666; 
     137  -webkit-box-shadow: 3px 3px 4px #666; 
     138  font-size: 11px !important; 
     139  list-style-type: none; 
     140} 
     141.ui-menu-item a { 
     142  display: block !important; 
     143  padding: 5px 7px !important; 
     144  border-radius: 5px !important; 
     145  -moz-border-radius: 5px !important; 
     146  -webkit-border-radius: 5px !important; 
     147} 
     148.ui-menu-item a:hover, 
     149.ui-menu-item a:focus, 
     150.ui-menu-item a:active, 
     151#ui-active-menuitem { 
     152  background: #69c !important; 
     153  color: #fff !important; 
     154  cursor: pointer !important; 
     155} 
     156/* Gmap max markers errors */ 
     157#markers_max_message { 
     158  font-weight: bold; 
     159} 
     160#markers_max_message.markers_max_message_error { 
     161  background: #c00; 
     162  border-radius: 3px; 
     163  color: #fff; 
     164  padding: 3px 6px 4px 6px; 
     165} 
     166/* Timepicker related styles */ 
     167.ui-timepicker-div .ui-widget-header { 
     168  margin-bottom: 8px; 
     169} 
     170.ui-timepicker-div dl { 
     171  text-align: left; 
     172} 
     173.ui-timepicker-div dl dt { 
     174  height: 25px; 
     175  margin-bottom: -25px; 
     176} 
     177.ui-timepicker-div dl dd { 
     178  margin: 0 10px 10px 65px; 
     179} 
     180.ui-timepicker-div td { 
     181  font-size: 90%; 
     182} 
     183.ui-tpicker-grid-label { 
     184  background: none; 
     185  border: none; 
     186  margin: 0; 
     187  padding: 0; 
     188} 
     189/* Color previews */ 
     190.slt-cf-color-preview { 
     191  display: inline-block; 
     192  padding: .3em 1em; 
     193  margin: .4em; 
     194  vertical-align: top; 
     195  text-align: center; 
     196  border: 1px solid #666; 
     197} 
     198/* Attachments lists */ 
     199ul.slt-cf-attachments-list li { 
     200  float: left; 
     201  margin: 0 20px 20px 0; 
     202} 
     203ul.slt-cf-attachments-list li .slt-cf-attachment { 
     204  display: block; 
     205  overflow: hidden; 
     206} 
     207ul.slt-cf-attachments-list li .slt-cf-attachment.file { 
     208  box-sizing: border-box; 
     209  padding: 10px; 
     210  min-height: 80px; 
     211  -moz-box-shadow: inset 0 0 10px 1px #999; 
     212  -webkit-box-shadow: inset 0 0 10px 1px #999; 
     213  box-shadow: inset 0 0 10px 1px #999; 
     214} 
     215ul.slt-cf-attachments-list li .slt-cf-attachment.file p { 
     216  margin: 0; 
     217  padding-top: 45px; 
     218} 
     219ul.slt-cf-attachments-list li label { 
     220  display: block; 
     221  text-align: center; 
     222} 
     223ul.slt-cf-attachments-list li label .slt-cf-attachment { 
     224  margin-bottom: .6em; 
     225} 
     226/* Image previews */ 
     227.slt-fs-preview img { 
     228  max-width: 100%; 
     229  height: auto; 
     230} 
  • developers-custom-fields/trunk/js/slt-cf-gmaps.js

    r1154478 r1208892  
    22// Contributed by adriantoll 
    33// Be careful of center (in this script) / centre (DCF form field IDs) 
    4 /* global google, slt_cf_gmaps */ 
     4/* global google, slt_cf_gmaps, alert */ 
    55/* exported slt_cf_gmap_init */ 
    66 
     
    1818    for (var key in slt_cf_maps[container_id].markers) { 
    1919 
    20       // Filter unwanted properties from the prototype 
    21       if (slt_cf_maps[container_id].markers.hasOwnProperty(key)) { 
    22  
    23         // Add this marker to the HTML string 
    24         markers_string += slt_cf_maps[container_id].markers[key]; 
    25  
    26       } 
     20      // Get the marker latlng as a string 
     21      var marker_latlng = slt_cf_maps[container_id].markers[key].getPosition().toString(); 
     22 
     23      // Add this marker to the HTML string 
     24      markers_string += marker_latlng; 
    2725 
    2826    } 
     
    3331    // Write to the input 
    3432    document.getElementById(container_id + '_map_markers').value = markers_string; 
    35     //console.log(markers_string); 
    3633 
    3734  } 
     
    4643 
    4744    // If it's not an input map 
    48     if (slt_cf_maps[container_id].map._slt_cf_input_map === false) { 
     45    if (slt_cf_maps[container_id].settings.input_map === false) { 
    4946 
    5047      // Add a simple marker to the map 
     
    5956    else { 
    6057 
    61       // Add an interactive marker to the map 
    62       marker = new google.maps.Marker({ 
    63         draggable: true, 
    64         map: slt_cf_maps[container_id].map, 
    65         position: new_marker_latlng, 
    66         title: 'Drag to move, click to delete', 
    67       }); 
    68  
    69       // Increment the number of markers 
    70       slt_cf_maps[container_id].marker_total++; 
    71  
    72       // Set a variable for ease of use 
    73       marker.id = slt_cf_maps[container_id].marker_total; 
    74  
    75       // Add the marker latlng to the markers array 
    76       slt_cf_maps[container_id].markers[marker.id] = marker.position.toString(); 
    77  
    78       // Update the <input> array 
    79       write_markers(container_id); 
    80  
    81       // Set an event listener for a click on the marker 
    82       google.maps.event.addListener(marker, 'click', function() { 
    83  
    84         // Remove the marker from the array 
    85         delete slt_cf_maps[container_id].markers[marker.id]; 
    86  
    87         // Remove the marker from the map 
    88         this.setMap(null); 
     58      // Only add a marker if we haven't reached the maximum number of markers 
     59      // or if this is a map being initialised 
     60      if ( slt_cf_maps[container_id].markers.length < slt_cf_maps[container_id].settings.markers_max || slt_cf_maps[container_id].settings.init === true ) { 
     61 
     62        // Add an interactive marker to the map 
     63        // by pushing it to the markers object 
     64        slt_cf_maps[container_id].markers.push( 
     65          new google.maps.Marker({ 
     66            draggable: true, 
     67            map: slt_cf_maps[container_id].map, 
     68            position: new_marker_latlng, 
     69            title: 'Drag to move, click to delete', 
     70          }) 
     71        ); 
    8972 
    9073        // Update the <input> array 
    9174        write_markers(container_id); 
    9275 
    93       }); 
    94  
    95       // Set an event listener for the end of a marker being dragged 
    96       google.maps.event.addListener(marker, 'dragend', function(e) { 
    97  
    98         // Set the new position in an array 
    99         slt_cf_maps[container_id].markers[marker.id] = e.latLng.toString(); 
    100  
    101         // Update the <input> array 
    102         write_markers(container_id); 
    103  
    104       }); 
     76        // Get the marker's array key 
     77        var marker_key = slt_cf_maps[container_id].markers.length - 1; 
     78 
     79        // Set an event listener for a click on the marker 
     80        google.maps.event.addListener(slt_cf_maps[container_id].markers[marker_key], 'click', function() { 
     81 
     82          // Remove the marker from the array 
     83          slt_cf_maps[container_id].markers.splice(marker_key,1); 
     84 
     85          // Remove the marker from the map 
     86          this.setMap(null); 
     87 
     88          // Remove a "max markers" error highlight 
     89          if (slt_cf_maps[container_id].settings.markers_max > 0) { document.getElementById('markers_max_message').className = ''; } 
     90 
     91          // Update the <input> array 
     92          write_markers(container_id); 
     93 
     94        }); 
     95 
     96        // Set an event listener for the end of a marker being dragged 
     97        google.maps.event.addListener(slt_cf_maps[container_id].markers[marker_key], 'dragend', function(e) { 
     98 
     99          // Update the <input> array 
     100          write_markers(container_id); 
     101 
     102        }); 
     103 
     104      // Otherwise highlight the max markers message 
     105      } else if (slt_cf_maps[container_id].settings.markers_max > 1) { 
     106 
     107        document.getElementById('markers_max_message').className = 'markers_max_message_error'; 
     108 
     109      } 
    105110 
    106111    } 
     
    110115 
    111116  // Write out a map for input or output 
    112   function slt_cf_gmap_init( container_id, map_mode, markers_available, map_markers, map_center_latlng, map_zoom, gmap_type, callback ) { 
     117  function slt_cf_gmap_init( container_id, map_mode, markers_max, map_markers, map_center_latlng, map_zoom, gmap_type, callback ) { 
    113118 
    114119    // Set the map type 
     
    135140    slt_cf_maps[container_id].map = new google.maps.Map(document.getElementById( container_id ), map_options); 
    136141 
     142    // Add objects to the container for markers and settings 
     143    slt_cf_maps[container_id].markers = []; 
     144    slt_cf_maps[container_id].settings = []; 
     145 
     146    // Add an init variable so we don't crash when reducing max markers 
     147    slt_cf_maps[container_id].settings.init = true; 
     148 
    137149    // Set the container_id as a variable in the map object 
    138     slt_cf_maps[container_id].map._slt_cf_mapname = container_id; 
     150    // to write changes out to the container HTML 
     151    slt_cf_maps[container_id].map.parent_container_id = container_id; 
     152 
     153    // Set the maximum number of markers 
     154    slt_cf_maps[container_id].settings.markers_max = markers_max; 
    139155 
    140156    // Store whether the map is an input map or not 
    141     if (map_mode === 'input') { slt_cf_maps[container_id].map._slt_cf_input_map = true; } 
    142     else { slt_cf_maps[container_id].map._slt_cf_input_map = false; } 
     157    if (map_mode === 'input') { slt_cf_maps[container_id].settings.input_map = true; } 
     158    else                      { slt_cf_maps[container_id].settings.input_map = false; } 
    143159 
    144160    // Extra settings for markers 
    145     if (markers_available) { 
    146  
    147       // Add a markers array to the map container 
    148       slt_cf_maps[container_id].markers = []; 
    149  
    150       // Set the current number of markers 
    151       slt_cf_maps[container_id].marker_total = 0; 
    152  
    153       // Catch old single marker fields - possibly not necessary but just in case 
    154       if ( ! map_markers instanceof Array) { map_markers = [ map_markers ]; } 
     161    if (markers_max) { 
    155162 
    156163      // If there are existing markers 
     
    182189 
    183190        // Set a variable to store double click status 
    184         slt_cf_maps[container_id].doubleClick = false; 
     191        slt_cf_maps[container_id].settings.doubleClick = false; 
    185192 
    186193        // Function to deal with double clicks 
     
    188195 
    189196          // Set the double click status to true so single click functions doesn't get triggered 
    190           slt_cf_maps[container_id].doubleClick = true; 
     197          slt_cf_maps[container_id].settings.doubleClick = true; 
    191198 
    192199          // Reset double click status once the delay for a potential single click has passed 
    193           window.setTimeout(function(){ slt_cf_maps[container_id].doubleClick = false; }, 250); 
     200          window.setTimeout(function(){ slt_cf_maps[container_id].settings.doubleClick = false; }, 250); 
    194201 
    195202        }); 
     
    199206 
    200207          // Wait 250ms to see if there's a double click 
    201           window.setTimeout(function(){ if (!slt_cf_maps[container_id].doubleClick) { 
     208          window.setTimeout(function(){ if (!slt_cf_maps[container_id].settings.doubleClick) { 
    202209 
    203210            // Add the marker to the map 
     
    221228 
    222229        // Write the new zoom, center and bounds for saving with the post 
    223         document.getElementById( this._slt_cf_mapname + '_zoom' ).value = this.getZoom(); 
    224         document.getElementById( this._slt_cf_mapname + '_centre_latlng' ).value = this.getCenter().toString().slice(1,-1).replace(' ',''); 
    225         document.getElementById( this._slt_cf_mapname + '_bounds_sw').value = this.getBounds().getSouthWest().toString().slice(1,-1).replace(' ',''); 
    226         document.getElementById( this._slt_cf_mapname + '_bounds_ne').value = this.getBounds().getNorthEast().toString().slice(1,-1).replace(' ',''); 
     230        document.getElementById( this.parent_container_id + '_zoom' ).value = this.getZoom(); 
     231        document.getElementById( this.parent_container_id + '_centre_latlng' ).value = this.getCenter().toString().slice(1,-1).replace(' ',''); 
     232        document.getElementById( this.parent_container_id + '_bounds_sw').value = this.getBounds().getSouthWest().toString().slice(1,-1).replace(' ',''); 
     233        document.getElementById( this.parent_container_id + '_bounds_ne').value = this.getBounds().getNorthEast().toString().slice(1,-1).replace(' ',''); 
    227234 
    228235      }); 
     
    233240        // Initialise the geocoder 
    234241        var geocoder = new google.maps.Geocoder(); 
    235  
    236         // Set up the geocoder bounds 
    237         var boundsSW = jQuery( '#' + container_id + '_bounds_sw' ).val().split(','); 
    238         var boundsNE = jQuery( '#' + container_id + '_bounds_ne' ).val().split(','); 
    239         var geocodeBoundsSW = new google.maps.LatLng( boundsSW[0], boundsSW[1] ); 
    240         var geocodeBoundsNE = new google.maps.LatLng( boundsNE[0], boundsNE[1] ); 
    241         slt_cf_maps[container_id].map.geocodeBounds = new google.maps.LatLngBounds(geocodeBoundsSW,geocodeBoundsNE); 
    242242 
    243243        // Kick off the geocoder on page load 
     
    252252          // Make the marker instructions conditional 
    253253          var marker_instructions = ''; 
    254           if (markers_available) { marker_instructions = '<small>Click on the map to add a marker. Click a marker to remove it. Click and drag a marker to change its location.<br><br></small>'; } 
     254          if (markers_max) { 
     255 
     256            marker_instructions =  ''; 
     257 
     258              if ( slt_cf_maps[container_id].settings.markers_max > 1 ) { 
     259 
     260                marker_instructions += '<p>Click on the map or find an address to add a marker. Click a marker to remove it. Drag and drop a marker to change its location.</p>'; 
     261                marker_instructions += '<p id="markers_max_message">Maximum number of markers: ' + slt_cf_maps[container_id].settings.markers_max + '</p>'; 
     262 
     263              } 
     264 
     265              else { 
     266 
     267                marker_instructions += '<p> Drag and drop the marker or find an address below.</p>'; 
     268 
     269              } 
     270 
     271 
     272          } 
    255273 
    256274          // Write the autocomplete form 
     
    304322              slt_cf_maps[container_id].map.panTo(newLocation); 
    305323 
    306               // Add a marker if appropriate 
    307               if ( markers_available ){ add_marker(container_id,newLocation); } 
     324              // If there are multiple markers 
     325              if ( slt_cf_maps[container_id].settings.markers_max > 1 ){ 
     326 
     327                // Try to add a new marker 
     328                add_marker(container_id,newLocation); 
     329 
     330              // Or if there's one marker 
     331              } else if ( slt_cf_maps[container_id].settings.markers_max === 1 ) { 
     332 
     333                // Move the marker 
     334                slt_cf_maps[container_id].markers[0].setPosition(newLocation); 
     335 
     336                // And update the <input> array 
     337                write_markers(container_id); 
     338 
     339              } 
    308340 
    309341            } 
     
    319351    // If there's a callback, call it with a reference to the map 
    320352    if ( typeof callback !== 'undefined' && window[callback] ) { window[callback]( slt_cf_maps[container_id].map ); } 
     353 
     354    // We've finished, so init is no longer true 
     355    slt_cf_maps[container_id].settings.init = false; 
    321356 
    322357  } 
  • developers-custom-fields/trunk/js/slt-cf-gmaps.min.js

    r1154478 r1208892  
    1 var slt_cf_maps=[];function write_markers(b){var c="";for(var a in slt_cf_maps[b].markers){if(slt_cf_maps[b].markers.hasOwnProperty(a)){c+=slt_cf_maps[b].markers[a]}}c=c.replace(/\)\(/g,"|").replace(/\(/g,"").replace(/\)/g,"").replace(/ /g,"");document.getElementById(b+"_map_markers").value=c}function add_marker(c,b){var a;if(slt_cf_maps[c].map._slt_cf_input_map===false){a=new google.maps.Marker({map:slt_cf_maps[c].map,position:b})}else{a=new google.maps.Marker({draggable:true,map:slt_cf_maps[c].map,position:b,title:"Drag to move, click to delete"});slt_cf_maps[c].marker_total++;a.id=slt_cf_maps[c].marker_total;slt_cf_maps[c].markers[a.id]=a.position.toString();write_markers(c);google.maps.event.addListener(a,"click",function(){delete slt_cf_maps[c].markers[a.id];this.setMap(null);write_markers(c)});google.maps.event.addListener(a,"dragend",function(d){slt_cf_maps[c].markers[a.id]=d.latLng.toString();write_markers(c)})}}function slt_cf_gmap_init(f,m,i,b,h,c,g,p){if(g==="hybrid"){g=google.maps.MapTypeId.HYBRID}else{if(g==="satellite"){g=google.maps.MapTypeId.SATELLITE}else{if(g==="terrain"){g=google.maps.MapTypeId.TERRAIN}else{g=google.maps.MapTypeId.ROADMAP}}}h=h.replace(" ","");h=h.split(",");h=new google.maps.LatLng(h[0],h[1]);var l={center:h,mapTypeId:g,scrollwheel:false,zoom:c};slt_cf_maps[f]=[];slt_cf_maps[f].map=new google.maps.Map(document.getElementById(f),l);slt_cf_maps[f].map._slt_cf_mapname=f;if(m==="input"){slt_cf_maps[f].map._slt_cf_input_map=true}else{slt_cf_maps[f].map._slt_cf_input_map=false}if(i){slt_cf_maps[f].markers=[];slt_cf_maps[f].marker_total=0;if(!b instanceof Array){b=[b]}if(b.length>0){for(var o in b){if(b.hasOwnProperty(o)){var k=b[o].split(",");k=new google.maps.LatLng(k[0],k[1]);add_marker(f,k)}}}if(m==="input"){slt_cf_maps[f].doubleClick=false;google.maps.event.addListener(slt_cf_maps[f].map,"dblclick",function(){slt_cf_maps[f].doubleClick=true;window.setTimeout(function(){slt_cf_maps[f].doubleClick=false},250)});google.maps.event.addListener(slt_cf_maps[f].map,"click",function(q){window.setTimeout(function(){if(!slt_cf_maps[f].doubleClick){add_marker(f,q.latLng)}},250)})}}if(m==="input"){google.maps.event.addListener(slt_cf_maps[f].map,"bounds_changed",function(){document.getElementById(this._slt_cf_mapname+"_zoom").value=this.getZoom();document.getElementById(this._slt_cf_mapname+"_centre_latlng").value=this.getCenter().toString().slice(1,-1).replace(" ","");document.getElementById(this._slt_cf_mapname+"_bounds_sw").value=this.getBounds().getSouthWest().toString().slice(1,-1).replace(" ","");document.getElementById(this._slt_cf_mapname+"_bounds_ne").value=this.getBounds().getNorthEast().toString().slice(1,-1).replace(" ","")});if(jQuery().autocomplete){var e=new google.maps.Geocoder();var d=jQuery("#"+f+"_bounds_sw").val().split(",");var n=jQuery("#"+f+"_bounds_ne").val().split(",");var a=new google.maps.LatLng(d[0],d[1]);var j=new google.maps.LatLng(n[0],n[1]);slt_cf_maps[f].map.geocodeBounds=new google.maps.LatLngBounds(a,j);jQuery(document).ready(function(r){var s="";if(document.createElement("input").placeholder!=="undefined"){s="screen-reader-text"}var q="";if(i){q="<small>Click on the map to add a marker. Click a marker to remove it. Click and drag a marker to change its location.<br><br></small>"}r("#"+f).after('<p class="gmap-address">'+q+'<label for="'+f+'_address" class="'+s+'">'+slt_cf_gmaps.geocoder_label+':</label><input type="text" id="'+f+'_address" name="'+f+'_address" value="" class="regular-text" style="width:100%;" placeholder="Find an address" /></p>');r("#"+f+"_address").autocomplete({source:function(u,t){e.geocode({address:u.term,bounds:slt_cf_maps[f].map.getBounds()},function(w,v){if(v===google.maps.GeocoderStatus.OK){t(r.map(w,function(x){return{label:x.formatted_address,value:x.formatted_address,latitude:x.geometry.location.lat(),longitude:x.geometry.location.lng()}}))}else{console.log("Geocode was not successful for the following reason: "+v)}})},select:function(t,v){var u=new google.maps.LatLng(v.item.latitude,v.item.longitude);slt_cf_maps[f].map.panTo(u);if(i){add_marker(f,u)}}})})}}if(typeof p!=="undefined"&&window[p]){window[p](slt_cf_maps[f].map)}}jQuery(document).ready(function(a){if(a("div.gmap_input").length){a("div.gmap_input").each(function(){var c,b;c=a(this).attr("id");if(a("input.gmap_toggle_display").length){a("input.gmap_toggle_display").change(function(){if(a(this).hasClass("yes")){a("#"+c+"_wrapper").slideDown("fast",function(){b=slt_cf_maps[c].map.getCenter();google.maps.event.trigger(slt_cf_maps[c].map,"resize");slt_cf_maps[c].map.setCenter(b)})}else{a("#"+c+"_wrapper").slideUp()}})}})}}); 
     1// Google Maps script for Developer's Custom Fields 
     2// Contributed by adriantoll 
     3// Be careful of center (in this script) / centre (DCF form field IDs) 
     4/* global google, slt_cf_gmaps, alert *//* exported slt_cf_gmap_init */// Set up array for multiple maps and markers 
     5function write_markers(e){var t="";for(var n in slt_cf_maps[e].markers){var r=slt_cf_maps[e].markers[n].getPosition().toString();t+=r}t=t.replace(/\)\(/g,"|").replace(/\(/g,"").replace(/\)/g,"").replace(/ /g,"");document.getElementById(e+"_map_markers").value=t}function add_marker(e,t){var n;if(slt_cf_maps[e].settings.input_map===!1)n=new google.maps.Marker({map:slt_cf_maps[e].map,position:t});else if(slt_cf_maps[e].markers.length<slt_cf_maps[e].settings.markers_max||slt_cf_maps[e].settings.init===!0){slt_cf_maps[e].markers.push(new google.maps.Marker({draggable:!0,map:slt_cf_maps[e].map,position:t,title:"Drag to move, click to delete"}));write_markers(e);var r=slt_cf_maps[e].markers.length-1;google.maps.event.addListener(slt_cf_maps[e].markers[r],"click",function(){slt_cf_maps[e].markers.splice(r,1);this.setMap(null);slt_cf_maps[e].settings.markers_max>0&&(document.getElementById("markers_max_message").className="");write_markers(e)});google.maps.event.addListener(slt_cf_maps[e].markers[r],"dragend",function(t){write_markers(e)})}else slt_cf_maps[e].settings.markers_max>1&&(document.getElementById("markers_max_message").className="markers_max_message_error")}function slt_cf_gmap_init(e,t,n,r,i,s,o,u){o==="hybrid"?o=google.maps.MapTypeId.HYBRID:o==="satellite"?o=google.maps.MapTypeId.SATELLITE:o==="terrain"?o=google.maps.MapTypeId.TERRAIN:o=google.maps.MapTypeId.ROADMAP;i=i.replace(" ","");i=i.split(",");i=new google.maps.LatLng(i[0],i[1]);var a={center:i,mapTypeId:o,scrollwheel:!1,zoom:s};slt_cf_maps[e]=[];slt_cf_maps[e].map=new google.maps.Map(document.getElementById(e),a);slt_cf_maps[e].markers=[];slt_cf_maps[e].settings=[];slt_cf_maps[e].settings.init=!0;slt_cf_maps[e].map.parent_container_id=e;slt_cf_maps[e].settings.markers_max=n;t==="input"?slt_cf_maps[e].settings.input_map=!0:slt_cf_maps[e].settings.input_map=!1;if(n){if(r.length>0)for(var f in r)if(r.hasOwnProperty(f)){var l=r[f].split(",");l=new google.maps.LatLng(l[0],l[1]);add_marker(e,l)}if(t==="input"){slt_cf_maps[e].settings.doubleClick=!1;google.maps.event.addListener(slt_cf_maps[e].map,"dblclick",function(){slt_cf_maps[e].settings.doubleClick=!0;window.setTimeout(function(){slt_cf_maps[e].settings.doubleClick=!1},250)});google.maps.event.addListener(slt_cf_maps[e].map,"click",function(t){window.setTimeout(function(){slt_cf_maps[e].settings.doubleClick||add_marker(e,t.latLng)},250)})}}if(t==="input"){google.maps.event.addListener(slt_cf_maps[e].map,"bounds_changed",function(){document.getElementById(this.parent_container_id+"_zoom").value=this.getZoom();document.getElementById(this.parent_container_id+"_centre_latlng").value=this.getCenter().toString().slice(1,-1).replace(" ","");document.getElementById(this.parent_container_id+"_bounds_sw").value=this.getBounds().getSouthWest().toString().slice(1,-1).replace(" ","");document.getElementById(this.parent_container_id+"_bounds_ne").value=this.getBounds().getNorthEast().toString().slice(1,-1).replace(" ","")});if(jQuery().autocomplete){var c=new google.maps.Geocoder;jQuery(document).ready(function(t){var r="";document.createElement("input").placeholder!=="undefined"&&(r="screen-reader-text");var i="";if(n){i="";if(slt_cf_maps[e].settings.markers_max>1){i+="<p>Click on the map or find an address to add a marker. Click a marker to remove it. Drag and drop a marker to change its location.</p>";i+='<p id="markers_max_message">Maximum number of markers: '+slt_cf_maps[e].settings.markers_max+"</p>"}else i+="<p> Drag and drop the marker or find an address below.</p>"}t("#"+e).after('<p class="gmap-address">'+i+'<label for="'+e+'_address" class="'+r+'">'+slt_cf_gmaps.geocoder_label+':</label><input type="text" id="'+e+'_address" name="'+e+'_address" value="" class="regular-text" style="width:100%;" placeholder="Find an address" /></p>');t("#"+e+"_address").autocomplete({source:function(n,r){c.geocode({address:n.term,bounds:slt_cf_maps[e].map.getBounds()},function(e,n){n===google.maps.GeocoderStatus.OK?r(t.map(e,function(e){return{label:e.formatted_address,value:e.formatted_address,latitude:e.geometry.location.lat(),longitude:e.geometry.location.lng()}})):console.log("Geocode was not successful for the following reason: "+n)})},select:function(t,n){var r=new google.maps.LatLng(n.item.latitude,n.item.longitude);slt_cf_maps[e].map.panTo(r);if(slt_cf_maps[e].settings.markers_max>1)add_marker(e,r);else if(slt_cf_maps[e].settings.markers_max===1){slt_cf_maps[e].markers[0].setPosition(r);write_markers(e)}}})})}}typeof u!="undefined"&&window[u]&&window[u](slt_cf_maps[e].map);slt_cf_maps[e].settings.init=!1}var slt_cf_maps=[];jQuery(document).ready(function(e){e("div.gmap_input").length&&e("div.gmap_input").each(function(){var t,n;t=e(this).attr("id");e("input.gmap_toggle_display").length&&e("input.gmap_toggle_display").change(function(){e(this).hasClass("yes")?e("#"+t+"_wrapper").slideDown("fast",function(){n=slt_cf_maps[t].map.getCenter();google.maps.event.trigger(slt_cf_maps[t].map,"resize");slt_cf_maps[t].map.setCenter(n)}):e("#"+t+"_wrapper").slideUp()})})}); 
  • developers-custom-fields/trunk/readme.txt

    r1156053 r1208892  
    9292 
    9393== Changelog == 
     94= 1.3 = 
     95* `user_new_form` hook used to add fields to new user form (to include fields in new user form, set scope as per including them in registration form, e.g. `array( 'registration', 'subscriber' )` - the latter being the default user role) 
     96* `group_by_post_type` now includes option group label even if there's only one post type in the options 
     97* Changed `location_marker` field parameter to accept integers, to control how many markers can be set (default is one) 
     98* Google Maps JavaScript: Reworked code for more efficiency, prevent addition of more markers to a map than set in `location_marker`, variable instructions based on maximum number of markers, geocode moves single map marker (as in previous single-marker releases) or adds new markers on maps with multiple markers 
     99 
    94100= 1.2.2 = 
    95101* Changed admin notices so they only show for admins 
  • developers-custom-fields/trunk/slt-cf-init.php

    r1156053 r1208892  
    432432                'timepicker_format'         => $slt_custom_fields['timepicker_default_format'], 
    433433                'timepicker_ampm'           => $slt_custom_fields['timepicker_default_ampm'], 
    434                 'location_marker'           => true, 
     434                'location_marker'           => 1, 
    435435                'gmap_type'                 => 'roadmap', 
    436436                'edit_on_profile'           => false, 
     
    487487                            "centre_latlng" => "52.337946593485135,-1.667382812500029", 
    488488                            "zoom"          => "6", 
    489                             "marker_latlng" => "52.24386921477694,-0.9203125000000227", 
     489                            "map_markers"   => array( "52.24386921477694,-0.9203125000000227" ), 
    490490                            "bounds_sw"     => "50.27802587971423,-7.160546875000023", 
    491491                            "bounds_ne"     => "54.306194393010095,3.8257812499999773" 
     
    663663                        } 
    664664                        // Add sorting by post type if multiple post types, in order to group in output 
    665                         $multiple_post_types = ( isset( $field['options_query'] ) && is_array( $field['options_query'] ) && isset( $field['options_query']['post_type'] ) && is_array( $field['options_query']['post_type'] ) && count( $field['options_query']['post_type'] ) > 1 ); 
     665                        $multiple_post_types = ( isset( $field['options_query'] ) && is_array( $field['options_query'] ) && isset( $field['options_query']['post_type'] ) && is_array( $field['options_query']['post_type'] ) ); 
    666666                        if ( $multiple_post_types ) { 
    667667                            add_action( 'pre_get_posts', 'slt_cf_sort_queries_by_post_type' ); 
  • developers-custom-fields/trunk/slt-cf-lib.php

    r1154478 r1208892  
    608608 
    609609// Output a map (for display or input) 
    610 function slt_cf_gmap( $type = 'output', $name = '', $values = 'stored_data', $width = 0, $height = 0, $location_marker = null, $map_type_id = '', $echo = true, $js_callback = '', $required = true, $object_type = 'post' ) { 
     610function slt_cf_gmap( $type = 'output', $name = '', $values = 'stored_data', $width = 0, $height = 0, $location_markers = null, $map_type_id = '', $echo = true, $js_callback = '', $required = true, $object_type = 'post' ) { 
    611611    $output = ''; 
    612612    $using_default_name = false; 
     
    624624        $name = slt_cf_field_key( $name, $object_type ); 
    625625    } 
    626     if ( $location_marker === null ) { 
    627         $location_marker = 'true'; 
    628     } else { 
    629         $location_marker = $location_marker ? 'true' : 'false'; 
    630     } 
     626    $location_markers = (int) $location_markers; // This should handle pre-1.3 booleans 
    631627    if ( empty( $map_type_id ) ) { 
    632628        $map_type_id = 'roadmap'; 
     
    781777    $inline_script = "jQuery( document ).ready( function($) {\n"; 
    782778    // Output multiple markers array as JS array 
    783     $inline_script .= "slt_cf_gmap_init( '{$id}', '{$type}', {$location_marker}, [ '" . implode( "','", $values['map_markers'] ) . "' ], '{$values['centre_latlng']}', {$values['zoom']}, '{$map_type_id}'"; 
     779    $inline_script .= "slt_cf_gmap_init( '{$id}', '{$type}', {$location_markers}, [ '" . implode( "','", $values['map_markers'] ) . "' ], '{$values['centre_latlng']}', {$values['zoom']}, '{$map_type_id}'"; 
    784780    // Callback? 
    785781    if ( $js_callback ) { 
  • developers-custom-fields/trunk/slt-custom-fields.php

    r1156053 r1208892  
    1010Description: Provides theme developers with tools for managing custom fields. 
    1111Author: Steve Taylor 
    12 Version: 1.2.2 
     12Version: 1.3 
    1313Author URI: http://sltaylor.co.uk 
    1414License: GPLv2 
     
    5151define( 'SLT_CF_NO_OPTIONS', __( 'No options to choose from', SLT_CF_TEXT_DOMAIN ) ); 
    5252define( 'SLT_CF_REQUEST_PROTOCOL', isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://' ); 
    53 define( 'SLT_CF_VERSION', '1.2.2' ); 
     53define( 'SLT_CF_VERSION', '1.3' ); 
    5454define( 'SLT_CF_PRIMARY_FILE_PATH', plugin_basename( __FILE__ ) ); 
    5555$slt_custom_fields = array(); 
     
    143143    add_action( 'add_meta_boxes', 'slt_cf_display_post_attachment', 10, 2 ); 
    144144    add_action( 'do_meta_boxes', 'slt_cf_remove_default_meta_box', 1, 3 ); 
     145    add_action( 'user_new_form', 'slt_cf_display_user', 12, 1 ); 
    145146    add_action( 'show_user_profile', 'slt_cf_display_user', 12, 1 ); 
    146147    add_action( 'edit_user_profile', 'slt_cf_display_user', 12, 1 ); 
     
    174175        $user_id = null; 
    175176        if ( ! empty( $user ) ) { 
    176             // Editing a profile, not registering a new user 
    177             $user_roles = $user->roles; 
    178             $user_role = array_shift( $user_roles ); 
    179             $user_id = $user->ID; 
     177            if ( $user != 'add-new-user' ) { 
     178                // Editing a profile, not registering a new user 
     179                $user_roles = $user->roles; 
     180                $user_role = array_shift( $user_roles ); 
     181                $user_id = $user->ID; 
     182            } 
    180183        } 
    181184        slt_cf_init_fields( 'user', $user_role, $user_id ); 
Note: See TracChangeset for help on using the changeset viewer.