PluginProbe
CBX Map for Google Map & OpenStreetMap / 1.1.11
CBX Map for Google Map & OpenStreetMap v1.1.11
trunk 1.1.10 1.1.11 1.1.12 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5
cbxgooglemap / assets / js / cbxgooglemap-block.js

cbxgooglemap-block.js in CBX Map for Google Map & OpenStreetMap 1.1.11, at assets/js/cbxgooglemap-block.js

230 lines 7.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 'use strict';
2
3 (function (blocks, element, components, editor, $) {
4 var el = element.createElement,
5 registerBlockType = blocks.registerBlockType,
6 InspectorControls = editor.InspectorControls,
7 ServerSideRender = components.ServerSideRender,
8 RangeControl = components.RangeControl,
9 Panel = components.Panel,
10 PanelBody = components.PanelBody,
11 PanelRow = components.PanelRow,
12 TextControl = components.TextControl,
13 //NumberControl = components.NumberControl,
14 TextareaControl = components.TextareaControl,
15 CheckboxControl = components.CheckboxControl,
16 RadioControl = components.RadioControl,
17 SelectControl = components.SelectControl,
18 ToggleControl = components.ToggleControl,
19 //ColorPicker = components.ColorPalette,
20 //ColorPicker = components.ColorPicker,
21 //ColorPicker = components.ColorIndicator,
22 PanelColorPicker = editor.PanelColorSettings,
23 DateTimePicker = components.DateTimePicker,
24 HorizontalRule = components.HorizontalRule,
25 ExternalLink = components.ExternalLink;
26
27 var MediaUpload = wp.editor.MediaUpload;
28
29
30 var iconEl = el('svg', { width: 20, height: 20 },
31 el('path', { d: "M8,0C4.687,0,2,2.687,2,6c0,3.854,4.321,8.663,5,9.398C7.281,15.703,7.516,16,8,16s0.719-0.297,1-0.602 C9.679,14.663,14,9.854,14,6C14,2.687,11.313,0,8,0z M8,10c-2.209,0-4-1.791-4-4s1.791-4,4-4s4,1.791,4,4S10.209,10,8,10z M8,4 C6.896,4,6,4.896,6,6s0.896,2,2,2s2-0.896,2-2S9.104,4,8,4z" } )
32 );
33
34
35 registerBlockType('codeboxr/cbxgooglemap', {
36 title: cbxgooglemap_block.block_title,
37 icon: iconEl,
38 category: cbxgooglemap_block.block_category,
39
40 /*
41 * In most other blocks, you'd see an 'attributes' property being defined here.
42 * We've defined attributes in the PHP, that information is automatically sent
43 * to the block editor, so we don't need to redefine it here.
44 */
45 edit: function (props) {
46
47
48 return [
49 /*
50 * The ServerSideRender element uses the REST API to automatically call
51 * php_block_render() in your PHP code whenever it needs to get an updated
52 * view of the block.
53 */
54 el(ServerSideRender, {
55 block: 'codeboxr/cbxgooglemap',
56 attributes: props.attributes,
57 }),
58
59
60 el( InspectorControls, {},
61 // 1st Panel – Form Settings
62 el( PanelBody, { title: cbxgooglemap_block.general_settings.title, initialOpen: true },
63 el( SelectControl,
64 {
65 label: cbxgooglemap_block.general_settings.id,
66 options : cbxgooglemap_block.general_settings.id_options,
67 onChange: ( value ) => {
68 props.setAttributes( { id: parseInt(value) } );
69 },
70 value: props.attributes.id
71 }
72 ),
73 el( 'p', {'class' :'cbxgooglemap_block_note'}, cbxgooglemap_block.general_settings.id_note),
74 el( 'hr', {} ),
75 el( 'h3', {'class' :'cbxgooglemap_block_note_custom_attribute'}, cbxgooglemap_block.general_settings.custom_attribute_note),
76 el( SelectControl,
77 {
78 label: cbxgooglemap_block.general_settings.maptype,
79 options : cbxgooglemap_block.general_settings.maptype_options,
80 onChange: ( value ) => {
81 props.setAttributes( { maptype: value } );
82 },
83 value: props.attributes.maptype
84 }
85 ),
86 el( TextControl,
87 {
88 label: cbxgooglemap_block.general_settings.lat,
89 onChange: ( value ) => {
90 props.setAttributes( { lat: value } );
91 },
92 value: props.attributes.lat
93 }
94 ),
95 el( TextControl,
96 {
97 label: cbxgooglemap_block.general_settings.lng,
98 onChange: ( value ) => {
99 props.setAttributes( { lng: value } );
100 },
101 value: props.attributes.lng
102 }
103 ),
104 el( TextControl,
105 {
106 label: cbxgooglemap_block.general_settings.width,
107 onChange: ( value ) => {
108 props.setAttributes( { width: value } );
109 },
110 value: props.attributes.width
111 }
112 ),
113 el( TextControl,
114 {
115 label: cbxgooglemap_block.general_settings.height,
116 onChange: ( value ) => {
117 props.setAttributes( { height: value } );
118 },
119 value: props.attributes.height
120 }
121 ),
122 el( TextControl,
123 {
124 label: cbxgooglemap_block.general_settings.zoom,
125 onChange: ( value ) => {
126 props.setAttributes( { zoom: value } );
127 },
128 value: props.attributes.zoom
129 }
130 ),
131 el( ToggleControl,
132 {
133 label: cbxgooglemap_block.general_settings.scrollwheel,
134 onChange: ( value ) => {
135 props.setAttributes( { scrollwheel: value } );
136 },
137 checked: props.attributes.scrollwheel
138 }
139 ),
140 el( ToggleControl,
141 {
142 label: cbxgooglemap_block.general_settings.showinfo,
143 onChange: ( value ) => {
144 props.setAttributes( { showinfo: value } );
145 },
146 checked: props.attributes.showinfo
147 }
148 ),
149 el( ToggleControl,
150 {
151 label: cbxgooglemap_block.general_settings.infow_open,
152 onChange: ( value ) => {
153 props.setAttributes( { infow_open: value } );
154 },
155 checked: props.attributes.infow_open
156 }
157 ),
158 el( TextControl,
159 {
160 label: cbxgooglemap_block.general_settings.heading,
161 onChange: ( value ) => {
162 props.setAttributes( { heading: value } );
163 },
164 value: props.attributes.heading
165 }
166 ),
167 el( TextControl,
168 {
169 label: cbxgooglemap_block.general_settings.address,
170 onChange: ( value ) => {
171 props.setAttributes( { address: value } );
172 },
173 value: props.attributes.address
174 }
175 ),
176 el( TextControl,
177 {
178 label: cbxgooglemap_block.general_settings.website,
179 onChange: ( value ) => {
180 props.setAttributes( { website: value } );
181 },
182 value: props.attributes.website
183 }
184 ),
185 el( MediaUpload,
186 {
187 label: cbxgooglemap_block.general_settings.mapicon,
188 //value: props.attributes.icon_id,
189 value: props.attributes.mapicon,
190 onSelect: ( media ) => {
191 props.setAttributes(
192 {
193 //icon_id: parseInt(media.id),
194 mapicon: media.url,
195 }
196 );
197 },
198 type: 'image',
199 render: function( obj ) {
200 return el( components.Button, {
201 className: 'components-icon-button image-block-btn is-button is-default is-large',
202 onClick: obj.open
203 },
204 el( 'svg', { className: 'dashicon dashicons-edit', width: '20', height: '20' },
205 el( 'path', { d: "M2.25 1h15.5c.69 0 1.25.56 1.25 1.25v15.5c0 .69-.56 1.25-1.25 1.25H2.25C1.56 19 1 18.44 1 17.75V2.25C1 1.56 1.56 1 2.25 1zM17 17V3H3v14h14zM10 6c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2zm3 5s0-6 3-6v10c0 .55-.45 1-1 1H5c-.55 0-1-.45-1-1V8c2 0 3 4 3 4s1-3 3-3 3 2 3 2z" } )
206 ),
207 el( 'span', {}, cbxgooglemap_block.general_settings.mapicon_select
208 ),
209 );
210 }
211 }
212 ),
213
214 ),
215 )
216
217
218
219 ]},
220 // We're going to be rendering in PHP, so save() can just return null.
221 save: function () {
222 return null;
223 },
224 });
225 }(
226 window.wp.blocks,
227 window.wp.element,
228 window.wp.components,
229 window.wp.editor
230 ));