+ if (!empty($futureSurveys)) /* Dis someone use it ? */
+ {
+ $list .= "
". gT("Following survey(s) are not yet active but you can register for them.")."
+ ".gT("The following surveys are available:")."
+
";
+ if( $outputSurveys==0)
+ {
+ $list=CHtml::openTag('div',array('class'=>'col-xs-12')).gT("No available surveys").CHtml::closeTag('div');
+ }
+ echo $list;
diff --git a/application/views/admin/update/_ajaxVariables.php b/application/views/admin/update/_ajaxVariables.php
index 67639c33d3c..bd975a1bf2a 100644
--- a/application/views/admin/update/_ajaxVariables.php
+++ b/application/views/admin/update/_ajaxVariables.php
@@ -17,8 +17,8 @@
?>
diff --git a/application/views/admin/update/manage/manage_key.php b/application/views/admin/update/manage/manage_key.php
new file mode 100644
index 00000000000..94ef19e6174
--- /dev/null
+++ b/application/views/admin/update/manage/manage_key.php
@@ -0,0 +1,77 @@
+
diff --git a/application/views/admin/update/manage/subscribe.php b/application/views/admin/update/manage/subscribe.php
new file mode 100644
index 00000000000..5141a78d2d9
--- /dev/null
+++ b/application/views/admin/update/manage/subscribe.php
@@ -0,0 +1,53 @@
+
+
diff --git a/application/views/admin/update/updater/welcome/_welcome.php b/application/views/admin/update/updater/welcome/_welcome.php
index a7ef0af50cd..a9b7c11a6a7 100644
--- a/application/views/admin/update/updater/welcome/_welcome.php
+++ b/application/views/admin/update/updater/welcome/_welcome.php
@@ -47,8 +47,8 @@
-
diff --git a/application/views/survey/questions/answer/arrays/10point/rows/answer_row.php b/application/views/survey/questions/answer/arrays/10point/rows/answer_row.php
index d90c940a9f0..74761d3f7fb 100644
--- a/application/views/survey/questions/answer/arrays/10point/rows/answer_row.php
+++ b/application/views/survey/questions/answer/arrays/10point/rows/answer_row.php
@@ -12,7 +12,7 @@
-
+ ">
" role="group" aria-labelledby="answertext"
class="answers-list radio-list "
>
-
+ ">
0): // if second label set is used ?>
-
+ ">
-
" role="radiogroup" aria-labelledby="answertext">
+ " role="radiogroup" aria-labelledby="answertext">
-
+ ">
diff --git a/application/views/survey/questions/answer/arrays/multiflexi/rows/answer_row.php b/application/views/survey/questions/answer/arrays/multiflexi/rows/answer_row.php
index db0c076cd7e..afc77859045 100644
--- a/application/views/survey/questions/answer/arrays/multiflexi/rows/answer_row.php
+++ b/application/views/survey/questions/answer/arrays/multiflexi/rows/answer_row.php
@@ -17,7 +17,7 @@
" role="group" aria-labelledby="answertext">
- ">
+ ">
" role="group" aria-labelledby="answertext">
- ">
+ ">
- " role="radiogroup" aria-labelledby="answertext">
+ " role="radiogroup" aria-labelledby="answertext">
- " id="answertext">
+ " id="answertext">
diff --git a/application/views/survey/questions/answer/multiplechoice/rows/answer_row.php b/application/views/survey/questions/answer/multiplechoice/rows/answer_row.php
deleted file mode 100644
index 53805abfa3a..00000000000
--- a/application/views/survey/questions/answer/multiplechoice/rows/answer_row.php
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
diff --git a/application/views/survey/questions/answer/multiplechoice/rows/answer_row.twig b/application/views/survey/questions/answer/multiplechoice/rows/answer_row.twig
new file mode 100644
index 00000000000..66b3a0c6217
--- /dev/null
+++ b/application/views/survey/questions/answer/multiplechoice/rows/answer_row.twig
@@ -0,0 +1,41 @@
+{#
+
+!!!! BECAREFUL: ONLY FOR TESTING !!!!!
+!!!! DON'T START TO TRANSLATE ALL VIEWS BASED ON THIS MODEL !!!!!
+
+!!!! IT WILL PROBABLY FIRST NEED TO CHANGE THE TWIG TEMPLATE SYNTAX TO AVOID CONFLICT WITH EXPRESSION MANAGER !!!!
+
+/**
+ * Multiple Choice Html : item row
+ *
+ * @var hiddenfield
+ * @var name
+ * @var title
+ * @var question
+ * @var checkedState
+ * @var sCheckconditionFunction
+ * @var myfname
+ * @var sValue
+ */
+#}
+
+
+
diff --git a/application/views/survey/questions/answer/multiplenumeric/rows/input/answer_row.php b/application/views/survey/questions/answer/multiplenumeric/rows/input/answer_row.php
index f54ae821a4f..35c58ccf59d 100644
--- a/application/views/survey/questions/answer/multiplenumeric/rows/input/answer_row.php
+++ b/application/views/survey/questions/answer/multiplenumeric/rows/input/answer_row.php
@@ -22,7 +22,7 @@
>
-
+ " for="answer">
diff --git a/application/views/survey/questions/answer/multiplenumeric/rows/sliders/answer_row.php b/application/views/survey/questions/answer/multiplenumeric/rows/sliders/answer_row.php
index 19f1faf6811..ad954d27277 100644
--- a/application/views/survey/questions/answer/multiplenumeric/rows/sliders/answer_row.php
+++ b/application/views/survey/questions/answer/multiplenumeric/rows/sliders/answer_row.php
@@ -28,8 +28,8 @@
*/
?>
->
-
+
+
diff --git a/application/views/surveys/publicSurveyList.php b/application/views/surveys/publicSurveyList.php
index b90672f3f22..94b4f3310a9 100644
--- a/application/views/surveys/publicSurveyList.php
+++ b/application/views/surveys/publicSurveyList.php
@@ -14,9 +14,9 @@
}
/* get the col class for with (src : http://encosia.com/using-btn-block-bootstrap-3-dropdown-button-groups) */
if ($survey->publicstatistics == "Y"){
- $colClass="col-sm-10 col-md-11";
+ $colClass="col-xs-10 col-md-11";
}else{
- $colClass="col-sm-12";
+ $colClass="col-xs-12";
}
$surveyLine = CHtml::link(
$survey->localizedTitle,
@@ -28,7 +28,6 @@
array(
'class' => "surveytitle btn btn-primary {$colClass}",
'title'=>gT('Start survey'),
- // broken : jquery-ui tooltip replace bs tooltip 'data-toggle'=>'tooltip',
'lang'=>$surveylang // Must add dir ?
)
);
@@ -36,9 +35,8 @@
$surveyLine .= CHtml::link(''. gT('View statistics') .' ',
array('statistics_user/action', 'surveyid' => $survey->sid,'language' => $surveylang),
array(
- 'class'=>'view-stats btn btn-success col-sm-2 col-md-1',
+ 'class'=>'view-stats btn btn-success col-xs-2 col-md-1',
'title'=>gT('View statistics'),
- // broken : jquery-ui tooltip replace bs tooltip 'data-toggle'=>'tooltip',
)
);
}
diff --git a/scripts/admin/admin_core.js b/scripts/admin/admin_core.js
index 900c0d78248..af720fab6e4 100644
--- a/scripts/admin/admin_core.js
+++ b/scripts/admin/admin_core.js
@@ -22,13 +22,15 @@ var LS = LS || {};
*/
hasFormValidation= typeof document.createElement( 'input' ).checkValidity == 'function';
+/* See function */
+fixAccordionPosition();
+
$(document).ready(function(){
initializeAjaxProgress();
tableCellAdapters();
linksInDialog();
doToolTip();
-
$('button,input[type=submit],input[type=button],input[type=reset],.button').button();
$('button,input[type=submit],input[type=button],input[type=reset],.button').addClass("limebutton");
@@ -115,23 +117,6 @@ $(document).ready(function(){
});
- $('#hideadvancedattributes').click(function(){
- $('#showadvancedattributes').show();
- $('#hideadvancedattributes').hide();
- $('#advancedquestionsettingswrapper').animate({
- "height": "toggle", "opacity": "toggle"
- });
-
- });
- $('#question_type').change(updatequestionattributes);
-
- $('#question_type_button li a').click(function(){
- $(".btn:first-child .buttontext").text($(this).text());
- $('#question_type').val($(this).data('value'));
-
- updatequestionattributes();
- });
-
$('#MinimizeGroupWindow').click(function(){
$('#groupdetails').hide();
});
@@ -329,41 +314,6 @@ function getToolTip(type){
//We have form validation and other stuff..
-function updatequestionattributes()
-{
- var type = $('#question_type').val();
- OtherSelection(type);
-
- $('.loader').show();
- $('#advancedquestionsettings').html('');
- var selected_value = qDescToCode[''+$("#question_type_child .selected").text()];
- if (selected_value==undefined) selected_value = $("#question_type").val();
- $('#advancedquestionsettings').load(attr_url,{qid:$('#qid').val(),
- question_type:selected_value,
- sid:$('#sid').val()
- }, function(){
- // Loads the tooltips for the toolbars
-
- // Loads the tooltips for the toolbars
- $('.loader').hide();
- $('label[title]').qtip({
- style: {name: 'cream',
- tip: true,
- color:'#111111',
- border: {
- width: 1,
- radius: 5,
- color: '#EADF95'}
- },
- position: {adjust: {
- screen: true, scroll:true},
- corner: {
- target: 'bottomRight'}
- },
- show: {effect: {length:50}}
- });}
- );
-}
function validatefilename (form, strmessage )
{
@@ -850,20 +800,20 @@ function onlyUnique(value, index, self) {
/**
* A method to use the implemented notifier, via ajax or javascript
- *
+ *
* @param text string | The text to be displayed
* @param classes string | The classes that will be put onto the inner container
* @param styles object | An object of css-attributes that will be put onto the inner container
- * @param customOptions | possible options are:
+ * @param customOptions | possible options are:
* useHtml (boolean) -> use the @text as html
- * timeout (int) -> the timeout in milliseconds until the notifier will fade/slide out
+ * timeout (int) -> the timeout in milliseconds until the notifier will fade/slide out
* inAnimation (string) -> The jQuery animation to call for the notifier [fadeIn||slideDown]
* outAnimation (string) -> The jQuery animation to remove the notifier [fadeOut||slideUp]
- * animationTime (int) -> The time in milliseconds the animation will last
+ * animationTime (int) -> The time in milliseconds the animation will last
*/
function NotifyFader(){
var count = 0;
-
+
var increment = function(){count = count+1;},
decrement = function(){count = count-1;},
getCount = function(){return count;};
@@ -877,8 +827,8 @@ function NotifyFader(){
var options = {
useHtml : customOptions.useHtml || true,
timeout : customOptions.timeout || 3500,
- inAnimation : customOptions.inAnimation || "slideDown",
- outAnimation : customOptions.outAnimation || "slideUp",
+ inAnimation : customOptions.inAnimation || "slideDown",
+ outAnimation : customOptions.outAnimation || "slideUp",
animationTime : customOptions.animationTime || 450
};
var container = $("
");
@@ -898,7 +848,7 @@ function NotifyFader(){
position: 'fixed',
left : "15%",
width : "70%",
- 'z-index':3500
+ 'z-index':3500
})
.appendTo($('#notif-container').parent())
.html(container);
@@ -1011,3 +961,18 @@ LS.ajax = function(options) {
return $.ajax(options);
}
+/* When using accordion : sometimes the start of accordion is uot of range (in question and survey settings)
+ * Then move to id just after opened it
+ * Attach to document due to ajax call in question
+ */
+function fixAccordionPosition(){
+ $(document).on('shown.bs.collapse',"#accordion", function () {
+ var collapsed = $(this).find('.collapse.in').prev('.panel-heading');
+ /* test if is up to surveybarid bottom, if yes : scrollTo */
+ if($(collapsed).offset().top-$(window).scrollTop() < $(".navbar-fixed-top").first().outerHeight(true)){
+ $('html, body').animate({
+ scrollTop: $(collapsed).offset().top-$(".navbar-fixed-top").first().outerHeight(true)
+ }, 500);
+ }
+ });
+}
diff --git a/scripts/admin/participantpanel.js b/scripts/admin/participantpanel.js
index bdb18d1b3fb..cb50f4f972c 100644
--- a/scripts/admin/participantpanel.js
+++ b/scripts/admin/participantpanel.js
@@ -2,7 +2,6 @@
LS = LS || {};
LS.CPDB = (function() {
var
-
// Basic modal used by all submethods
baseModal = '#participantPanel_edit_modal',
@@ -273,8 +272,10 @@ LS.CPDB = (function() {
$('#action_toggleAllParticipantShare').on('click', function() {
$('.selector_participantShareCheckbox').prop('checked', $('#action_toggleAllParticipantShare').prop('checked'));
});
-
- $('.action_changeBlacklistStatus').bootstrapSwitch();
+
+ if(($('#pageSizeParticipantView').val() <= 100) || ($('#pageSizeAttributes').val() <= 100) || ($('#pageSizeShareParticipantView').val() <= 100) ){
+ $('.action_changeBlacklistStatus').bootstrapSwitch();
+ }
$('.action_changeBlacklistStatus').on('switchChange.bootstrapSwitch', function(event,state){
var self = this;
@@ -429,10 +430,12 @@ LS.CPDB = (function() {
*/
bindButtons = function() {
basics();
- participantPanel();
- attributePanel();
- sharePanel();
-
+ switch($('#locator').data('location')){
+ case 'participants' : participantPanel(); break;
+ case 'attributes' : attributePanel(); break;
+ case 'sharepanel' : sharePanel(); break;
+ }
+
/**
* @TODO rewrite export
*/
diff --git a/scripts/admin/questions.js b/scripts/admin/questions.js
index 2feb8e766f9..29705620e6b 100644
--- a/scripts/admin/questions.js
+++ b/scripts/admin/questions.js
@@ -1,8 +1,8 @@
/*
* LimeSurvey (tm)
-* Copyright (C) 2012 The LimeSurvey Project Team / Carsten Schmitz
+* Copyright (C) 2012-2016 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
-* License: GNU/GPL License v2 or later, see LICENSE.php
+* License: GNU/GPL License v3 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
@@ -20,6 +20,18 @@ $(document).ready(function(){
$('#collapseOne').on('hide.bs.collapse', function () {
$('#questionTypeContainer').css("overflow","hidden");
});
+
+ if($('.loader-advancedquestionsettings').length){
+ updatequestionattributes();
+ }
+ $('#question_type').change(updatequestionattributes);
+
+ $('#question_type_button li a').click(function(){
+ $(".btn:first-child .buttontext").text($(this).text());
+ $('#question_type').val($(this).data('value'));
+
+ updatequestionattributes();
+ });
});
/**
* Validate question object on blur on title element
@@ -100,3 +112,37 @@ function validateQuestion(jqObject){
dataType="json"
);
}
+function updatequestionattributes()
+{
+ var type = $('#question_type').val();
+ OtherSelection(type);
+
+ $('.loader-advancedquestionsettings').removeClass("hidden");
+ $('.panel-advancedquestionsettings').remove();
+ var selected_value = qDescToCode[''+$("#question_type_child .selected").text()];
+ if (selected_value==undefined) selected_value = $("#question_type").val();
+ $.post(attr_url,{
+ 'qid':$('#qid').val(),
+ 'question_type':selected_value,
+ 'sid':$('#sid').val()
+ }, function(data) {
+ $('.loader-advancedquestionsettings').before(data);
+ $('.loader-advancedquestionsettings').addClass("hidden");
+ $('label[title]').qtip({
+ style: {name: 'cream',
+ tip: true,
+ color:'#111111',
+ border: {
+ width: 1,
+ radius: 5,
+ color: '#EADF95'}
+ },
+ position: {adjust: {
+ screen: true, scroll:true},
+ corner: {
+ target: 'bottomRight'}
+ },
+ show: {effect: {length:50}}
+ });
+ });
+}
diff --git a/scripts/map.js b/scripts/map.js
index e7304588f63..a2f7fe98be1 100644
--- a/scripts/map.js
+++ b/scripts/map.js
@@ -6,26 +6,25 @@
$(document).ready(function()
{
- $(".ls-answers .location").each(function(index,element){
- var question = $(element).attr('name');
- var coordinates = $(element).val();
- var latLng = coordinates.split(" ");
- var question_id = question.substr(0,question.length-2);
- var question_id = question.substr(0,question.length-2);
- if ($("#mapservice_"+question_id).val()==1){
- // Google Maps
- if (gmaps[''+question] == undefined) {
- GMapsInitialize(question,latLng[0],latLng[1]);
- }
- }
- else if ($("#mapservice_"+question_id).val()==100){
- // Maps
- // Maps
- if (osmaps[''+question] == undefined) {
- osmaps[''+question] = OSGeoInitialize(question,latLng);
- }
- }
- });
+ $(".ls-answers .location").each(function(index,element){
+ var question = $(element).attr('name');
+ var coordinates = $(element).val();
+ var latLng = coordinates.split(" ");
+ var question_id = question.substr(0,question.length-2);
+ var question_id = question.substr(0,question.length-2);
+ if ($("#mapservice_"+question_id).val()==1){
+ // Google Maps
+ if (gmaps[''+question] == undefined) {
+ GMapsInitialize(question,latLng[0],latLng[1]);
+ }
+ }
+ else if ($("#mapservice_"+question_id).val()==100){
+ // Maps
+ if (osmaps[''+question] == undefined) {
+ osmaps[''+question] = OSGeoInitialize(question,latLng);
+ }
+ }
+ });
});
@@ -34,235 +33,200 @@ osmaps = new Object;
zoom = [];
-function isvalidCoord(val){
- if (!isNaN(parseFloat(val)) && (val>-180 && val<180)) {
- return true;
- } else {
- return false;
- }
+function isvalidCoord(val,type){
+ if(type=='lat'){
+ var min=-90;
+ var max=90
+ }else{
+ var min=-180;
+ var max=180
+ }
+ if (!isNaN(parseFloat(val)) && (val>min && val<=max)) {
+ return true;
+ } else {
+ return false;
+ }
}
// OSMap functions
function OSGeoInitialize(question,latLng){
- var tileServerURL = {
- OSM : "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}",
- HUM : "http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}",
- CYC : "http://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}",
- TRA : "http://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}"
- };
- var name = question.substr(0,question.length - 2);
- // tiles layers def
- // If not latLng is set the Map will center to Hamburg
- var MapOption=LSmaps[name];
- if(isNaN(MapOption.latitude) || MapOption.latitude==""){
- MapOption.latitude=53.582665;
- }
- if(isNaN(MapOption.longitude) || MapOption.longitude==""){
- MapOption.longitude=10.018924;
- }
- var mapOSM = L.tileLayer(tileServerURL.OSM+".png", {
- maxZoom: 19,
- subdomains: ["a", "b", "c"],
- attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA.'
- });
- var mapCYC = L.tileLayer(tileServerURL.CYC+".png", {
- maxZoom: 19,
- subdomains: ["a", "b", "c"],
- attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA.'
- });
- var mapHOT = L.layerGroup([L.tileLayer(tileServerURL.HUM+".png", {
- maxZoom: 20,
- subdomains: ["a", "b", "c"],
- }), L.tileLayer(tileServerURL+".png", {
- maxZoom: 19,
- subdomains: ["a", "b", "c"],
- attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA.'
- })]);
- var mapTRA = L.layerGroup([L.tileLayer(tileServerURL.TRA+".png", {
- maxZoom: 19,
- subdomains: ["a", "b", "c"],
- }), L.tileLayer(tileServerURL+".png", {
- maxZoom: 19,
- subdomains: ["a", "b", "c"],
- attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA.'
- })]);
-
- var baseLayers = {
- "Street Map": mapOSM,
- "Humanitarian": mapHOT,
- "Cyclemap": mapCYC,
- "Traffic Map" : mapTRA
- };
- var overlays = {
- };
- var map = L.map("map_"+name, {
- zoom:MapOption.zoomLevel,
- minZoom:1,
- center: [MapOption.latitude, MapOption.longitude] ,
- maxBounds: ([[-90, -180],[90, 180]]),
- layers: [mapOSM]
- });
- //function zoomExtent(){ // todo: restrict to rect ?
- // map.setView([15, 15],1);
- //}
-
- var pt1 = latLng[0].split("@");
- var pt2 = latLng[1].split("@");
-
- if ((pt1.length == 2) && (pt2.length == 2)) { // is Rect
- var isRect = true;
- lat = "";
- lng = "";
- minLat = pt1[0];
- minLng = pt1[1];
- maxLat = pt2[0];
- maxLng = pt2[1];
- map.fitBounds([[minLat, minLng],[maxLat, maxLng]]);
- map.setMaxBounds([[minLat, minLng],[maxLat, maxLng]]);
- UI_update("","");
- } else { // is default marker position
- var isRect = false;
- lat = latLng[0];
- lng = latLng[1];
- }
-
- if (isNaN(parseFloat(lat)) || isNaN(parseFloat(lng))) {
- lat=-9999; lng=-9999;
- }
-
- var marker = new L.marker([lat,lng], {title:'Current Location',id:1,draggable:'true'});
- map.addLayer(marker);
-
- var layerControl = L.control.layers(baseLayers, overlays, {
- collapsed: true
- }).addTo(map);
-
- map.on('click',
- function(e) {
- var coords = L.latLng(e.latlng.lat,e.latlng.lng);
- marker.setLatLng(coords);
- UI_update(e.latlng.lat,e.latlng.lng)
- }
- )
-
- // Zoom to 11 when switching to Aerial or Hybrid views - bug 10589
- var layer2Name, layer3Name, layerIndex = 0;
- for (var key in baseLayers) {
- if (!baseLayers.hasOwnProperty(key)) {
- continue;
- }
- if(layerIndex == 1) {
- layer2Name = key;
+ var tileServerURL = {
+ OSM : "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}",
+ HUM : "http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}",
+ CYC : "http://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}",
+ TRA : "http://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}"
+ };
+ var name = question.substr(0,question.length - 2);
+ // tiles layers def
+ // If not latLng is set the Map will center to Hamburg
+ var MapOption=LSmaps[name];
+ if(isNaN(MapOption.latitude) || MapOption.latitude==""){
+ MapOption.latitude=53.582665;
+ }
+ if(isNaN(MapOption.longitude) || MapOption.longitude==""){
+ MapOption.longitude=10.018924;
+ }
+ var mapOSM = L.tileLayer(tileServerURL.OSM+".png", {
+ maxZoom: 19,
+ subdomains: ["a", "b", "c"],
+ attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA.'
+ });
+ var mapCYC = L.tileLayer(tileServerURL.CYC+".png", {
+ maxZoom: 19,
+ subdomains: ["a", "b", "c"],
+ attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA.'
+ });
+ var mapHOT = L.layerGroup([L.tileLayer(tileServerURL.HUM+".png", {
+ maxZoom: 20,
+ subdomains: ["a", "b", "c"],
+ }), L.tileLayer(tileServerURL+".png", {
+ maxZoom: 19,
+ subdomains: ["a", "b", "c"],
+ attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA.'
+ })]);
+ var mapTRA = L.layerGroup([L.tileLayer(tileServerURL.TRA+".png", {
+ maxZoom: 19,
+ subdomains: ["a", "b", "c"],
+ }), L.tileLayer(tileServerURL+".png", {
+ maxZoom: 19,
+ subdomains: ["a", "b", "c"],
+ attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA.'
+ })]);
+
+ var baseLayers = {
+ "Street Map": mapOSM,
+ "Humanitarian": mapHOT,
+ "Cyclemap": mapCYC,
+ "Traffic Map" : mapTRA
+ };
+ var overlays = {
+ };
+ var map = L.map("map_"+name, {
+ zoom:MapOption.zoomLevel,
+ minZoom:1,
+ center: [MapOption.latitude, MapOption.longitude] ,
+ maxBounds: ([[-90, -180],[90, 180]]),
+ layers: [mapOSM]
+ });
+
+ //function zoomExtent(){ // todo: restrict to rect ?
+ // map.setView([15, 15],1);
+ //}
+
+ var pt1 = latLng[0].split("@");
+ var pt2 = latLng[1].split("@");
+
+ if ((pt1.length == 2) && (pt2.length == 2)) { // is Rect
+ var isRect = true;
+ lat = "";
+ lng = "";
+ minLat = pt1[0];
+ minLng = pt1[1];
+ maxLat = pt2[0];
+ maxLng = pt2[1];
+ map.fitBounds([[minLat, minLng],[maxLat, maxLng]]);
+ map.setMaxBounds([[minLat, minLng],[maxLat, maxLng]]);
+ UI_update("","");
+ } else { // is default marker position
+ var isRect = false;
+ lat = latLng[0];
+ lng = latLng[1];
+ }
+
+ if (isNaN(parseFloat(lat)) || isNaN(parseFloat(lng))) {
+ lat=-9999; lng=-9999;
+ }
+
+ var marker = new L.marker([lat,lng], {title:'Current Location',id:1,draggable:'true'});
+ map.addLayer(marker);
+
+ var layerControl = L.control.layers(baseLayers, overlays, {
+ collapsed: true
+ }).addTo(map);
+
+ map.on('click',
+ function(e) {
+ var coords = L.latLng(e.latlng.lat,e.latlng.lng);
+ if(isvalidCoord(coords.lat,'lat') && isvalidCoord(coords.lng,'lng')){
+ marker.setLatLng(coords);
+ UI_update(e.latlng.lat,e.latlng.lng);
+ }
}
- else if(layerIndex == 2) {
- layer3Name = key;
+ )
+
+ // Zoom to 11 when switching to Aerial or Hybrid views - bug 10589 / @deprectaed : layer was updated
+ //~ var layer2Name, layer3Name, layerIndex = 0;
+ //~ for (var key in baseLayers) {
+ //~ if (!baseLayers.hasOwnProperty(key)) {
+ //~ continue;
+ //~ }
+ //~ if(layerIndex == 1) {
+ //~ layer2Name = key;
+ //~ }
+ //~ else if(layerIndex == 2) {
+ //~ layer3Name = key;
+ //~ }
+ //~ layerIndex++;
+ //~ }
+ //~ map.on('baselayerchange', function(e) {
+ //~ if(e.name == layer2Name || e.name == layer3Name) {
+ //~ map.setZoom(MapOption.zoomLevel);
+ //~ }
+ //~ });
+
+ marker.on('dragend', function(e){
+ var marker = e.target;
+ var position = marker.getLatLng();
+ UI_update(position.lat,position.lng)
+ });
+
+ function UI_update(lat,lng){
+ if (isvalidCoord(lat,'lat') && isvalidCoord(lng,'lng')) {
+ $("#answer"+name).val(Math.round(lat*100000)/100000 + ";" + Math.round(lng*100000)/100000);
+ $("#answer_lat"+question).val(Math.round(lat*100000)/100000).removeClass("text-danger").data('prevvalue',Math.round(lat*100000)/100000);
+ $("#answer_lng"+question).val(Math.round(lng*100000)/100000).removeClass("text-danger").data('prevvalue',Math.round(lat*100000)/100000);
+ } else {
+ $("#answer"+name).val("");
+ $("#answer_lat"+question).val("").data('prevvalue','');
+ $("#answer_lng"+question).val("").data('prevvalue','');
}
- layerIndex++;
+ checkconditions($("#answer"+name).val(), name, 'text', 'keyup');
}
- map.on('baselayerchange', function(e) {
- if(e.name == layer2Name || e.name == layer3Name) {
- map.setZoom(11);
+
+
+ $('.coords[name^='+name+']').each(function(){
+ $(this).data('prevvalue',$(this).val());
+ });
+ $('.coords[name^='+name+']').on('blur',function(){
+ if ($(this).data('prevvalue') != $(this).val()) {
+ var newLat = $("#answer_lat"+question).val();
+ if(newLat!=="" && !isvalidCoord(newLat,'lat')){
+ $("#answer_lat"+question).addClass("text-danger");
+ }else{
+ $("#answer_lat"+question).removeClass("text-danger");
+ }
+ var newLng = $("#answer_lng"+question).val();
+ if(newLng!="" && !isvalidCoord(newLng)){
+ $("#answer_lng"+question).addClass("text-danger");
+ }else{
+ $("#answer_lng"+question).removeClass("text-danger");
+ }
+ if (isvalidCoord(newLat,'lat') && isvalidCoord(newLng,'lng')) {
+ $("#answer"+name).val(newLat + ";" + newLng);
+ map.setView([newLat, newLng]);
+ marker.setLatLng(L.latLng(newLat,newLng));
+ checkconditions($("#answer"+name).val(), name, 'text', 'keyup');
+ }
}
+ $(this).data('prevvalue',$(this).val());
});
- marker.on('dragend', function(e){
- var marker = e.target;
- var position = marker.getLatLng();
- UI_update(position.lat,position.lng)
- });
-
- function UI_update(lat,lng){
- if (isvalidCoord(lat) && isvalidCoord(lng)) {
- //$("#answer"+question).val(Math.round(lat*100000)/100000 + " " + Math.round(lng*100000)/100000);
- $("#answer"+name).val(Math.round(lat*100000)/100000 + ";" + Math.round(lng*100000)/100000).trigger("keyup");
- $("#answer_lat"+question).val(Math.round(lat*100000)/100000);
- $("#answer_lng"+question).val(Math.round(lng*100000)/100000);
- } else {
- //$("#answer"+question).val("");
- $("#answer"+name).val("").trigger("keyup");
- $("#answer_lat"+question).val("");
- $("#answer_lng"+question).val("");
- }
- }
-
- $('coords[name^='+name+']').each(function() {
- // Save current value of element
- $(this).data('oldVal', $(this));
- // Look for changes
- $(this).bind("propertychange keyup input cut paste", function(event){
- // If value has changed...
- if ($(this).data('oldVal') != $(this).val()) {
- // Updated stored value
- $(this).data('oldVal', $(this).val());
- var newLat = $("#answer_lat"+question).val();
- var newLng = $("#answer_lng"+question).val();
- if (isNumber(newLat) && isNumber(newLng)) {
- $("#answer"+name).val(newLat + ";" + newLng);
- marker.setLatLng(L.latLng(newLat,newLng));
- } else {
- $("#answer"+name).val("-- --");
- marker.setLatLng(L.latLng(9999,9999));
- }
- }
- });
- });
-
- function isNumber(n){
- return !isNaN(parseFloat(n)) && isFinite(n);
- }
- //~ $("#searchbox_"+name).autocomplete({
- //~ appendTo: $("#searchbox_"+name).parent(),
- //~ source: function( request, response ) {
- //~ $.ajax({
- //~ url: "http://api.geonames.org/searchJSON",
- //~ dataType: "jsonp",
- //~ data: {
- //~ username : LSmap.geonameUser,
- //~ featureClass : 'P',
- //~ maxRows : 5,
- //~ lang : LSmap.geonameLang,
- //~ name_startsWith: request.term
- //~ },
- //~ beforeSend : function(jqXHR, settings) {
- //~ if($("#restrictToExtent_"+name).prop('checked'))
- //~ {
- //~ settings.url += "&east=" + map.getBounds().getEast() + "&west=" + map.getBounds().getWest() + "&north=" + map.getBounds().getNorth() + "&south=" + map.getBounds().getSouth();
- //~ }
- //~ },
- //~ success: function( data ) {
- //~ response($.map(data.geonames, function(item) {
- //~ return {
- //~ label: item.name + ", " + item.countryName,
- //~ lat: item.lat,
- //~ lng: item.lng,
- //~ source: "GeoNames"
- //~ };
- //~ }));
- //~ }
- //~ });
- //~ },
- //~ minLength: 3,
- //~ select: function( event, ui ) {
- //~ if(ui.item.source=="GeoNames")
- //~ {
- //~ map.setView([ui.item.lat, ui.item.lng], 13);
- //~ marker.setLatLng([ui.item.lat, ui.item.lng]);
- //~ UI_update(ui.item.lat, ui.item.lng);
- //~ }
- //~ },
- //~ open: function() {
- //~ $( this ).addClass( "searching" );
- //~ },
- //~ close: function() {
- //~ $( this ).removeClass( "searching" );
- //~ }
- //~ });
-
$("#searchbox_"+name).autocomplete({
serviceUrl : "http://api.geonames.org/searchJSON",
dataType: "jsonp",
paramName: 'name_startsWith',
+ deferRequestBy: 500,
params:{
username : LSmap.geonameUser,
featureClass : 'P',
@@ -295,7 +259,7 @@ function OSGeoInitialize(question,latLng){
},
onSelect : function(suggestion) {
if(suggestion.data.src=='geoname'){
- map.setView([suggestion.data.lat, suggestion.data.lng], 13);
+ map.setView([suggestion.data.lat, suggestion.data.lng], MapOption.zoomLevel);
marker.setLatLng([suggestion.data.lat, suggestion.data.lng]);
UI_update(suggestion.data.lat, suggestion.data.lng);
}
@@ -356,94 +320,94 @@ function OSGeoInitialize(question,latLng){
function GMapsInitialize(question,lat,lng) {
- var name = question.substr(0,question.length - 2);
- var latlng = new google.maps.LatLng(lat, lng);
-
- var mapOptions = {
- zoom: zoom[name],
- center: latlng,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- };
-
- var map = new google.maps.Map(document.getElementById("gmap_canvas_" + question), mapOptions);
- gmaps[''+question] = map;
-
- var marker = new google.maps.Marker({
- position: latlng,
- draggable:true,
- map: map,
- id: 'marker__'+question
- });
- gmaps['marker__'+question] = marker;
-
- google.maps.event.addListener(map, 'rightclick', function(event) {
- marker.setPosition(event.latLng);
- map.panTo(event.latLng);
- geocodeAddress(name, event.latLng);
- $("#answer"+question).val(Math.round(event.latLng.lat()*10000)/10000 + " " + Math.round(event.latLng.lng()*10000)/10000);
- });
-
- google.maps.event.addListener(marker, 'dragend', function(event) {
- //map.panTo(event.latLng);
- geocodeAddress(name, event.latLng);
- $("#answer"+question).val(Math.round(event.latLng.lat()*10000)/10000 + " " + Math.round(event.latLng.lng()*10000)/10000);
- });
+ var name = question.substr(0,question.length - 2);
+ var latlng = new google.maps.LatLng(lat, lng);
+
+ var mapOptions = {
+ zoom: zoom[name],
+ center: latlng,
+ mapTypeId: google.maps.MapTypeId.ROADMAP
+ };
+
+ var map = new google.maps.Map(document.getElementById("gmap_canvas_" + question), mapOptions);
+ gmaps[''+question] = map;
+
+ var marker = new google.maps.Marker({
+ position: latlng,
+ draggable:true,
+ map: map,
+ id: 'marker__'+question
+ });
+ gmaps['marker__'+question] = marker;
+
+ google.maps.event.addListener(map, 'rightclick', function(event) {
+ marker.setPosition(event.latLng);
+ map.panTo(event.latLng);
+ geocodeAddress(name, event.latLng);
+ $("#answer"+question).val(Math.round(event.latLng.lat()*10000)/10000 + " " + Math.round(event.latLng.lng()*10000)/10000);
+ });
+
+ google.maps.event.addListener(marker, 'dragend', function(event) {
+ //map.panTo(event.latLng);
+ geocodeAddress(name, event.latLng);
+ $("#answer"+question).val(Math.round(event.latLng.lat()*10000)/10000 + " " + Math.round(event.latLng.lng()*10000)/10000);
+ });
}
// Reset map when shown by conditions
function resetMap(qID) {
- var question = $('#question'+qID+' input.location').attr('name');
- var name = question.substr(0,question.length - 2);
- var coordinates = $('#question'+qID+' input.location').attr('value');
- var xy = coordinates.split(" ");
- if(gmaps[question]) {
- var currentMap = gmaps[question];
- var marker = gmaps['marker__'+question];
- var markerLatLng = new google.maps.LatLng(xy[0],xy[1]);
- marker.setPosition(markerLatLng);
- google.maps.event.trigger(currentMap, 'resize')
- currentMap.setCenter(markerLatLng);
- }
+ var question = $('#question'+qID+' input.location').attr('name');
+ var name = question.substr(0,question.length - 2);
+ var coordinates = $('#question'+qID+' input.location').attr('value');
+ var xy = coordinates.split(" ");
+ if(gmaps[question]) {
+ var currentMap = gmaps[question];
+ var marker = gmaps['marker__'+question];
+ var markerLatLng = new google.maps.LatLng(xy[0],xy[1]);
+ marker.setPosition(markerLatLng);
+ google.maps.event.trigger(currentMap, 'resize')
+ currentMap.setCenter(markerLatLng);
+ }
}
// Reverse geocoder
function geocodeAddress(name, pos) {
- var geocoder = new google.maps.Geocoder();
-
- var city = '';
- var state = '';
- var country = '';
- var postal = '';
-
- geocoder.geocode({
- latLng: pos
- }, function(results, status) {
- if (status == google.maps.GeocoderStatus.OK && results[0]) {
- $(results[0].address_components).each(function(i, val) {
- if($.inArray('locality', val.types) > -1) {
- city = val.short_name;
- }
- else if($.inArray('administrative_area_level_1', val.types) > -1) {
- state = val.short_name;
- }
- else if($.inArray('country', val.types) > -1) {
- country = val.short_name;
- }
- else if($.inArray('postal_code', val.types) > -1) {
- postal = val.short_name;
- }
- });
-
- var location = (results[0].geometry.location);
- }
- getInfoToStore(name, pos.lat(), pos.lng(), city, state, country, postal);
- });
+ var geocoder = new google.maps.Geocoder();
+
+ var city = '';
+ var state = '';
+ var country = '';
+ var postal = '';
+
+ geocoder.geocode({
+ latLng: pos
+ }, function(results, status) {
+ if (status == google.maps.GeocoderStatus.OK && results[0]) {
+ $(results[0].address_components).each(function(i, val) {
+ if($.inArray('locality', val.types) > -1) {
+ city = val.short_name;
+ }
+ else if($.inArray('administrative_area_level_1', val.types) > -1) {
+ state = val.short_name;
+ }
+ else if($.inArray('country', val.types) > -1) {
+ country = val.short_name;
+ }
+ else if($.inArray('postal_code', val.types) > -1) {
+ postal = val.short_name;
+ }
+ });
+
+ var location = (results[0].geometry.location);
+ }
+ getInfoToStore(name, pos.lat(), pos.lng(), city, state, country, postal);
+ });
}
// Store address info
function getInfoToStore(name, lat, lng, city, state, country, postal){
- var boycott = $("#boycott_"+name).val();
+ var boycott = $("#boycott_"+name).val();
// 2 - city; 3 - state; 4 - country; 5 - postal
if (boycott.indexOf("2")!=-1)
city = '';
diff --git a/templates/default/views/startpage.pstpl b/templates/default/views/startpage.pstpl
index 5877db3d1b8..1aab18c4426 100644
--- a/templates/default/views/startpage.pstpl
+++ b/templates/default/views/startpage.pstpl
@@ -1,7 +1,31 @@
-
+
-{SURVEYNAME}
+
+{#
+ !!!!NOTE!!!!
+ THIS IS A FIRST TEST TO USE TWIG IN PSTPL FILES
+
+ NOW, ANY VARIABLE DISPONIBLE IN $REDATA WILL BE USABLE FROM TEMPLATE FILES
+
+ // This survey:
+ Eg: {{ thissurvey.adminemail }}
+ Eg: {{ thissurvey.template }} ;
+ Eg: {{ thissurvey.admin }} ;
+ Eg: {{ thissurvey.datecreated }} ;
+ Eg: {{ thissurvey.navigationdelay }} ;
+ Eg: {{ thissurvey. surveyls_language}} ;
+ etc. etc.
+
+ IN THE QUESTION PSTPL, QUESTION OBJECT VARIABLES WILL BE AVAILABLE, SAME FOR GROUP, ETC
+
+ HERE WE USE THE ARRAY $thissurvey
+ SO NOW, IT'S NOT NEEDED TO ADD ANYMORE ANY REPLACEMENT KEYWORD
+ MOST OF THE HTML GENERATED IN THE DIFFERENT HELPERS (LIKE SAVE_LINKS)
+ COULD BE PLACED DIRECTLY INSIDE THE PSTPL FILES
+#}
+
+{{thissurvey.surveyls_title}}
@@ -9,10 +33,10 @@
{TEMPLATEJS}
-
+
{GOOGLE_ANALYTICS_JAVASCRIPT}
-
+