"use strict";
$(function () {
$('.fieldlist').each(function() {
var $this=$(this);
var lis=$this.children('li');
lis.first().children(':first').after(' ');
lis.first().children('button').click(function() {
clone_fieldlist($this.children('li:last'));
});
lis=lis.slice(1);
lis.each(function() {
append_remove_button($(this));
});
});
$('.selectpicker').selectpicker();
$("[data-toggle='tooltip']").tooltip();
var Geoinput = function(el, options, e) {
this.$element = $(el);
this.init();
};
Geoinput.prototype = {
constructor: Geoinput,
init: function() {
this.$element.hide();
this.$button = this.makeButton();
this.$modal = this.makeModal();
this.$element.after(this.$button);
this.$element.after(this.$modal);
this.$modal.find('textarea').val(this.$element.val());
this.buttonIcon();
var that = this;
this.$button.click(function(e) {
e.preventDefault();
that.$modal.modal();
return false;
});
this.$modal.find('.btn-primary').click(function(e) {
e.preventDefault();
that.$modal.modal('hide');
that.$element.val(that.$modal.find('textarea').val());
that.buttonIcon.call(that);
return false;
});
},
buttonIcon: function() {
if(this.$element.val())
this.$button[0].firstChild.src = '/static/img/map_edit.png';
else
this.$button[0].firstChild.src = '/static/img/map.png';
},
makeButton: function() {
return $('').addClass("btn btn-default geoinput-button")
.css('padding', '4px 7px')
.attr('title', 'enter geojson')
.html('');
},
makeModal: function() {
return $('