Changeset 2062123
- Timestamp:
- 04/03/2019 08:36:02 AM (7 years ago)
- Location:
- here-mobility/trunk
- Files:
-
- 6 edited
-
css/auto-complete.css (modified) (1 diff)
-
css/mce-here-button.css (modified) (2 diffs)
-
heremobility.php (modified) (4 diffs)
-
js/gutenberg-here-widget.js (modified) (7 diffs)
-
js/here-widget-button.js (modified) (8 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
here-mobility/trunk/css/auto-complete.css
r1980502 r2062123 26 26 border-radius: 4px; 27 27 background-color: rgba(0, 0, 0, .5); 28 -webkit-box-shadow: 0 0 1px rgba(255, 255, 255, .5);28 box-shadow: 0 0 1px rgba(255, 255, 255, .5); 29 29 } 30 30 -
here-mobility/trunk/css/mce-here-button.css
r2041749 r2062123 9 9 10 10 .mce-here-popup .mce-abs-layout { 11 height: 105px; 11 height: 240px; 12 width: 500px; 12 13 } 13 14 … … 23 24 24 25 .wp-here_panel { 25 max-width: 700px;26 max-width: 500px; 26 27 } -
here-mobility/trunk/heremobility.php
r2049373 r2062123 8 8 The Web Widget supports pickup location, destination, and required departure time, in addition, your users can also customize their ride according to any special requirements they have from suitcases to number of passengers. 9 9 The HERE Mobility Web Widget connects to the Mobility Marketplace to find the most relevant rides matching your users' requests and displays them to your users to choose from and book. To activate your Web Widget, please create an account(https://developer.mobility.here.com/signup) and request your app credentials. 10 * Version: 1.0. 810 * Version: 1.0.10 11 11 * Author: HERE Mobility 12 12 * Author URI: https://mobility.here.com/ … … 17 17 class HereMobility 18 18 { 19 const PLUGIN_VERSION = '1.0. 8';19 const PLUGIN_VERSION = '1.0.10'; 20 20 const SHORTCODE_WIDGET_TAG = 'here_panel'; 21 21 const SHORTCODE_LINK_TAG = 'here_link'; … … 179 179 'id' => '', 180 180 'appkey' => '', 181 'appsecret' => '' 181 'appsecret' => '', 182 'width' => '', 183 'height' => '', 184 'unit' => 'px', 185 'position' => 'center' 182 186 ), 183 187 array_change_key_case($attrs, CASE_LOWER) … … 215 219 'post_id' => get_the_ID() 216 220 ]); 217 return "<div class='wordpress-hmw' id='" . $attrs['id'] . "'></div><div id='table-booking-date'></div>"; 221 222 if ($attrs['width'] || $attrs['height']) { 223 $unit = $attrs['unit'] ? : 'px'; 224 $clear = ''; 225 $positionAttr = $attrs['position'] ? : 'center'; 226 227 switch ($positionAttr) { 228 case 'left': 229 $position = 'float: left;'; 230 $clear = 'style="clear:both;"'; 231 break; 232 case 'right': 233 $position = 'float: right;'; 234 $clear = 'style="clear:both;"'; 235 break; 236 default: 237 $position = 'margin: 0 auto;'; 238 } 239 240 $width = $attrs['width'] ? "width:{$attrs['width']}{$unit};" : ''; 241 $height = $attrs['height'] ? "height:{$attrs['height']}{$unit};" : ''; 242 $style = "{$width}{$height}{$position}"; 243 244 return sprintf("<div class='wordpress-hmw-container'><div class='wordpress-hmw' id='%s' style='%s'></div><div id='table-booking-date' %s></div></div>", 245 $attrs['id'], $style, $clear); 246 } else { 247 return sprintf("<div class='wordpress-hmw-container'><div class='wordpress-hmw' id='%s'></div><div id='table-booking-date'></div></div>", $attrs['id']); 248 } 218 249 } 219 250 -
here-mobility/trunk/js/gutenberg-here-widget.js
r1995227 r2062123 305 305 var _wp$components = wp.components, 306 306 RadioControl = _wp$components.RadioControl, 307 TextControl = _wp$components.TextControl; 307 TextControl = _wp$components.TextControl, 308 SelectControl = _wp$components.SelectControl; 308 309 309 310 … … 386 387 type: 'string', 387 388 default: null 389 }, 390 display: { 391 type: 'string', 392 default: 'default' 393 }, 394 width: { 395 type: 'string', 396 default: null 397 }, 398 height: { 399 type: 'string', 400 default: null 401 }, 402 unit: { 403 type: 'string', 404 default: 'px' 405 }, 406 position: { 407 type: 'string', 408 default: 'center' 388 409 } 389 410 }, … … 396 417 397 418 419 var settingDefaultAttributes = { 420 pickup: '', 421 destination: '', 422 appKey: '', 423 appSecret: '' 424 }; 425 426 var displayDefaultAttributes = { 427 width: '', 428 height: '', 429 unit: 'px', 430 position: 'center' 431 }; 432 398 433 if (!attributes.id) { 399 434 setAttributes({ … … 404 439 var onChangeSettings = function onChangeSettings(value) { 405 440 if (value === 'default') { 406 for (var key in attributes) {407 setAttributes(_defineProperty({}, key, ''));441 for (var key in settingDefaultAttributes) { 442 setAttributes(_defineProperty({}, key, settingDefaultAttributes[key])); 408 443 } 409 444 } 410 445 411 setAttributes({ 412 settings: value 413 }); 446 onChangeAttribute('settings')(value); 414 447 }; 415 448 … … 419 452 }; 420 453 }; 454 455 var onChangeDisplay = function onChangeDisplay(value) { 456 if (value === 'default') { 457 for (var key in displayDefaultAttributes) { 458 setAttributes(_defineProperty({}, key, displayDefaultAttributes[key])); 459 } 460 } 461 462 onChangeAttribute('display')(value); 463 }; 464 465 // if (!attributes.width && !attributes.height) { 466 // onChangeDisplay('default'); 467 // } 421 468 422 469 return [isSelected && wp.element.createElement( … … 426 473 'div', 427 474 null, 475 wp.element.createElement( 476 'h2', 477 null, 478 ' Settings ' 479 ), 428 480 (attributes.appKey && !attributes.appSecret || !attributes.appKey && attributes.appSecret) && wp.element.createElement( 429 481 'div', … … 461 513 value: attributes.appSecret, 462 514 onChange: onChangeAttribute('appSecret') 515 }) 516 ), 517 wp.element.createElement( 518 'div', 519 null, 520 wp.element.createElement( 521 'h2', 522 null, 523 ' Widget Display ' 524 ), 525 wp.element.createElement( 526 'p', 527 null, 528 'You can use the default size of the widget or set a custom size. Please note that HERE Mobility The widget\u2019s minimum size is ', 529 wp.element.createElement( 530 'b', 531 null, 532 '360x 450' 533 ), 534 '\u202Fpixels and its maximum size is ', 535 wp.element.createElement( 536 'b', 537 null, 538 '1200x450' 539 ), 540 ' pixels. The HERE web widget is mobile-responsive in portrait mode below the break point of ', 541 wp.element.createElement( 542 'b', 543 null, 544 '512*450' 545 ), 546 ' pixels.' 547 ), 548 wp.element.createElement(RadioControl, { 549 selected: attributes.display, 550 options: [{ label: 'Use Default Size', value: 'default' }, { label: 'Set custom size', value: 'custom' }], 551 onChange: onChangeDisplay 552 }) 553 ), 554 attributes.display === 'custom' && wp.element.createElement( 555 'div', 556 null, 557 wp.element.createElement(TextControl, { 558 label: 'Width', 559 type: 'number', 560 value: attributes.width, 561 onChange: onChangeAttribute('width') 562 }), 563 wp.element.createElement(TextControl, { 564 label: 'Height', 565 type: 'number', 566 value: attributes.height, 567 onChange: onChangeAttribute('height') 568 }), 569 wp.element.createElement(SelectControl, { 570 label: 'Unit', 571 value: attributes.unit, 572 options: [{ label: 'px', value: 'px' }, { label: '%', value: '%' }, { label: 'rem', value: 'rem' }], 573 onChange: onChangeAttribute('unit') 574 }), 575 wp.element.createElement(RadioControl, { 576 label: 'Position', 577 selected: attributes.position, 578 options: [{ label: 'Left', value: 'left' }, { label: 'Center', value: 'center' }, { label: 'Right', value: 'right' }], 579 onChange: onChangeAttribute('position') 463 580 }) 464 581 ) -
here-mobility/trunk/js/here-widget-button.js
r1995227 r2062123 61 61 label: '', 62 62 html: '<div> \ 63 <h2>Settings</h2>\ 63 64 <input type="radio" name="settings" value="default" id="settings_default"> \ 64 65 <label for="settings_default">Use default settings</label> \ … … 106 107 value: params.appSecret, 107 108 classes: 'app-secret' 108 } 109 }, 110 { 111 type: 'container', 112 name: 'display', 113 label: '', 114 html: '<div> \ 115 <h2>Widget Display</h2>\ 116 <p style="white-space: pre-line; font-style: italic; color: #ccc;">\ 117 You can use the default size of the widget or set a custom size. \ 118 Please note that HERE Mobility The widget’s minimum size is <b>360x 450</b> pixels\ 119 and its maximum size is <b>1200x450</b> pixels.\ 120 The HERE web widget is mobile-responsive in portrait mode below the break point of <b>512*450</b> pixels.\ 121 </p>\ 122 <input type="radio" name="display" value="default" id="display_default"> \ 123 <label for="display_default">Default</label> \ 124 <input type="radio" name="display" value="custom" id="display_custom"> \ 125 <label for="display_custom">Custom</label> \ 126 </div>' 127 }, 128 { 129 type: 'textbox', 130 name: 'width', 131 label: 'Width', 132 value: params.width, 133 classes: 'width' 134 }, 135 { 136 type: 'textbox', 137 name: 'height', 138 label: 'Height', 139 value: params.height, 140 classes: 'height' 141 }, 142 { 143 type: 'listbox', 144 name: 'unit', 145 label: 'Unit', 146 values : [ 147 { text: 'px', value: 'px' }, 148 { text: '%', value: '%' }, 149 { text: 'rem', value: 'rem' } 150 ], 151 value: params.unit, 152 classes: 'unit' 153 }, 154 { 155 type: 'listbox', 156 name: 'position', 157 label: 'Position', 158 values : [ 159 { text: 'left', value: 'left' }, 160 { text: 'center', value: 'center' }, 161 { text: 'right', value: 'right' } 162 ], 163 value: params.position, 164 classes: 'position' 165 } 109 166 ], 110 167 onSubmit: function (event) { … … 122 179 123 180 data.id = data.id || generateId(); 124 data.settings = params.settings == 'default' ? 'default': 'specific';181 data.settings = params.settings === 'default' ? 'default': 'specific'; 125 182 126 183 for(var prop in data) { … … 142 199 }, 143 200 onOpen: function () { 201 202 203 144 204 setTimeout(function () { 145 205 jQuery('.mce-pickup').autoComplete({ … … 156 216 jQuery('#settings_default').prop('checked', true); 157 217 158 jQuery('.mce-abs-layout-item').each(function (index) { 159 var elem = jQuery(this); 160 if (!elem.hasClass('mce-first')) { 161 elem.hide(); 162 } 163 }); 164 } else { 218 [ 219 '.mce-destination', 220 '.mce-pickup', 221 '.mce-app-key', 222 '.mce-app-secret' 223 ].forEach(function (childClass) { 224 jQuery(childClass).closest('.mce-abs-layout-item.mce-container').hide(); 225 }); 226 227 jQuery('#settings_default').prop('checked', true); 228 229 } else { 165 230 jQuery('#settings_specific').prop('checked', true); 166 231 } 232 233 if (params.display === 'default') { 234 [ 235 '.mce-width', 236 '.mce-height', 237 '.mce-unit', 238 '.mce-position' 239 ].forEach(function (childClass) { 240 jQuery(childClass).closest('.mce-abs-layout-item.mce-container').hide(); 241 }); 242 jQuery('#display_default').prop('checked', true); 243 244 } else { 245 jQuery('#display_custom').prop('checked', true); 246 } 167 247 168 248 jQuery('input[name="settings"]').change(function (event) { … … 175 255 jQuery('.mce-app-secret').val(''); 176 256 177 jQuery('.mce-abs-layout-item').each(function (index) { 178 var elem = jQuery(this); 179 if (!elem.hasClass('mce-first')) { 180 elem.hide(); 181 } 182 }); 257 [ 258 '.mce-destination', 259 '.mce-pickup', 260 '.mce-app-key', 261 '.mce-app-secret' 262 ].forEach(function (childClass) { 263 jQuery(childClass).closest('.mce-abs-layout-item.mce-container').hide(); 264 }); 265 183 266 params.settings = 'default'; 184 267 } else { 185 jQuery('.mce-abs-layout-item').each(function (index) { 186 var elem = jQuery(this); 187 if (!elem.hasClass('mce-first') && !elem.hasClass('mce-attr-id')) { 188 elem.show(); 189 } 190 }); 268 [ 269 '.mce-destination', 270 '.mce-pickup', 271 '.mce-app-key', 272 '.mce-app-secret' 273 ].forEach(function (childClass) { 274 jQuery(childClass).closest('.mce-abs-layout-item.mce-container').show(); 275 }); 276 191 277 params.settings = 'specific'; 192 278 } 193 279 }); 280 281 jQuery('input[name="display"]').change(function (event) { 282 if (event.target.getAttribute('value') === 'default') { 283 284 jQuery('.mce-width').val(''); 285 jQuery('.mce-height').val(''); 286 jQuery('.mce-unit').val('px'); 287 jQuery('.mce-position').val('center'); 288 289 [ 290 '.mce-width', 291 '.mce-height', 292 '.mce-unit', 293 '.mce-position' 294 ].forEach(function (childClass) { 295 jQuery(childClass).closest('.mce-abs-layout-item.mce-container').hide(); 296 }); 297 298 params.display = 'default'; 299 } else { 300 301 [ 302 '.mce-width', 303 '.mce-height', 304 '.mce-unit', 305 '.mce-position' 306 ].forEach(function (childClass) { 307 jQuery(childClass).closest('.mce-abs-layout-item.mce-container').show(); 308 }); 309 310 params.settings = 'custom'; 311 } 312 }); 194 313 }); 195 314 }, … … 211 330 appKey: '', 212 331 appSecret: '', 213 settings: 'default' 332 settings: 'default', 333 display: 'default', 334 width: '', 335 height: '', 336 unit: 'px', 337 position: 'center' 214 338 }); 215 339 } … … 238 362 appKey: getAttr(title, 'appKey'), 239 363 appSecret: getAttr(title, 'appSecret'), 240 settings: getAttr(title, 'settings') 364 settings: getAttr(title, 'settings'), 365 width: getAttr(title, 'width'), 366 height: getAttr(title, 'height'), 367 position: getAttr(title, 'position'), 368 unit: getAttr(title, 'unit'), 369 display: getAttr(title, 'display'), 241 370 }); 242 371 } -
here-mobility/trunk/readme.txt
r2049373 r2062123 6 6 Requires at least: 4.0 7 7 Tested up to: 5.0.8 8 Stable tag: 1.0. 88 Stable tag: 1.0.10 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.txt
Note: See TracChangeset
for help on using the changeset viewer.