-
Notifications
You must be signed in to change notification settings - Fork 2
/
gtm_settings_page.php
157 lines (123 loc) · 6.82 KB
/
gtm_settings_page.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
// @digfish: the form to configure Geotagged media plugin
?>
<style type="text/css">
#geocode_on_upload_details {
display: none;
}
</style>
<div id="mst_cntx" style="display: none">
</div>
<div class="wrap">
<h1>Geotagged Media Plugin options</h1>
<p>
Fill the fields with the configuration for Geotagged Media Plugin
</p>
<form name="gtm_settings_form" method="post" action="options-general.php?page=gtm-admin-options">
<p><input type="checkbox" name="gtm_options[geocode_on_upload]" value="true"><label
for="gtm_options[geocode_on_upload]">Assign names automtically to photos on upload !?</label></p>
<div id="composer_init_section">
<p id="geocode_on_upload_details">In order to proceed with this option it's required to download the
Composer
package manager
<button class="button" id="btn_download_composer">Click here to download</button>
<P id='download_composer_response' style="display: none;"></P>
</p></div>
<p><input type="checkbox" name="gtm_options[add_metadata_column]" value="true"><label>Add metadata column to
media library?</label></p>
<p><input type="checkbox" name="gtm_options[media_metadata_gps_details]" value="true"><label>Show GPS details on
Media Attachment details !?</label></p>
<p><input type="checkbox" name="gtm_options[media_show_edit_exif_form]" value="true"><label>Show Edit EXIF
fields form !? </label></p>
<p><input type="checkbox" name="gtm_options[add_dashboard_geotagged_media_option]" value="true"><label>Add "
Geotagged Media" item to the the dashboard side menu ?</label></p>
<p><label><input type="checkbox" name="gtm_options[media_library_gtm_filters]" value="true">Add filters on media
library to allow to select geotagged and not geotagged media ?</label></p>
<p><label class="gtm input-label">BingMaps Key</label><input type="text" name="gtm_options[key_bingmaps]"
class="gtm-input"
value="<?php echo $gtm_options['key_bingmaps'] ?>">
</p>
<p><label class="gtm input-label"> ThunderForest Key</label><input class="gtm-input" type="text"
name="gtm_options[key_thunderforest]"
value="<?php echo $gtm_options['key_thunderforest'] ?>">
</p>
<p><label class="gtm input-label"> MapBox Key</label><input class="gtm-input" type="text" style="width:700px"
name="gtm_options[key_mapbox]"
value="<?php echo $gtm_options['key_mapbox'] ?>">
</p>
<?php echo submit_button() ?>
</form>
</div>
<script type="text/javascript">
function jquiModal(dialog_id,msg) {
jQuery('body').append("<DIV id='"+ dialog_id + "'><img src='/wp-includes/images/spinner-2x.gif'>" + msg + "</DIV");
$jquim = jQuery('#'+dialog_id).dialog();
console.log('jquim',$jquim);
return $jquim;
}
function jquiClose($jquim) {
jQuery('.ui-dialog button').trigger('click');
jQuery('.ui-dialog').remove();
}
jQuery(document).ready(function ($) {
$jquim = jquiModal('gtmModalWaitSettings',"<H4>Please wait while the option settings are loaded...</H4>");
var mustache_tmpl = "";
// load mustache js templates
$.get("<?php echo plugin_dir_url( __FILE__ ) ?>/gtm.mst", {}).success(function (response) {
console.log("Mustache templates file loaded!");
mustache_tmpl = jQuery.parseHTML(response, document, true);
$('head').append(mustache_tmpl);
});
$.get(
ajaxurl + "?action=gtm_get_options_values",
{}).success(
function (response) {
jquiClose($jquim);
// console.log("GTM options", response);
gtm_options = response;
$.each(gtm_options, function (option_name, option_value) {
// console.log(option_name, option_value);
if (option_value == 'true') {
$("[type=checkbox][name=gtm_options\\[" + option_name + "\\]]").attr('checked', 'yes');
}
});
});
$('#btn_download_composer').on('click', function (evt) {
evt.preventDefault();
jquim = jquiModal("gtmModalWaitDwnldComposer","<H4>Downloading composer, wait...</H4>");
$.get(
ajaxurl + "?action=gtm_download_composer", {}).success(function (response) {
jquiClose(jquim);
console.log(response);
$('#download_composer_response').html(mst_render('#mst_simple_paragraph', {'text': response}));
$('#download_composer_response').show();
//$('#composer_init_section').trigger('init_vendor');
$('#composer_init_section').triggerHandler('click');
$('#btn_download_composer').hide();
});
});
$('#composer_init_section').on('click', '#btn_composer_init_vendor', function (evt) {
// console.log('clicked',this)
evt.preventDefault();
jquim = jquiModal("gtmModalWiatDwnldDpendencis","<H4>Downloading dependencies, wait...</H4>");
$('#btn_composer_init_vendor').parent().append(mst_render('#mst_simple_paragraph', {'text': "Downloading dependencies . . . Please wait . . ."}));
$.get(ajaxurl + "?action=gtm_install_deps", {}).success(function (response) {
// console.log(response);
jquiClose(jquim);
$('#btn_composer_init_vendor').hide();
$('#btn_composer_init_vendor').parent().append(mst_render('#mst_textarea_console', {'text': response}));
$('#btn_composer_init_vendor').parent().append(mst_render('#mst_simple_paragraph', {'text': "Dependencies installed with success!"}));
});
});
$('[name=gtm_options\\[geocode_on_upload\\]]').on('click', function (evt) {
$this = $(this);
if ($this.attr('checked')) {
// console.log('Is checked!');
$('#geocode_on_upload_details').show();
} else {
// console.log('Is not checked!');
$('#geocode_on_upload_details').hide();
}
})
});
</script>