Poll, Survey, Quiz, Slideshow, Form, Story & Landing Page - Version 19.6.18

Version Description

  • bugfixes
Download this release

Release Info

Developer kucaahbe
Plugin Icon 128x128 Poll, Survey, Quiz, Slideshow, Form, Story & Landing Page
Version 19.6.18
Comparing to
See all releases

Code changes from version 19.6.17 to 19.6.18

Files changed (38) hide show
  1. admin/content-popup-gutenberg-template.html.php +15 -3
  2. admin/content-popup-template.html.php +19 -4
  3. admin/content-popup.php +13 -11
  4. admin/css/menu-page.css +2 -25
  5. admin/views/deactivate-feedback-form.php +19 -1
  6. admin/views/getting_started.php +33 -0
  7. admin/views/my_placements.php +3 -3
  8. admin/views/settings_track.php +1 -1
  9. admin/views/view_my_items.php +73 -34
  10. gutenberg/.editorconfig +21 -21
  11. gutenberg/.eslintignore +9 -9
  12. gutenberg/.eslintrc.json +192 -192
  13. gutenberg/.gitignore +84 -84
  14. gutenberg/form/dist/blocks.build.js +1 -1
  15. gutenberg/form/src/.DS_Store +0 -0
  16. gutenberg/form/src/block/block.js +168 -211
  17. gutenberg/init.php +8 -3
  18. gutenberg/personality/dist/blocks.build.js +1 -1
  19. gutenberg/personality/src/.DS_Store +0 -0
  20. gutenberg/personality/src/block/block.js +168 -209
  21. gutenberg/poll/dist/blocks.build.js +1 -1
  22. gutenberg/poll/src/.DS_Store +0 -0
  23. gutenberg/poll/src/block/block.js +167 -208
  24. gutenberg/slideshow/dist/blocks.build.js +1 -1
  25. gutenberg/slideshow/src/.DS_Store +0 -0
  26. gutenberg/slideshow/src/block/block.js +168 -210
  27. gutenberg/survey/dist/blocks.build.js +1 -1
  28. gutenberg/survey/src/.DS_Store +0 -0
  29. gutenberg/survey/src/block/block.js +168 -209
  30. gutenberg/trivia/dist/blocks.build.js +1 -1
  31. gutenberg/trivia/src/.DS_Store +0 -0
  32. gutenberg/trivia/src/block/block.js +170 -211
  33. includes/opinionstage-article-placement-functions.php +37 -37
  34. includes/opinionstage-functions.php +93 -93
  35. includes/opinionstage-sidebar-widget.php +1 -1
  36. opinionstage-polls.php +1 -1
  37. plugin.php +2 -2
  38. readme.txt +687 -685
admin/content-popup-gutenberg-template.html.php CHANGED
@@ -55,7 +55,7 @@ function opinionstage_create_new_href() {
55
  <div class="header-right-container">
56
  <div class="header-right-inner-container">
57
  <div class='filter'>
58
- <div class="dropdown">
59
  <button class="dropbtn gutenberg_dropdown" id="dropbtn"><span>All ITEMS</span></button>
60
  <div class="dropdown-content">
61
  <div class='filter__itm'
@@ -118,15 +118,17 @@ function opinionstage_create_new_href() {
118
  <div class='content__list'>
119
  <div v-if='hasData'>
120
  <div class='content__itm' v-for="widget in widgets">
 
121
  <div class='content__image'>
122
  <img :src='widget.imageUrl'>
123
  <div class='content__label'>{{ widget.type }}</div>
124
  </div>
125
- <p class='content__info'>{{ widget.title }}</p>
 
126
  <div class='content__links'>
127
  <button class='popup-content-btn content__links-itm'
128
  @click="var shortcode = widget.landingPageUrl.replace('https://www.opinionstage.com',''); window.verifyOSInsert(shortcode)">insert</button>
129
- <div class="dropdown">
130
  <div class="popup-action popup-content-btn"></div>
131
  <div class="content-item-menu">
132
  <div class="top-arrow-box"><div class="top-arrow"></div></div>
@@ -225,7 +227,17 @@ function opinionstage_create_new_href() {
225
  $('.filter__itm').live('click', function(e) {
226
  var text = $(this).text();
227
  $("button#dropbtn span").text(text);
 
 
 
 
 
 
 
 
 
228
  });
 
229
  $('div#show-templates').live('click', function(e) {
230
  var inputs = $(".filter__itm");
231
  for(var i = 0; i < inputs.length; i++){
55
  <div class="header-right-container">
56
  <div class="header-right-inner-container">
57
  <div class='filter'>
58
+ <div class="dropdown dropdown_items">
59
  <button class="dropbtn gutenberg_dropdown" id="dropbtn"><span>All ITEMS</span></button>
60
  <div class="dropdown-content">
61
  <div class='filter__itm'
118
  <div class='content__list'>
119
  <div v-if='hasData'>
120
  <div class='content__itm' v-for="widget in widgets">
121
+ <a target="_blank" :href='widget.landingPageUrl'>
122
  <div class='content__image'>
123
  <img :src='widget.imageUrl'>
124
  <div class='content__label'>{{ widget.type }}</div>
125
  </div>
126
+ </a>
127
+ <p class='content__info'><a target="_blank" :href='widget.editUrl'>{{ widget.title }}</a></p>
128
  <div class='content__links'>
129
  <button class='popup-content-btn content__links-itm'
130
  @click="var shortcode = widget.landingPageUrl.replace('https://www.opinionstage.com',''); window.verifyOSInsert(shortcode)">insert</button>
131
+ <div class="dropdown dropdown-popup-action">
132
  <div class="popup-action popup-content-btn"></div>
133
  <div class="content-item-menu">
134
  <div class="top-arrow-box"><div class="top-arrow"></div></div>
227
  $('.filter__itm').live('click', function(e) {
228
  var text = $(this).text();
229
  $("button#dropbtn span").text(text);
230
+
231
+ $('.dropdown_items .dropdown-content').attr('style', 'display: none !important');
232
+ $(".dropdown_items #dropbtn").hover(function() {
233
+ $('.dropdown_items .dropdown-content').css("display","block");
234
+ });
235
+ });
236
+
237
+ jQuery(document).live('click', function(e) {
238
+ $('.dropdown_items .dropdown-content').attr('style', 'display: none !important');
239
  });
240
+
241
  $('div#show-templates').live('click', function(e) {
242
  var inputs = $(".filter__itm");
243
  for(var i = 0; i < inputs.length; i++){
admin/content-popup-template.html.php CHANGED
@@ -50,7 +50,7 @@ function opinionstage_create_new_href() {
50
  <div class="header-right-container">
51
  <div class="header-right-inner-container">
52
  <div class='filter'>
53
- <div class="dropdown">
54
  <button class="dropbtn" id="dropbtn"><span>All ITEMS</span></button>
55
  <div class="dropdown-content">
56
  <div class='filter__itm'
@@ -112,14 +112,16 @@ function opinionstage_create_new_href() {
112
  <div class='content__list'>
113
  <div v-if='hasData'>
114
  <div class='content__itm' v-for="widget in widgets">
 
115
  <div class='content__image'>
116
  <img :src='widget.imageUrl'>
117
  <div class='content__label'>{{ widget.type }}</div>
118
  </div>
119
- <p class='content__info'>{{ widget.title }}</p>
 
120
  <div class='content__links'>
121
  <button class='popup-content-btn content__links-itm' @click="insertShortcode(widget)">insert</button>
122
- <div class="dropdown">
123
  <div class="popup-action popup-content-btn"></div>
124
  <div class="content-item-menu">
125
  <div class="top-arrow-box"><div class="top-arrow"></div></div>
@@ -201,11 +203,24 @@ function opinionstage_create_new_href() {
201
  </div>
202
  </template>
203
  <script>
204
- jQuery(document).ready(function ($) {
205
  $('.filter__itm').live('click', function(e) {
206
  var text = $(this).text();
207
  $("button#dropbtn span").text(text);
 
 
208
  });
 
 
 
 
 
 
 
 
 
 
 
209
  $('div#show-templates').live('click', function(e) {
210
  var inputs = $(".filter__itm");
211
  for(var i = 0; i < inputs.length; i++){
50
  <div class="header-right-container">
51
  <div class="header-right-inner-container">
52
  <div class='filter'>
53
+ <div class="dropdown dropdown_items">
54
  <button class="dropbtn" id="dropbtn"><span>All ITEMS</span></button>
55
  <div class="dropdown-content">
56
  <div class='filter__itm'
112
  <div class='content__list'>
113
  <div v-if='hasData'>
114
  <div class='content__itm' v-for="widget in widgets">
115
+ <a target="_blank" :href='widget.landingPageUrl'>
116
  <div class='content__image'>
117
  <img :src='widget.imageUrl'>
118
  <div class='content__label'>{{ widget.type }}</div>
119
  </div>
120
+ </a>
121
+ <p class='content__info'><a target="_blank" :href='widget.editUrl'>{{ widget.title }}</a></p>
122
  <div class='content__links'>
123
  <button class='popup-content-btn content__links-itm' @click="insertShortcode(widget)">insert</button>
124
+ <div class="dropdown dropdown-popup-action">
125
  <div class="popup-action popup-content-btn"></div>
126
  <div class="content-item-menu">
127
  <div class="top-arrow-box"><div class="top-arrow"></div></div>
203
  </div>
204
  </template>
205
  <script>
206
+ jQuery(document).ready(function ($) {
207
  $('.filter__itm').live('click', function(e) {
208
  var text = $(this).text();
209
  $("button#dropbtn span").text(text);
210
+
211
+ $('.dropdown_items .dropdown-content').attr('style', 'display: none !important');
212
  });
213
+
214
+ setTimeout(function(){
215
+ $(".dropdown_items #dropbtn").hover(function() {
216
+ $('.dropdown_items .dropdown-content').css("display","block");
217
+ });
218
+ },3000);
219
+
220
+ jQuery(document).live('click', function(e) {
221
+ $('.dropdown_items .dropdown-content').attr('style', 'display: none !important');
222
+ });
223
+
224
  $('div#show-templates').live('click', function(e) {
225
  var inputs = $(".filter__itm");
226
  for(var i = 0; i < inputs.length; i++){
admin/content-popup.php CHANGED
@@ -115,6 +115,10 @@ span#insert_error_editor a {
115
  position: relative;
116
  }
117
 
 
 
 
 
118
  .dropdown-content {
119
  background-color: #f9f9f9;
120
  box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
@@ -138,6 +142,9 @@ span#insert_error_editor a {
138
 
139
  .dropdown-content div:hover {background-color: #3487fa; color: #fff !important;}
140
 
 
 
 
141
  .dropdown:hover .dropdown-content {
142
  display: block !important;
143
  width: 180px;
@@ -311,7 +318,6 @@ li.create-menu__itm.companymenuli a.alisting {
311
  padding: 30px;
312
  }
313
  .opinionstage-content-popup-contents .filter {
314
- /* margin-right: 50px !important;*/
315
  width: auto;
316
  }
317
  .opinionstage-content-popup-contents .filter .dropdown .dropbtn {
@@ -392,10 +398,6 @@ li.create-menu__itm.companymenuli a.alisting {
392
  height: 90px;
393
  width: 15%;
394
  }
395
- /*.opinionstage-content-popup-contents .content__image img {
396
- height: 90px;
397
- width: 120px;
398
- }*/
399
  .opinionstage-content-popup-contents .content__info {
400
  background: transparent;
401
  display: inline-block;
@@ -407,6 +409,10 @@ li.create-menu__itm.companymenuli a.alisting {
407
  text-overflow: ellipsis;
408
  white-space: nowrap;
409
  }
 
 
 
 
410
  .opinionstage-content-popup-contents .content__itm:hover .content__links {
411
  display: inline-block;
412
  }
@@ -438,9 +444,6 @@ li.create-menu__itm.companymenuli a.alisting {
438
  padding: 12px 25px;
439
  position: relative;
440
  }
441
- /*.popup-action {
442
- position: relative;
443
- }*/
444
  .popup-action:before {
445
  color: #32adbc;
446
  content: "";
@@ -478,7 +481,7 @@ li.create-menu__itm.companymenuli a.alisting {
478
  .popup-action-dropdown.dropdown-content {
479
  left: auto;
480
  right: 0;
481
- top: 18px;
482
  z-index: 10;
483
  }
484
  .dropdown:hover .popup-action-dropdown.dropdown-content {
@@ -515,7 +518,6 @@ input.components-button.is-button.is-default.is-block.is-primary {
515
  }
516
  .top-arrow-box {
517
  position: relative;
518
- /*padding-top: 7px;*/
519
  }
520
  .top-arrow-box .top-arrow {
521
  background: #ffffff;
@@ -541,7 +543,7 @@ input.components-button.is-button.is-default.is-block.is-primary {
541
  line-height: normal;
542
  margin-left: -4px;
543
  position: absolute;
544
- top: 8px;
545
  transform: rotate(180deg);
546
  z-index: 99;
547
  }
115
  position: relative;
116
  }
117
 
118
+ .dropdown-popup-action {
119
+ height: 45px;
120
+ }
121
+
122
  .dropdown-content {
123
  background-color: #f9f9f9;
124
  box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
142
 
143
  .dropdown-content div:hover {background-color: #3487fa; color: #fff !important;}
144
 
145
+ .dropdown_items .dropdown-content {
146
+ width: 180px;
147
+ }
148
  .dropdown:hover .dropdown-content {
149
  display: block !important;
150
  width: 180px;
318
  padding: 30px;
319
  }
320
  .opinionstage-content-popup-contents .filter {
 
321
  width: auto;
322
  }
323
  .opinionstage-content-popup-contents .filter .dropdown .dropbtn {
398
  height: 90px;
399
  width: 15%;
400
  }
 
 
 
 
401
  .opinionstage-content-popup-contents .content__info {
402
  background: transparent;
403
  display: inline-block;
409
  text-overflow: ellipsis;
410
  white-space: nowrap;
411
  }
412
+ .opinionstage-content-popup-contents .content__info a, .opinionstage-content-popup-contents .content__info a:hover {
413
+ color: inherit;
414
+ text-decoration: none;
415
+ }
416
  .opinionstage-content-popup-contents .content__itm:hover .content__links {
417
  display: inline-block;
418
  }
444
  padding: 12px 25px;
445
  position: relative;
446
  }
 
 
 
447
  .popup-action:before {
448
  color: #32adbc;
449
  content: "";
481
  .popup-action-dropdown.dropdown-content {
482
  left: auto;
483
  right: 0;
484
+ top: 20px;
485
  z-index: 10;
486
  }
487
  .dropdown:hover .popup-action-dropdown.dropdown-content {
518
  }
519
  .top-arrow-box {
520
  position: relative;
 
521
  }
522
  .top-arrow-box .top-arrow {
523
  background: #ffffff;
543
  line-height: normal;
544
  margin-left: -4px;
545
  position: absolute;
546
+ top: 10px;
547
  transform: rotate(180deg);
548
  z-index: 99;
549
  }
admin/css/menu-page.css CHANGED
@@ -7,9 +7,6 @@
7
  width: 100%;
8
  -webkit-font-smoothing: antialiased;
9
  }
10
- /*#opinionstage-content a {
11
- color: #32adbc;
12
- }*/
13
  #opinionstage-content .opinionstage-header-wrapper {
14
  background: #232121;
15
  margin-right: 20px;
@@ -34,7 +31,6 @@
34
  padding: 20px 35px 0;
35
  }
36
  #opinionstage-content .opinionstage-status-content-connected {
37
- /*background: url(../images/top-bg.png) no-repeat 0px 0px;*/
38
  color: #fff;
39
  height: 115px;
40
  padding: 30px 30px 0;
@@ -130,16 +126,14 @@
130
  }
131
  #opinionstage-content .opinionstage-dashboard {
132
  background-color: #fff;
133
- /* height: 100vw;*/
134
  margin-right: 20px;
 
135
  overflow: hidden;
136
  }
137
  #opinionstage-content .opinionstage-dashboard-left , #opinionstage-content .opinionstage-dashboard-right {
138
- float: left;
139
  width: 1000px;
140
  }
141
  #opinionstage-content .opinionstage-dashboard-left {
142
- /*margin-right: 40px;*/
143
  margin: 30px;
144
  }
145
  #opinionstage-content .opinionstage-dashboard-section {
@@ -159,8 +153,6 @@
159
  float: left;
160
  margin: 0;
161
  padding: 10px;
162
- /*margin-right: 0;
163
- padding: 10px 25px;*/
164
  }
165
  #opinionstage-content .opinionstage-dashboard-section .opinionstage-section-header a:focus {
166
  box-shadow: none;
@@ -216,14 +208,10 @@
216
  display: table-row;
217
  }
218
  #opinionstage-content .opinionstage-dashboard-section .opinionstage-section-content-wrapper .opinionstage-section-content .opinionstage-section-raw {
219
- /*border: none;*/
220
  border-bottom: 1px solid #c8c8c9;
221
  border-left: none;
222
  border-right: none;
223
  }
224
- /*#opinionstage-content .opinionstage-dashboard-section .opinionstage-section-content-wrapper .opinionstage-section-content .opinionstage-section-raw:last-child {
225
- border-bottom: none;
226
- }*/
227
  #opinionstage-content .opinionstage-dashboard-section .opinionstage-section-content .opinionstage-section-raw .opinionstage-section-cell {
228
  display: table-cell;
229
  padding: 20px 0;
@@ -288,7 +276,6 @@
288
  }
289
  #opinionstage-section-placements .opinionstage-section-cell.opinionstage-btns-cell .opinionstage-edit-settings {
290
  font-size: 19px;
291
- /*height: 18px;*/
292
  width: 29px;
293
  }
294
  #opinionstage-section-help .opinionstage-section-content {
@@ -379,10 +366,8 @@
379
  /* Getting started */
380
  .gettingStartedSection {
381
  background: #fff;
382
- height: 100vw;
383
- /* width: 100%;
384
- max-width: 100%;*/
385
  margin-right: 20px;
 
386
  overflow: hidden;
387
  padding: 30px;
388
  }
@@ -546,7 +531,6 @@ a.opinionstage-blue-bordered-btn {
546
  }
547
  td.action {
548
  width: 30%;
549
- /*opacity: 0.7;*/
550
  }
551
  span.os-icon-plugin.icon-os-common-date {
552
  margin-right: 4px;
@@ -602,7 +586,6 @@ tr.settingBorderOs {
602
  }
603
  div#container .opinionstage-section-header {
604
  width: 100%;
605
- /*max-width: 890px;*/
606
  }
607
  .opinionstage-section-title {
608
  float: left;
@@ -637,7 +620,6 @@ div#loadMore {
637
  cursor: pointer;
638
  font-size: 14px;
639
  line-height: 38px;
640
- /*text-transform: uppercase;*/
641
  border: 1px solid #dededd;
642
  border-radius: 3px;
643
  padding: 0 10px;
@@ -702,7 +684,6 @@ td.image {
702
 
703
  .opinionstage-item-view-dashboard {
704
  margin: 30px;
705
- float: left;
706
  width: 1000px;
707
  }
708
  .opinionstage-header-inner-container {
@@ -752,9 +733,6 @@ td.image {
752
  .opinionstage-item-view-dashboard #check tbody .action .opinionstage-edit-content:last-child {
753
  margin-right: 0;
754
  }
755
- /*#opinionstage-content .opinionstage-item-title {
756
- color: #32373c;
757
- }*/
758
  .opinionstage-item-action-container {
759
  float: right;
760
  }
@@ -769,7 +747,6 @@ div#loadMore {
769
  margin: 0;
770
  }
771
  .opinionstage-placement-dashboard {
772
- float: left;
773
  margin: 30px;
774
  width: 1000px;
775
  }
7
  width: 100%;
8
  -webkit-font-smoothing: antialiased;
9
  }
 
 
 
10
  #opinionstage-content .opinionstage-header-wrapper {
11
  background: #232121;
12
  margin-right: 20px;
31
  padding: 20px 35px 0;
32
  }
33
  #opinionstage-content .opinionstage-status-content-connected {
 
34
  color: #fff;
35
  height: 115px;
36
  padding: 30px 30px 0;
126
  }
127
  #opinionstage-content .opinionstage-dashboard {
128
  background-color: #fff;
 
129
  margin-right: 20px;
130
+ min-height: 800px;
131
  overflow: hidden;
132
  }
133
  #opinionstage-content .opinionstage-dashboard-left , #opinionstage-content .opinionstage-dashboard-right {
 
134
  width: 1000px;
135
  }
136
  #opinionstage-content .opinionstage-dashboard-left {
 
137
  margin: 30px;
138
  }
139
  #opinionstage-content .opinionstage-dashboard-section {
153
  float: left;
154
  margin: 0;
155
  padding: 10px;
 
 
156
  }
157
  #opinionstage-content .opinionstage-dashboard-section .opinionstage-section-header a:focus {
158
  box-shadow: none;
208
  display: table-row;
209
  }
210
  #opinionstage-content .opinionstage-dashboard-section .opinionstage-section-content-wrapper .opinionstage-section-content .opinionstage-section-raw {
 
211
  border-bottom: 1px solid #c8c8c9;
212
  border-left: none;
213
  border-right: none;
214
  }
 
 
 
215
  #opinionstage-content .opinionstage-dashboard-section .opinionstage-section-content .opinionstage-section-raw .opinionstage-section-cell {
216
  display: table-cell;
217
  padding: 20px 0;
276
  }
277
  #opinionstage-section-placements .opinionstage-section-cell.opinionstage-btns-cell .opinionstage-edit-settings {
278
  font-size: 19px;
 
279
  width: 29px;
280
  }
281
  #opinionstage-section-help .opinionstage-section-content {
366
  /* Getting started */
367
  .gettingStartedSection {
368
  background: #fff;
 
 
 
369
  margin-right: 20px;
370
+ min-height: 500px;
371
  overflow: hidden;
372
  padding: 30px;
373
  }
531
  }
532
  td.action {
533
  width: 30%;
 
534
  }
535
  span.os-icon-plugin.icon-os-common-date {
536
  margin-right: 4px;
586
  }
587
  div#container .opinionstage-section-header {
588
  width: 100%;
 
589
  }
590
  .opinionstage-section-title {
591
  float: left;
620
  cursor: pointer;
621
  font-size: 14px;
622
  line-height: 38px;
 
623
  border: 1px solid #dededd;
624
  border-radius: 3px;
625
  padding: 0 10px;
684
 
685
  .opinionstage-item-view-dashboard {
686
  margin: 30px;
 
687
  width: 1000px;
688
  }
689
  .opinionstage-header-inner-container {
733
  .opinionstage-item-view-dashboard #check tbody .action .opinionstage-edit-content:last-child {
734
  margin-right: 0;
735
  }
 
 
 
736
  .opinionstage-item-action-container {
737
  float: right;
738
  }
747
  margin: 0;
748
  }
749
  .opinionstage-placement-dashboard {
 
750
  margin: 30px;
751
  width: 1000px;
752
  }
admin/views/deactivate-feedback-form.php CHANGED
@@ -17,6 +17,23 @@ global $wp_version;
17
  $plugin = explode('/',$value); // Folder name will be displayed
18
  $plugin_list[] = $plugin[0];
19
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  ?>
21
  <style type="text/css">
22
  .os-feedback-modal-wrapper {
@@ -148,9 +165,10 @@ mixpanel.init("73bec82504e0f14a7dba16aebd26b97d",{
148
  $ospEmail = '<?php echo $connectedEmail; ?>';
149
  $ospItemCount = '<?php echo $item_count; ?>';
150
  $pluginVersion="<?php echo OPINIONSTAGE_WIDGET_VERSION ?>";
 
151
 
152
  mixpanel.track("WordPress Opinion Stage Disconnect",
153
- {"reason": reason, "details": reason ,"url": window.location.href,"opinionStagePluginConnect": $opswConnected, "wpVersion": $ospVersion, "osVersion": $pluginVersion, "theme": $ospTheme, "pluginList": $ospPluginList, "email": $ospEmail, 'totalItem': $ospItemCount, },
154
  function(){
155
  window.location = elemOpen.find('a').attr('href');
156
  }
17
  $plugin = explode('/',$value); // Folder name will be displayed
18
  $plugin_list[] = $plugin[0];
19
  }
20
+
21
+ if ($wp_version < 5) {
22
+ if ( function_exists( 'register_block_type' ) && is_plugin_active( 'gutenberg/gutenberg.php') ) {
23
+ $editor = 'Gutenberg + Classic';
24
+ }
25
+ else {
26
+ $editor = 'Classic';
27
+ }
28
+ }
29
+ else {
30
+ if ( is_plugin_active( 'classic-editor/classic-editor.php') ) {
31
+ $editor = 'Gutenberg + Classic';
32
+ }
33
+ else {
34
+ $editor = 'Gutenberg';
35
+ }
36
+ }
37
  ?>
38
  <style type="text/css">
39
  .os-feedback-modal-wrapper {
165
  $ospEmail = '<?php echo $connectedEmail; ?>';
166
  $ospItemCount = '<?php echo $item_count; ?>';
167
  $pluginVersion="<?php echo OPINIONSTAGE_WIDGET_VERSION ?>";
168
+ $oseditor = '<?php echo $editor; ?>';
169
 
170
  mixpanel.track("WordPress Opinion Stage Disconnect",
171
+ {"reason": reason, "details": reason ,"url": window.location.href,"opinionStagePluginConnect": $opswConnected, "wpVersion": $ospVersion, "osVersion": $pluginVersion, "theme": $ospTheme, "pluginList": $ospPluginList, "email": $ospEmail, 'totalItem': $ospItemCount, 'editor': $oseditor, },
172
  function(){
173
  window.location = elemOpen.find('a').attr('href');
174
  }
admin/views/getting_started.php CHANGED
@@ -43,5 +43,38 @@ defined( 'ABSPATH' ) or die();
43
  <a href="https://help.opinionstage.com/wordpress-plugin/how-to-use-the-wordpress-plugin?utm_source=wordpress&utm_campaign=WPMainPI&utm_medium=link&o=wp35e8" target="_blank"><div class="gettingTemplateTutorial">GETTING STARTED <br/>TUTORIALS</div></a>
44
  </div>
45
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  <?php } ?>
47
  </div>
43
  <a href="https://help.opinionstage.com/wordpress-plugin/how-to-use-the-wordpress-plugin?utm_source=wordpress&utm_campaign=WPMainPI&utm_medium=link&o=wp35e8" target="_blank"><div class="gettingTemplateTutorial">GETTING STARTED <br/>TUTORIALS</div></a>
44
  </div>
45
  </div>
46
+
47
+ <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
48
+ <script type="text/javascript">
49
+ var aElems = document.getElementsByTagName('a');
50
+
51
+ for (var i = 0, len = aElems.length; i < len; i++) {
52
+ aElems[i].onclick = function(e) {
53
+ e.preventDefault();
54
+ var href = jQuery(this).attr('href');
55
+ var target = jQuery(this).attr('target');
56
+
57
+ swal({
58
+ title: "Leave without connecting?",
59
+ text: "To use this plugin you need to first connect WordPress with Opinion Stage.",
60
+ icon: "warning",
61
+ buttons: ["Cancel", "Leave"],
62
+ })
63
+ .then((willDelete) => {
64
+ if (willDelete) {
65
+ if(target !== undefined) {
66
+ window.open(href, target);
67
+ }
68
+ else {
69
+ window.location.href = href;
70
+ }
71
+ }
72
+ else {
73
+ jQuery('#os-email').focus();
74
+ }
75
+ });
76
+ };
77
+ }
78
+ </script>
79
  <?php } ?>
80
  </div>
admin/views/my_placements.php CHANGED
@@ -59,7 +59,7 @@ defined( 'ABSPATH' ) or die();
59
  <div class="example">Add a content popup to your site</div>
60
  </div>
61
  <div class="opinionstage-section-cell opinionstage-btns-cell">
62
- <a href="<?php echo opinionstage_flyout_edit_url('content'); ?>" class='opinionstage-blue-bordered-btn opinionstage-edit-content <?php echo( $os_client_logged_in ? '' : 'disabled' ) ?>' target="_blank">EDIT CONTENT</a>
63
  <a href="<?php echo opinionstage_flyout_edit_url('settings'); ?>" class='opinionstage-blue-bordered-btn opinionstage-edit-settings <?php echo( $os_client_logged_in ? '' : 'disabled' ) ?>' target="_blank">
64
  <div class="os-icon-plugin icon-os-common-settings"></div>
65
  </a>
@@ -84,7 +84,7 @@ defined( 'ABSPATH' ) or die();
84
  <div class="example">Add a content section to all posts</div>
85
  </div>
86
  <div class="opinionstage-section-cell opinionstage-btns-cell">
87
- <a href="<?php echo opinionstage_article_placement_edit_url('content'); ?>" class='opinionstage-blue-bordered-btn opinionstage-edit-content <?php echo( $os_client_logged_in ? '' : 'disabled' ) ?>' target="_blank">EDIT CONTENT</a>
88
  <a href="<?php echo opinionstage_article_placement_edit_url('settings'); ?>" class='opinionstage-blue-bordered-btn opinionstage-edit-settings <?php echo( $os_client_logged_in ? '' : 'disabled' ) ?>' target="_blank">
89
  <div class="os-icon-plugin icon-os-common-settings"></div>
90
  </a>
@@ -117,7 +117,7 @@ defined( 'ABSPATH' ) or die();
117
  </div>
118
  </div>
119
  <div class="opinionstage-section-cell opinionstage-btns-cell">
120
- <a href="<?php echo opinionstage_sidebar_placement_edit_url('content'); ?>" class='opinionstage-blue-bordered-btn opinionstage-edit-content <?php echo( $os_client_logged_in ? '' : 'disabled' ) ?>' target="_blank">EDIT CONTENT</a>
121
  <a href="<?php echo opinionstage_sidebar_placement_edit_url('settings'); ?>" class='opinionstage-blue-bordered-btn opinionstage-edit-settings <?php echo( $os_client_logged_in ? '' : 'disabled' ) ?>' target="_blank">
122
  <div class="os-icon-plugin icon-os-common-settings"></div>
123
  </a>
59
  <div class="example">Add a content popup to your site</div>
60
  </div>
61
  <div class="opinionstage-section-cell opinionstage-btns-cell">
62
+ <a href="<?php echo opinionstage_flyout_edit_url('content'); ?>" class='opinionstage-blue-bordered-btn opinionstage-edit-content <?php echo( $os_client_logged_in ? '' : 'disabled' ) ?>' target="_blank">SELECT ITEM</a>
63
  <a href="<?php echo opinionstage_flyout_edit_url('settings'); ?>" class='opinionstage-blue-bordered-btn opinionstage-edit-settings <?php echo( $os_client_logged_in ? '' : 'disabled' ) ?>' target="_blank">
64
  <div class="os-icon-plugin icon-os-common-settings"></div>
65
  </a>
84
  <div class="example">Add a content section to all posts</div>
85
  </div>
86
  <div class="opinionstage-section-cell opinionstage-btns-cell">
87
+ <a href="<?php echo opinionstage_article_placement_edit_url('content'); ?>" class='opinionstage-blue-bordered-btn opinionstage-edit-content <?php echo( $os_client_logged_in ? '' : 'disabled' ) ?>' target="_blank">SELECT ITEM</a>
88
  <a href="<?php echo opinionstage_article_placement_edit_url('settings'); ?>" class='opinionstage-blue-bordered-btn opinionstage-edit-settings <?php echo( $os_client_logged_in ? '' : 'disabled' ) ?>' target="_blank">
89
  <div class="os-icon-plugin icon-os-common-settings"></div>
90
  </a>
117
  </div>
118
  </div>
119
  <div class="opinionstage-section-cell opinionstage-btns-cell">
120
+ <a href="<?php echo opinionstage_sidebar_placement_edit_url('content'); ?>" class='opinionstage-blue-bordered-btn opinionstage-edit-content <?php echo( $os_client_logged_in ? '' : 'disabled' ) ?>' target="_blank">SELECT ITEM</a>
121
  <a href="<?php echo opinionstage_sidebar_placement_edit_url('settings'); ?>" class='opinionstage-blue-bordered-btn opinionstage-edit-settings <?php echo( $os_client_logged_in ? '' : 'disabled' ) ?>' target="_blank">
122
  <div class="os-icon-plugin icon-os-common-settings"></div>
123
  </a>
admin/views/settings_track.php CHANGED
@@ -2,7 +2,7 @@
2
  // block direct access to plugin PHP files:
3
  defined( 'ABSPATH' ) or die(1);
4
 
5
- if(isset($_POST['submit_tracking']) && $_POST['submit_tracking'] == 'Save Changes'){
6
  if(isset($_POST['opinionstage_allow_tracking']) && $_POST['opinionstage_allow_tracking'] == 'yes'){
7
  update_option('oswp_tracking_user_site_data', 'yes');
8
  }else{
2
  // block direct access to plugin PHP files:
3
  defined( 'ABSPATH' ) or die(1);
4
 
5
+ if(isset($_POST['submit_tracking']) && $_POST['submit_tracking'] == 'SAVE CHANGES'){
6
  if(isset($_POST['opinionstage_allow_tracking']) && $_POST['opinionstage_allow_tracking'] == 'yes'){
7
  update_option('oswp_tracking_user_site_data', 'yes');
8
  }else{
admin/views/view_my_items.php CHANGED
@@ -2,7 +2,6 @@
2
  // block direct access to plugin PHP files:
3
  defined( 'ABSPATH' ) or die(1); ?>
4
 
5
- <!-- <div class="wrap"> -->
6
  <div id="opinionstage-content">
7
  <div class="opinionstage-header-wrapper">
8
  <?php if ( $os_client_logged_in ) { ?>
@@ -48,12 +47,12 @@ defined( 'ABSPATH' ) or die(1); ?>
48
  </div>
49
  <p class="result_progress" style="display: block; font-size: 16px; text-align: center;">Loading...</p>
50
  <table id="check"></table>
 
51
  <div id="loadMore" class="btn btn_aqua btn_full-width" style="display: none;">Click for more</div>
52
  <div id="showLess" style="display: none;">Show less</div>
53
  </div>
54
  </div>
55
  </div>
56
- <!-- </div> -->
57
  <script type="text/javascript">
58
  jQuery(document).ready(function($){
59
  $.ajax({
@@ -86,7 +85,7 @@ defined( 'ABSPATH' ) or die(1); ?>
86
  var previewBlockOsView = dropdownOptions.data[i].attributes['landing-page-url'];
87
  var previewBlockOsEdit = dropdownOptions.data[i].attributes['edit-url'];
88
  var previewBlockOsStatistics = dropdownOptions.data[i].attributes['stats-url'];
89
- var viewtext = '<tbody id="count"><tr class="settingBorderOs"><td class="image"><div class="content-item-image quiz"><img height="90" src="'+previewBlockOsImageUrl+'" width="120"><div class="content-item-label">'+previewBlockOsType+'</div></div></td><td class="long"><div style="position: relative;height: 85px;"><a href="'+previewBlockOsEdit+'" class="opinionstage-item-title" target="_blank">'+previewBlockOsTitle+'</a><table><tbody><tr><td><span class="os-icon-plugin icon-os-common-date"></span><div class="label">'+previewBlockOsDate+'</div></td></tr></tbody></table></div></td><td class="action"><div class="opinionstage-item-action-container"><a href="'+previewBlockOsView+'" class="opinionstage-blue-bordered-btn opinionstage-edit-content " target="_blank"> View </a><a href="'+previewBlockOsEdit+'" class="opinionstage-blue-bordered-btn opinionstage-edit-content " target="_blank"> Edit </a><a href="'+previewBlockOsStatistics+'" class="opinionstage-blue-bordered-btn opinionstage-edit-content " target="_blank"> Statistics </div></a></td></tr></tbody>';
90
  $('.result_progress').css('display', 'none');
91
  $(viewtext).appendTo('#container table#check');
92
  }
@@ -94,28 +93,10 @@ defined( 'ABSPATH' ) or die(1); ?>
94
  },
95
  complete: function(data) {
96
  size_li = $("table#check tbody#count").size();
97
- if(dropdownOptions.data.length == size_li){
98
- setTimeout(function(){$('#showLess').trigger('click');},500);
99
- }
100
- // Show the div in 5s
101
- var countItemOS = 10;
102
- if(dropdownOptions.data.length > countItemOS){
103
- $("#loadMore").delay(2000).fadeIn(500);
104
- }
105
- x=10;
106
- $('table#check ttbody#count:lt('+x+')').show();
107
- $('#loadMore').click(function () {
108
- x= (x+10 <= size_li) ? x+10 : size_li;
109
- $('table#check tbody#count:lt('+x+')').show(500);
110
- if(size_li == x){
111
- $("#loadMore").hide(500);
112
- }
113
- });
114
- $('#showLess').live( 'click', function () {
115
- x=(x-0<0) ? 10 : x-0;
116
- $('table#check tbody#count').not(':lt('+x+')').hide();
117
- });
118
 
 
 
119
  var data = {
120
  'action': 'opinionstage_ajax_item_count',
121
  'oswp_item_count' : dropdownOptions.data.length
@@ -123,23 +104,37 @@ defined( 'ABSPATH' ) or die(1); ?>
123
 
124
  jQuery.post(ajaxurl, data, function(response) {
125
  if(response){
126
- // console.log(response);
127
  }
128
  });
129
 
130
  jQuery('#itemList').on('change', function() {
131
  var selectedValue = this.value;
132
  var contentLabel = jQuery(".content-item-label");
 
133
 
 
134
  contentLabel.each(function() {
 
135
  if(selectedValue != 'all' && selectedValue != jQuery( this ).text().toLowerCase()){
136
- jQuery( this ).parent().parent().parent().parent().css('display', 'none');
 
137
  }
138
  else {
139
  jQuery("#searchItem").val('');
140
- jQuery( this ).parent().parent().parent().parent().css('display', 'table-row-group');
 
 
141
  }
142
  });
 
 
 
 
 
 
 
 
143
  });
144
 
145
  $("#searchItem").on("keyup",function search(e) {
@@ -151,22 +146,26 @@ defined( 'ABSPATH' ) or die(1); ?>
151
 
152
  listTitle.each(function() {
153
  var title = jQuery( this ).text().toLowerCase();
 
 
154
  if ( dropdownValue == 'all' ) {
155
  if(!title.includes(searchItem)) {
156
- jQuery( this ).parent().parent().parent().parent().css('display', 'none');
157
  }
158
  else {
159
- jQuery( this ).parent().parent().parent().parent().css('display', 'table-row-group');
160
  }
161
  }
162
  else {
163
  contentList.each(function() {
164
  if(dropdownValue == jQuery( this ).text().toLowerCase()){
165
- if(!title.includes(searchItem)) {
166
- jQuery( this ).parent().parent().parent().parent().css('display', 'none');
167
- }
168
- else {
169
- jQuery( this ).parent().parent().parent().parent().css('display', 'table-row-group');
 
 
170
  }
171
  }
172
  });
@@ -180,5 +179,45 @@ defined( 'ABSPATH' ) or die(1); ?>
180
  }
181
  });
182
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  });
184
  </script>
2
  // block direct access to plugin PHP files:
3
  defined( 'ABSPATH' ) or die(1); ?>
4
 
 
5
  <div id="opinionstage-content">
6
  <div class="opinionstage-header-wrapper">
7
  <?php if ( $os_client_logged_in ) { ?>
47
  </div>
48
  <p class="result_progress" style="display: block; font-size: 16px; text-align: center;">Loading...</p>
49
  <table id="check"></table>
50
+ <p class="no_item" style="display: none; font-size: 15px; text-align: center;">No items found</p>
51
  <div id="loadMore" class="btn btn_aqua btn_full-width" style="display: none;">Click for more</div>
52
  <div id="showLess" style="display: none;">Show less</div>
53
  </div>
54
  </div>
55
  </div>
 
56
  <script type="text/javascript">
57
  jQuery(document).ready(function($){
58
  $.ajax({
85
  var previewBlockOsView = dropdownOptions.data[i].attributes['landing-page-url'];
86
  var previewBlockOsEdit = dropdownOptions.data[i].attributes['edit-url'];
87
  var previewBlockOsStatistics = dropdownOptions.data[i].attributes['stats-url'];
88
+ var viewtext = '<tbody id="count"><tr class="settingBorderOs"><td class="image"><a href="'+previewBlockOsView+'" target="_blank"><div class="content-item-image quiz"><img height="90" src="'+previewBlockOsImageUrl+'" width="120"><div class="content-item-label">'+previewBlockOsType+'</div></div></a></td><td class="long"><div style="position: relative;height: 85px;"><a href="'+previewBlockOsEdit+'" class="opinionstage-item-title" target="_blank">'+previewBlockOsTitle+'</a><table><tbody><tr><td><span class="os-icon-plugin icon-os-common-date"></span><div class="label">'+previewBlockOsDate+'</div></td></tr></tbody></table></div></td><td class="action"><div class="opinionstage-item-action-container"><a href="'+previewBlockOsView+'" class="opinionstage-blue-bordered-btn opinionstage-edit-content " target="_blank"> View </a><a href="'+previewBlockOsEdit+'" class="opinionstage-blue-bordered-btn opinionstage-edit-content " target="_blank"> Edit </a><a href="'+previewBlockOsStatistics+'" class="opinionstage-blue-bordered-btn opinionstage-edit-content " target="_blank"> Statistics </div></a></td></tr></tbody>';
89
  $('.result_progress').css('display', 'none');
90
  $(viewtext).appendTo('#container table#check');
91
  }
93
  },
94
  complete: function(data) {
95
  size_li = $("table#check tbody#count").size();
96
+ dropdownDataLength = dropdownOptions.data.length;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
+ console.log(size_li + '' + dropdownDataLength);
99
+ loadMore(size_li, dropdownDataLength, "all");
100
  var data = {
101
  'action': 'opinionstage_ajax_item_count',
102
  'oswp_item_count' : dropdownOptions.data.length
104
 
105
  jQuery.post(ajaxurl, data, function(response) {
106
  if(response){
107
+
108
  }
109
  });
110
 
111
  jQuery('#itemList').on('change', function() {
112
  var selectedValue = this.value;
113
  var contentLabel = jQuery(".content-item-label");
114
+ var item_count = 0;
115
 
116
+ jQuery('.no_item').css('display', 'none');
117
  contentLabel.each(function() {
118
+ getContainer = jQuery( this ).parent().parent().parent().parent();
119
  if(selectedValue != 'all' && selectedValue != jQuery( this ).text().toLowerCase()){
120
+ getContainer.parent().css('display', 'none');
121
+ getContainer.parent().removeClass('countItem');
122
  }
123
  else {
124
  jQuery("#searchItem").val('');
125
+ getContainer.parent().css('display', 'table-row-group');
126
+ getContainer.parent().addClass('countItem');
127
+ item_count = item_count + 1;
128
  }
129
  });
130
+
131
+ if (item_count == 0) {
132
+ jQuery('.no_item').css('display', 'block');
133
+ }
134
+
135
+ size = $("table#check tbody.countItem").size();
136
+ $("#loadMore").fadeOut(500);
137
+ loadMore(size, item_count, "filter");
138
  });
139
 
140
  $("#searchItem").on("keyup",function search(e) {
146
 
147
  listTitle.each(function() {
148
  var title = jQuery( this ).text().toLowerCase();
149
+ outerContainer = jQuery( this ).parent().parent().parent().parent();
150
+
151
  if ( dropdownValue == 'all' ) {
152
  if(!title.includes(searchItem)) {
153
+ outerContainer.css('display', 'none');
154
  }
155
  else {
156
+ outerContainer.css('display', 'table-row-group');
157
  }
158
  }
159
  else {
160
  contentList.each(function() {
161
  if(dropdownValue == jQuery( this ).text().toLowerCase()){
162
+ if (outerContainer.hasClass('countItem')) {
163
+ if(!title.includes(searchItem)) {
164
+ outerContainer.css('display', 'none');
165
+ }
166
+ else {
167
+ outerContainer.css('display', 'table-row-group');
168
+ }
169
  }
170
  }
171
  });
179
  }
180
  });
181
 
182
+
183
+ function loadMore(size, dataLength, item) {
184
+ if(dataLength == size && dataLength > 10){
185
+ setTimeout(function(){$('#showLess').trigger('click');},500);
186
+ }
187
+ // Show the div in 5s
188
+ console.log(dataLength + ' ' + size + ' ' + item);
189
+ var countItemOS = 10;
190
+ if(dataLength > countItemOS){
191
+ $("#loadMore").delay(2000).fadeIn(500);
192
+ }
193
+
194
+ x=10;
195
+ $('table#check ttbody#count:lt('+x+')').show();
196
+ $('#loadMore').click(function () {
197
+ x= (x+10 <= size) ? x+10 : size;
198
+
199
+ if (item == 'all') {
200
+ $('table#check tbody#count:lt('+x+')').show(500);
201
+ }
202
+ else {
203
+ $('table#check tbody#countItem:lt('+x+')').show(500);
204
+ }
205
+
206
+ if(size == x){
207
+ $("#loadMore").hide(500);
208
+ }
209
+ });
210
+ $('#showLess').live( 'click', function () {
211
+ console.log(x);
212
+ x=(x-0<0) ? 10 : x-0;
213
+ console.log(x);
214
+ if (item == 'all') {
215
+ $('table#check tbody#count').not(':lt('+x+')').hide();
216
+ }
217
+ else {
218
+ $('table#check tbody#countItem').not(':lt('+x+')').hide();
219
+ }
220
+ });
221
+ }
222
  });
223
  </script>
gutenberg/.editorconfig CHANGED
@@ -1,21 +1,21 @@
1
- # This file is for unifying the coding style for different editors and IDEs
2
- # editorconfig.org
3
-
4
- # WordPress Coding Standards
5
- # https://make.wordpress.org/core/handbook/coding-standards/
6
-
7
- root = true
8
-
9
- [*]
10
- charset = utf-8
11
- end_of_line = lf
12
- insert_final_newline = true
13
- trim_trailing_whitespace = true
14
- indent_style = tab
15
-
16
- [*.yml]
17
- indent_style = space
18
- indent_size = 2
19
-
20
- [*.md]
21
- trim_trailing_whitespace = false
1
+ # This file is for unifying the coding style for different editors and IDEs
2
+ # editorconfig.org
3
+
4
+ # WordPress Coding Standards
5
+ # https://make.wordpress.org/core/handbook/coding-standards/
6
+
7
+ root = true
8
+
9
+ [*]
10
+ charset = utf-8
11
+ end_of_line = lf
12
+ insert_final_newline = true
13
+ trim_trailing_whitespace = true
14
+ indent_style = tab
15
+
16
+ [*.yml]
17
+ indent_style = space
18
+ indent_size = 2
19
+
20
+ [*.md]
21
+ trim_trailing_whitespace = false
gutenberg/.eslintignore CHANGED
@@ -1,9 +1,9 @@
1
- **/*.min.js
2
- **/*.build.js
3
- **/node_modules/**
4
- **/vendor/**
5
- build
6
- coverage
7
- cypress
8
- node_modules
9
- vendor
1
+ **/*.min.js
2
+ **/*.build.js
3
+ **/node_modules/**
4
+ **/vendor/**
5
+ build
6
+ coverage
7
+ cypress
8
+ node_modules
9
+ vendor
gutenberg/.eslintrc.json CHANGED
@@ -1,192 +1,192 @@
1
- {
2
- "root": true,
3
- "parser": "babel-eslint",
4
- "extends": [
5
- "wordpress",
6
- "plugin:react/recommended",
7
- "plugin:jsx-a11y/recommended",
8
- "plugin:jest/recommended"
9
- ],
10
- "env": {
11
- "browser": false,
12
- "es6": true,
13
- "node": true,
14
- "mocha": true,
15
- "jest/globals": true
16
- },
17
- "parserOptions": {
18
- "sourceType": "module",
19
- "ecmaFeatures": {
20
- "jsx": true
21
- }
22
- },
23
- "globals": {
24
- "wp": true,
25
- "wpApiSettings": true,
26
- "window": true,
27
- "document": true
28
- },
29
- "plugins": ["react", "jsx-a11y", "jest"],
30
- "settings": {
31
- "react": {
32
- "pragma": "wp"
33
- }
34
- },
35
- "rules": {
36
- "array-bracket-spacing": ["error", "always"],
37
- "brace-style": ["error", "1tbs"],
38
- "camelcase": ["error", { "properties": "never" }],
39
- "comma-dangle": ["error", "always-multiline"],
40
- "comma-spacing": "error",
41
- "comma-style": "error",
42
- "computed-property-spacing": ["error", "always"],
43
- "constructor-super": "error",
44
- "dot-notation": "error",
45
- "eol-last": "error",
46
- "eqeqeq": "error",
47
- "func-call-spacing": "error",
48
- "indent": ["error", "tab", { "SwitchCase": 1 }],
49
- "jsx-a11y/label-has-for": [
50
- "error",
51
- {
52
- "required": "id"
53
- }
54
- ],
55
- "jsx-a11y/media-has-caption": "off",
56
- "jsx-a11y/no-noninteractive-tabindex": "off",
57
- "jsx-a11y/role-has-required-aria-props": "off",
58
- "jsx-quotes": "error",
59
- "key-spacing": "error",
60
- "keyword-spacing": "error",
61
- "lines-around-comment": "off",
62
- "no-alert": "error",
63
- "no-bitwise": "error",
64
- "no-caller": "error",
65
- "no-console": "error",
66
- "no-const-assign": "error",
67
- "no-debugger": "error",
68
- "no-dupe-args": "error",
69
- "no-dupe-class-members": "error",
70
- "no-dupe-keys": "error",
71
- "no-duplicate-case": "error",
72
- "no-duplicate-imports": "error",
73
- "no-else-return": "error",
74
- "no-eval": "error",
75
- "no-extra-semi": "error",
76
- "no-fallthrough": "error",
77
- "no-lonely-if": "error",
78
- "no-mixed-operators": "error",
79
- "no-mixed-spaces-and-tabs": "error",
80
- "no-multiple-empty-lines": ["error", { "max": 1 }],
81
- "no-multi-spaces": "error",
82
- "no-multi-str": "off",
83
- "no-negated-in-lhs": "error",
84
- "no-nested-ternary": "error",
85
- "no-redeclare": "error",
86
- "no-restricted-syntax": [
87
- "error",
88
- {
89
- "selector":
90
- "ImportDeclaration[source.value=/^@wordpress\\u002F.+\\u002F/]",
91
- "message": "Path access on WordPress dependencies is not allowed."
92
- },
93
- {
94
- "selector": "ImportDeclaration[source.value=/^blocks$/]",
95
- "message": "Use @wordpress/blocks as import path instead."
96
- },
97
- {
98
- "selector": "ImportDeclaration[source.value=/^components$/]",
99
- "message": "Use @wordpress/components as import path instead."
100
- },
101
- {
102
- "selector": "ImportDeclaration[source.value=/^date$/]",
103
- "message": "Use @wordpress/date as import path instead."
104
- },
105
- {
106
- "selector": "ImportDeclaration[source.value=/^editor$/]",
107
- "message": "Use @wordpress/editor as import path instead."
108
- },
109
- {
110
- "selector": "ImportDeclaration[source.value=/^element$/]",
111
- "message": "Use @wordpress/element as import path instead."
112
- },
113
- {
114
- "selector": "ImportDeclaration[source.value=/^i18n$/]",
115
- "message": "Use @wordpress/i18n as import path instead."
116
- },
117
- {
118
- "selector": "ImportDeclaration[source.value=/^data$/]",
119
- "message": "Use @wordpress/data as import path instead."
120
- },
121
- {
122
- "selector": "ImportDeclaration[source.value=/^utils$/]",
123
- "message": "Use @wordpress/utils as import path instead."
124
- },
125
- {
126
- "selector":
127
- "CallExpression[callee.name=/^__|_n|_x$/]:not([arguments.0.type=/^Literal|BinaryExpression$/])",
128
- "message": "Translate function arguments must be string literals."
129
- },
130
- {
131
- "selector":
132
- "CallExpression[callee.name=/^_n|_x$/]:not([arguments.1.type=/^Literal|BinaryExpression$/])",
133
- "message": "Translate function arguments must be string literals."
134
- },
135
- {
136
- "selector":
137
- "CallExpression[callee.name=_nx]:not([arguments.2.type=/^Literal|BinaryExpression$/])",
138
- "message": "Translate function arguments must be string literals."
139
- }
140
- ],
141
- "no-shadow": "error",
142
- "no-undef": "error",
143
- "no-undef-init": "error",
144
- "no-unreachable": "error",
145
- "no-unsafe-negation": "error",
146
- "no-unused-expressions": "error",
147
- "no-unused-vars": "error",
148
- "no-useless-computed-key": "error",
149
- "no-useless-constructor": "error",
150
- "no-useless-return": "error",
151
- "no-var": "error",
152
- "no-whitespace-before-property": "error",
153
- "object-curly-spacing": ["error", "always"],
154
- "padded-blocks": ["error", "never"],
155
- "prefer-const": "error",
156
- "quote-props": ["error", "as-needed"],
157
- "react/display-name": "off",
158
- "react/jsx-curly-spacing": [
159
- "error",
160
- {
161
- "when": "always",
162
- "children": true
163
- }
164
- ],
165
- "react/jsx-equals-spacing": "error",
166
- "react/jsx-indent": ["error", "tab"],
167
- "react/jsx-indent-props": ["error", "tab"],
168
- "react/jsx-key": "error",
169
- "react/jsx-tag-spacing": "error",
170
- "react/no-children-prop": "off",
171
- "react/no-find-dom-node": "warn",
172
- "react/prop-types": "off",
173
- "semi": "error",
174
- "semi-spacing": "error",
175
- "space-before-blocks": ["error", "always"],
176
- "space-before-function-paren": ["error", "never"],
177
- "space-in-parens": ["error", "always"],
178
- "space-infix-ops": ["error", { "int32Hint": false }],
179
- "space-unary-ops": [
180
- "error",
181
- {
182
- "overrides": {
183
- "!": true
184
- }
185
- }
186
- ],
187
- "template-curly-spacing": ["error", "always"],
188
- "valid-jsdoc": ["error", { "requireReturn": false }],
189
- "valid-typeof": "error",
190
- "yoda": "off"
191
- }
192
- }
1
+ {
2
+ "root": true,
3
+ "parser": "babel-eslint",
4
+ "extends": [
5
+ "wordpress",
6
+ "plugin:react/recommended",
7
+ "plugin:jsx-a11y/recommended",
8
+ "plugin:jest/recommended"
9
+ ],
10
+ "env": {
11
+ "browser": false,
12
+ "es6": true,
13
+ "node": true,
14
+ "mocha": true,
15
+ "jest/globals": true
16
+ },
17
+ "parserOptions": {
18
+ "sourceType": "module",
19
+ "ecmaFeatures": {
20
+ "jsx": true
21
+ }
22
+ },
23
+ "globals": {
24
+ "wp": true,
25
+ "wpApiSettings": true,
26
+ "window": true,
27
+ "document": true
28
+ },
29
+ "plugins": ["react", "jsx-a11y", "jest"],
30
+ "settings": {
31
+ "react": {
32
+ "pragma": "wp"
33
+ }
34
+ },
35
+ "rules": {
36
+ "array-bracket-spacing": ["error", "always"],
37
+ "brace-style": ["error", "1tbs"],
38
+ "camelcase": ["error", { "properties": "never" }],
39
+ "comma-dangle": ["error", "always-multiline"],
40
+ "comma-spacing": "error",
41
+ "comma-style": "error",
42
+ "computed-property-spacing": ["error", "always"],
43
+ "constructor-super": "error",
44
+ "dot-notation": "error",
45
+ "eol-last": "error",
46
+ "eqeqeq": "error",
47
+ "func-call-spacing": "error",
48
+ "indent": ["error", "tab", { "SwitchCase": 1 }],
49
+ "jsx-a11y/label-has-for": [
50
+ "error",
51
+ {
52
+ "required": "id"
53
+ }
54
+ ],
55
+ "jsx-a11y/media-has-caption": "off",
56
+ "jsx-a11y/no-noninteractive-tabindex": "off",
57
+ "jsx-a11y/role-has-required-aria-props": "off",
58
+ "jsx-quotes": "error",
59
+ "key-spacing": "error",
60
+ "keyword-spacing": "error",
61
+ "lines-around-comment": "off",
62
+ "no-alert": "error",
63
+ "no-bitwise": "error",
64
+ "no-caller": "error",
65
+ "no-console": "error",
66
+ "no-const-assign": "error",
67
+ "no-debugger": "error",
68
+ "no-dupe-args": "error",
69
+ "no-dupe-class-members": "error",
70
+ "no-dupe-keys": "error",
71
+ "no-duplicate-case": "error",
72
+ "no-duplicate-imports": "error",
73
+ "no-else-return": "error",
74
+ "no-eval": "error",
75
+ "no-extra-semi": "error",
76
+ "no-fallthrough": "error",
77
+ "no-lonely-if": "error",
78
+ "no-mixed-operators": "error",
79
+ "no-mixed-spaces-and-tabs": "error",
80
+ "no-multiple-empty-lines": ["error", { "max": 1 }],
81
+ "no-multi-spaces": "error",
82
+ "no-multi-str": "off",
83
+ "no-negated-in-lhs": "error",
84
+ "no-nested-ternary": "error",
85
+ "no-redeclare": "error",
86
+ "no-restricted-syntax": [
87
+ "error",
88
+ {
89
+ "selector":
90
+ "ImportDeclaration[source.value=/^@wordpress\\u002F.+\\u002F/]",
91
+ "message": "Path access on WordPress dependencies is not allowed."
92
+ },
93
+ {
94
+ "selector": "ImportDeclaration[source.value=/^blocks$/]",
95
+ "message": "Use @wordpress/blocks as import path instead."
96
+ },
97
+ {
98
+ "selector": "ImportDeclaration[source.value=/^components$/]",
99
+ "message": "Use @wordpress/components as import path instead."
100
+ },
101
+ {
102
+ "selector": "ImportDeclaration[source.value=/^date$/]",
103
+ "message": "Use @wordpress/date as import path instead."
104
+ },
105
+ {
106
+ "selector": "ImportDeclaration[source.value=/^editor$/]",
107
+ "message": "Use @wordpress/editor as import path instead."
108
+ },
109
+ {
110
+ "selector": "ImportDeclaration[source.value=/^element$/]",
111
+ "message": "Use @wordpress/element as import path instead."
112
+ },
113
+ {
114
+ "selector": "ImportDeclaration[source.value=/^i18n$/]",
115
+ "message": "Use @wordpress/i18n as import path instead."
116
+ },
117
+ {
118
+ "selector": "ImportDeclaration[source.value=/^data$/]",
119
+ "message": "Use @wordpress/data as import path instead."
120
+ },
121
+ {
122
+ "selector": "ImportDeclaration[source.value=/^utils$/]",
123
+ "message": "Use @wordpress/utils as import path instead."
124
+ },
125
+ {
126
+ "selector":
127
+ "CallExpression[callee.name=/^__|_n|_x$/]:not([arguments.0.type=/^Literal|BinaryExpression$/])",
128
+ "message": "Translate function arguments must be string literals."
129
+ },
130
+ {
131
+ "selector":
132
+ "CallExpression[callee.name=/^_n|_x$/]:not([arguments.1.type=/^Literal|BinaryExpression$/])",
133
+ "message": "Translate function arguments must be string literals."
134
+ },
135
+ {
136
+ "selector":
137
+ "CallExpression[callee.name=_nx]:not([arguments.2.type=/^Literal|BinaryExpression$/])",
138
+ "message": "Translate function arguments must be string literals."
139
+ }
140
+ ],
141
+ "no-shadow": "error",
142
+ "no-undef": "error",
143
+ "no-undef-init": "error",
144
+ "no-unreachable": "error",
145
+ "no-unsafe-negation": "error",
146
+ "no-unused-expressions": "error",
147
+ "no-unused-vars": "error",
148
+ "no-useless-computed-key": "error",
149
+ "no-useless-constructor": "error",
150
+ "no-useless-return": "error",
151
+ "no-var": "error",
152
+ "no-whitespace-before-property": "error",
153
+ "object-curly-spacing": ["error", "always"],
154
+ "padded-blocks": ["error", "never"],
155
+ "prefer-const": "error",
156
+ "quote-props": ["error", "as-needed"],
157
+ "react/display-name": "off",
158
+ "react/jsx-curly-spacing": [
159
+ "error",
160
+ {
161
+ "when": "always",
162
+ "children": true
163
+ }
164
+ ],
165
+ "react/jsx-equals-spacing": "error",
166
+ "react/jsx-indent": ["error", "tab"],
167
+ "react/jsx-indent-props": ["error", "tab"],
168
+ "react/jsx-key": "error",
169
+ "react/jsx-tag-spacing": "error",
170
+ "react/no-children-prop": "off",
171
+ "react/no-find-dom-node": "warn",
172
+ "react/prop-types": "off",
173
+ "semi": "error",
174
+ "semi-spacing": "error",
175
+ "space-before-blocks": ["error", "always"],
176
+ "space-before-function-paren": ["error", "never"],
177
+ "space-in-parens": ["error", "always"],
178
+ "space-infix-ops": ["error", { "int32Hint": false }],
179
+ "space-unary-ops": [
180
+ "error",
181
+ {
182
+ "overrides": {
183
+ "!": true
184
+ }
185
+ }
186
+ ],
187
+ "template-curly-spacing": ["error", "always"],
188
+ "valid-jsdoc": ["error", { "requireReturn": false }],
189
+ "valid-typeof": "error",
190
+ "yoda": "off"
191
+ }
192
+ }
gutenberg/.gitignore CHANGED
@@ -1,85 +1,85 @@
1
- # Packages #
2
- ############
3
- *.7z
4
- *.dmg
5
- *.gz
6
- *.bz2
7
- *.iso
8
- *.jar
9
- *.rar
10
- *.tar
11
- *.zip
12
- *.tgz
13
- *.map
14
-
15
- # Logs and databases #
16
- ######################
17
- *.log
18
- *.sql
19
-
20
- # OS generated files #
21
- ######################
22
- **.DS_Store*
23
- ehthumbs.db
24
- Icon?
25
- Thumbs.db
26
- ._*
27
-
28
- # Vim generated files #
29
- ######################
30
- *.un~
31
-
32
- # SASS #
33
- ##########
34
- **/.sass-cache
35
- **/.sass-cache/*
36
- **/.map
37
-
38
- # Composer #
39
- ##########
40
- vendors/composer/
41
- !assets/js/vendor/
42
- wpcs/
43
- composer.lock
44
-
45
- # Bower #
46
- ##########
47
- assets/bower_components/*
48
-
49
- # Codekit #
50
- ##########
51
- /codekit-config.json
52
- *.codekit
53
- **.codekit-cache/*
54
-
55
- # NPM #
56
- ##########
57
- node_modules
58
- **/node_modules/**
59
-
60
- # Compiled Files and Build Dirs #
61
- ##########
62
- /README.html
63
-
64
- # PhpStrom Project Files #
65
- .idea/
66
- library/vendors/composer
67
- assets/img/.DS_Store
68
- assets/sass/HTML
69
- assets/sass/Rails
70
- HTML
71
- Rails
72
-
73
- # CGB
74
- .idea/
75
- .vscode/
76
- node_modules/
77
- .DS_Store
78
- *.tgz
79
- my-app*
80
- template/src/__tests__/__snapshots__/
81
- lerna-debug.log
82
- npm-debug.log*
83
- yarn-debug.log*
84
- yarn-error.log*
85
  /.changelog
1
+ # Packages #
2
+ ############
3
+ *.7z
4
+ *.dmg
5
+ *.gz
6
+ *.bz2
7
+ *.iso
8
+ *.jar
9
+ *.rar
10
+ *.tar
11
+ *.zip
12
+ *.tgz
13
+ *.map
14
+
15
+ # Logs and databases #
16
+ ######################
17
+ *.log
18
+ *.sql
19
+
20
+ # OS generated files #
21
+ ######################
22
+ **.DS_Store*
23
+ ehthumbs.db
24
+ Icon?
25
+ Thumbs.db
26
+ ._*
27
+
28
+ # Vim generated files #
29
+ ######################
30
+ *.un~
31
+
32
+ # SASS #
33
+ ##########
34
+ **/.sass-cache
35
+ **/.sass-cache/*
36
+ **/.map
37
+
38
+ # Composer #
39
+ ##########
40
+ vendors/composer/
41
+ !assets/js/vendor/
42
+ wpcs/
43
+ composer.lock
44
+
45
+ # Bower #
46
+ ##########
47
+ assets/bower_components/*
48
+
49
+ # Codekit #
50
+ ##########
51
+ /codekit-config.json
52
+ *.codekit
53
+ **.codekit-cache/*
54
+
55
+ # NPM #
56
+ ##########
57
+ node_modules
58
+ **/node_modules/**
59
+
60
+ # Compiled Files and Build Dirs #
61
+ ##########
62
+ /README.html
63
+
64
+ # PhpStrom Project Files #
65
+ .idea/
66
+ library/vendors/composer
67
+ assets/img/.DS_Store
68
+ assets/sass/HTML
69
+ assets/sass/Rails
70
+ HTML
71
+ Rails
72
+
73
+ # CGB
74
+ .idea/
75
+ .vscode/
76
+ node_modules/
77
+ .DS_Store
78
+ *.tgz
79
+ my-app*
80
+ template/src/__tests__/__snapshots__/
81
+ lerna-debug.log
82
+ npm-debug.log*
83
+ yarn-debug.log*
84
+ yarn-error.log*
85
  /.changelog
gutenberg/form/dist/blocks.build.js CHANGED
@@ -1 +1 @@
1
- !function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});n(1)},function(e,t,n){"use strict";function r(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){function r(o,a){try{var i=t[o](a),s=i.value}catch(e){return void n(e)}if(!i.done)return Promise.resolve(s).then(function(e){r("next",e)},function(e){r("throw",e)});e(s)}return r("next")})}}var o,a,i,s,c,l,u=n(2),p=n.n(u),m=n(5),f=(n.n(m),n(6)),d=(n.n(f),wp.i18n.__),h=wp.blocks.registerBlockType,g=wp.components,v=g.SelectControl,b=(g.TextControl,wp.editor.RichText,!1);h("opinion-stage/block-os-form",{title:d("Form"),icon:"editor-justify",category:"opinion-stage",keywords:[d("Opinion Stage Form"),d("Opinion Stage Form")],attributes:{embedUrl:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},oswpUrlShortcode:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},lockEmbed:{source:"attribute",attribute:"data-lock-embed",selector:"div[data-lock-embed]"},buttonText:{source:"attribute",attribute:"data-button-text",selector:"div[data-button-text]"}},edit:function(e){function t(){var t=this,n=osGutenData.OswpPluginVersion,o=osGutenData.OswpClientToken,a=osGutenData.OswpFetchDataUrl+"?type=form&page=1&per_page=99";fetch(a,{method:"GET",headers:{Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json","OSWP-Plugin-Version":n,"OSWP-Client-Token":o}}).then(function(){var n=r(p.a.mark(function n(r){var o;return p.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.json();case 2:o=t.sent,o=o.data,b=o,e.setAttributes({buttonText:"Embed"}),e.setAttributes({buttonText:m}),"Change"==m&&"Select"!=u?e.setAttributes({embedUrl:u}):e.setAttributes({embedUrl:"Select"});case 8:case"end":return t.stop()}},n,t)}));return function(e){return n.apply(this,arguments)}}()).catch(function(e){console.log("ERROR: "+e.message)})}var n=e.attributes,u=n.embedUrl,m=(n.oswpUrlShortcode,n.lockEmbed,n.buttonText),f=(e.setAttributes,function(t){if(""==t)e.setAttributes({embedUrl:""});else if(""!=t){e.setAttributes({embedUrl:t});for(var n=0;n<b.length;n++){var r=function(e){var t=document.createElement("a");return t.href=e,t}(b[n].attributes["landing-page-url"]),l=r.pathname;if(t==l){o=b[n].attributes.title,a=b[n].attributes["image-url"],i=b[n].attributes["landing-page-url"],s=b[n].attributes["edit-url"],c=b[n].attributes["stats-url"];break}}}}),d=function(t){"Embed"==t.target.value?""==u||"Select"==u||"createNew"==u||"refresh"==u?e.setAttributes({lockEmbed:!1,buttonText:"Embed"}):(e.setAttributes({lockEmbed:!0,buttonText:"Change"}),O=wp.element.createElement(v,{id:"selectID",options:l,value:u,onChange:f,className:"components-select-control__input"})):e.setAttributes({lockEmbed:!1,buttonText:"Embed"})};window.verifyOSInsert=function(t){e.setAttributes({oswpUrlShortcode:t});for(var n=document.getElementById("selectID").options,r=0;r<n.length;r++)if(n[r].value==t){n[r].defaultSelected=!0,e.setAttributes({lockEmbed:!0,buttonText:"Change",embedUrl:t});break}};var h=osGutenData.onCreateButtonClickOs+"?w_type=form&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8",g=function(e){window.open(h,"_blank").focus()};m||e.setAttributes({buttonText:"Embed"});var w=osGutenData.callbackUrlOs,y=w,E=(osGutenData.getActionUrlOS,osGutenData.getLogoImageLink),k=function(e){window.location.replace(y)};if(""==osGutenData.isOsConnected)return $(document).ready(function(){$("span#oswpLauncherContentPopupform , #owspLaunchInputCreate").live("click",function(e){e.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500)})}),wp.element.createElement("div",{className:e.className},wp.element.createElement("div",{className:"os-form-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:E,alt:""})),wp.element.createElement("p",{className:"components-heading"},"Please connect WordPress to Opinion Stage to start adding forms"),wp.element.createElement("button",{className:"components-button is-button is-default is-block is-primary",onClick:k},"Connect")),wp.element.createElement("span",null));if(0==b)l=[{value:"Select",label:"Select a form"},{value:"refresh",label:"Refresh"}],t();else{l=[{value:"Select",label:"Select a form"},{value:"refresh",label:"Refresh"},{value:"",label:"-----------------"}];for(var x=0;x<b.length;x++){l[l.length]={value:b[x].attributes["landing-page-url"].replace("https://www.opinionstage.com",""),label:b[x].attributes.title};var _=function(e){var t=document.createElement("a");return t.href=e,t}(b[x].attributes["landing-page-url"]),N=_.pathname;if(u==N){o=b[x].attributes.title,a=b[x].attributes["image-url"],i=b[x].attributes["landing-page-url"],s=b[x].attributes["edit-url"],c=b[x].attributes["stats-url"];var L=b[x].id}}}"refresh"==u&&t();var O=wp.element.createElement(v,{id:"selectID",options:l,value:u,onChange:f,className:"components-select-control__input"});$(document).ready(function(){$("span#oswpLauncherContentPopupform").live("click",function(e){console.log("oswpLauncherContentPopupform"),e.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500);var t=$(this).attr("data-os-block");$("button#dropbtn span").text(t);for(var n=$(".filter__itm"),r=0;r<n.length;r++){if($(n[r]).text()==t){setTimeout(function(){$(n[r]).trigger("click")},1e3),setTimeout(function(){$(".progress_message").css("display","none"),$(".content__list").css("display","block")},2500),$("button.content__links-itm").live("click",function(e){$(".tingle-modal.opinionstage-content-popup").hide(),$(".tingle-modal.opinionstage-content-popup.tingle-modal--visible").hide()});break}$(".progress_message").css("display","block"),$(".content__list").css("display","none"),console.log("test")}})});var S=wp.element.createElement("div",{className:"os-form-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:E,alt:""})),wp.element.createElement("span",{id:"oswpLauncherContentPopupform",className:"components-button is-button is-default is-block is-primary","data-opinionstage-content-launch":!0,"data-os-block":"form"},"Select a Form"),wp.element.createElement("input",{type:"button",value:"Create a New Form",className:"components-button is-button is-default is-block is-primary",onClick:g}),wp.element.createElement("div",{className:"components-placeholder__fieldset"},O,wp.element.createElement("input",{type:"button",value:m,className:"components-button is-button is-default is-large",id:"clickMe",onClick:d})));return function(e,t,n){var r,o=e.getElementsByTagName(t)[0],a=Math.floor((new Date).getTime()/1e6);e.getElementById(n)||(r=e.createElement(t),r.id=n,r.async=1,r.src="https://www.opinionstage.com/assets/loader.js?"+a,o.parentNode.insertBefore(r,o))}(document,"script","os-widget-jssdk"),L="os-widget-"+L,""!=u&&"Select"!=u&&u?"Embed"==m||"Change"==m&&(S=wp.element.createElement("div",{className:"os-form-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:E,alt:""})),wp.element.createElement("div",{className:"components-preview__block"},wp.element.createElement("div",{className:"components-preview__leftBlockImage"},wp.element.createElement("img",{src:a,alt:o,className:"image"}),wp.element.createElement("div",{className:"overlay"},wp.element.createElement("div",{className:"text"},wp.element.createElement("a",{href:i,target:"_blank"}," View "),wp.element.createElement("a",{href:s,target:"_blank"}," Edit "),wp.element.createElement("a",{href:c,target:"_blank"}," Statistics "),wp.element.createElement("input",{type:"button",value:m,className:"components-button is-button is-default is-large left-align",onClick:d})))),wp.element.createElement("div",{className:"components-preview__rightBlockContent"},wp.element.createElement("div",{className:"components-placeholder__label"},"Form: ",o)))),O=wp.element.createElement(v,{id:"selectID",options:l,value:u,disabled:!0,onChange:f,className:"components-select-control__input"})):"Select"==u||""==u||"refresh"==u||e.setAttributes({buttonText:"Embed"}),wp.element.createElement("div",{className:e.className},S)},save:function(e){var t=e.attributes,n=(t.embedUrl,t.oswpUrlShortcode),r=t.lockEmbed,o=t.buttonText;return wp.element.createElement("div",{class:"os-form-wrapper","data-type":"form","data-test-url":n,"data-lock-embed":r,"data-button-text":o},'[os-widget path="',n,'"]')}})},function(e,t,n){e.exports=n(3)},function(e,t,n){var r=function(){return this}()||Function("return this")(),o=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,a=o&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,e.exports=n(4),o)r.regeneratorRuntime=a;else try{delete r.regeneratorRuntime}catch(e){r.regeneratorRuntime=void 0}},function(e,t){!function(t){"use strict";function n(e,t,n,r){var a=t&&t.prototype instanceof o?t:o,i=Object.create(a.prototype),s=new f(r||[]);return i._invoke=l(e,n,s),i}function r(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}function o(){}function a(){}function i(){}function s(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function c(e){function t(n,o,a,i){var s=r(e[n],e,o);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"===typeof l&&b.call(l,"__await")?Promise.resolve(l.__await).then(function(e){t("next",e,a,i)},function(e){t("throw",e,a,i)}):Promise.resolve(l).then(function(e){c.value=e,a(c)},i)}i(s.arg)}function n(e,n){function r(){return new Promise(function(r,o){t(e,n,r,o)})}return o=o?o.then(r,r):r()}var o;this._invoke=n}function l(e,t,n){var o=N;return function(a,i){if(o===O)throw new Error("Generator is already running");if(o===S){if("throw"===a)throw i;return h()}for(n.method=a,n.arg=i;;){var s=n.delegate;if(s){var c=u(s,n);if(c){if(c===T)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===N)throw o=S,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=O;var l=r(e,t,n);if("normal"===l.type){if(o=n.done?S:L,l.arg===T)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=S,n.method="throw",n.arg=l.arg)}}}function u(e,t){var n=e.iterator[t.method];if(n===g){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=g,u(e,t),"throw"===t.method))return T;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return T}var o=r(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,T;var a=o.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=g),t.delegate=null,T):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,T)}function p(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function m(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function f(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(p,this),this.reset(!0)}function d(e){if(e){var t=e[y];if(t)return t.call(e);if("function"===typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(b.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=g,t.done=!0,t};return r.next=r}}return{next:h}}function h(){return{value:g,done:!0}}var g,v=Object.prototype,b=v.hasOwnProperty,w="function"===typeof Symbol?Symbol:{},y=w.iterator||"@@iterator",E=w.asyncIterator||"@@asyncIterator",k=w.toStringTag||"@@toStringTag",x="object"===typeof e,_=t.regeneratorRuntime;if(_)return void(x&&(e.exports=_));_=t.regeneratorRuntime=x?e.exports:{},_.wrap=n;var N="suspendedStart",L="suspendedYield",O="executing",S="completed",T={},C={};C[y]=function(){return this};var P=Object.getPrototypeOf,j=P&&P(P(d([])));j&&j!==v&&b.call(j,y)&&(C=j);var A=i.prototype=o.prototype=Object.create(C);a.prototype=A.constructor=i,i.constructor=a,i[k]=a.displayName="GeneratorFunction",_.isGeneratorFunction=function(e){var t="function"===typeof e&&e.constructor;return!!t&&(t===a||"GeneratorFunction"===(t.displayName||t.name))},_.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,i):(e.__proto__=i,k in e||(e[k]="GeneratorFunction")),e.prototype=Object.create(A),e},_.awrap=function(e){return{__await:e}},s(c.prototype),c.prototype[E]=function(){return this},_.AsyncIterator=c,_.async=function(e,t,r,o){var a=new c(n(e,t,r,o));return _.isGeneratorFunction(t)?a:a.next().then(function(e){return e.done?e.value:a.next()})},s(A),A[k]="Generator",A[y]=function(){return this},A.toString=function(){return"[object Generator]"},_.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},_.values=d,f.prototype={constructor:f,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=g,this.done=!1,this.delegate=null,this.method="next",this.arg=g,this.tryEntries.forEach(m),!e)for(var t in this)"t"===t.charAt(0)&&b.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=g)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){function t(t,r){return a.type="throw",a.arg=e,n.next=t,r&&(n.method="next",n.arg=g),!!r}if(this.done)throw e;for(var n=this,r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var i=b.call(o,"catchLoc"),s=b.call(o,"finallyLoc");if(i&&s){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(i){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&b.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,T):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),T},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),m(n),T}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;m(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:d(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=g),T}}}(function(){return this}()||Function("return this")())},function(e,t){},function(e,t){}]);
1
+ !function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});n(1)},function(t,e,n){"use strict";function r(t){return function(){var e=t.apply(this,arguments);return new Promise(function(t,n){function r(o,i){try{var a=e[o](i),s=a.value}catch(t){return void n(t)}if(!a.done)return Promise.resolve(s).then(function(t){r("next",t)},function(t){r("throw",t)});t(s)}return r("next")})}}var o=n(2),i=n.n(o),a=n(5),s=(n.n(a),n(6)),c=(n.n(s),wp.i18n.__),l=wp.blocks.registerBlockType,u=wp.components,m=(u.SelectControl,u.TextControl,wp.editor.RichText,!1);l("opinion-stage/block-os-form",{title:c("Form"),icon:"editor-justify",category:"opinion-stage",keywords:[c("Opinion Stage Form"),c("Opinion Stage Form")],attributes:{embedUrl:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},lockEmbed:{source:"attribute",attribute:"data-lock-embed",selector:"div[data-lock-embed]"},buttonText:{source:"attribute",attribute:"data-button-text",selector:"div[data-button-text]"},insertItemImage:{source:"attribute",attribute:"data-image-url",selector:"div[data-image-url]"},insertItemOsTitle:{source:"attribute",attribute:"data-title-url",selector:"div[data-title-url]"},insertItemOsView:{source:"attribute",attribute:"data-view-url",selector:"div[data-view-url]"},insertItemOsEdit:{source:"attribute",attribute:"data-edit-url",selector:"div[data-edit-url]"},insertItemOsStatistics:{source:"attribute",attribute:"data-statistics-url",selector:"div[data-statistics-url]"}},edit:function(t){var e=t.attributes,n=e.embedUrl,o=(e.lockEmbed,e.buttonText),a=e.insertItemImage,s=e.insertItemOsTitle,c=e.insertItemOsView,l=e.insertItemOsEdit,u=e.insertItemOsStatistics,p=(t.setAttributes,osGutenData.callbackUrlOs),f=p,d=(osGutenData.getActionUrlOS,osGutenData.getLogoImageLink),h=function(e){window.verifyOSInsert=function(e){var n=this;t.setAttributes({embedUrl:e,buttonText:"Change"});var a=osGutenData.OswpPluginVersion,s=osGutenData.OswpClientToken,c=osGutenData.OswpFetchDataUrl+"?type=form&page=1&per_page=99";fetch(c,{method:"GET",headers:{Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json","OSWP-Plugin-Version":a,"OSWP-Client-Token":s}}).then(function(){var e=r(i.a.mark(function e(r){var a;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.json();case 2:a=e.sent,a=a.data,m=a,t.setAttributes({buttonText:o});case 6:case"end":return e.stop()}},e,n)}));return function(t){return e.apply(this,arguments)}}()).catch(function(t){console.log("ERROR: "+t.message)})}},g=function(e){t.setAttributes({embedUrl:"",buttonText:"Embed",lockEmbed:!1,insertItemImage:!1,insertItemOsTitle:!1,insertItemOsView:!1,insertItemOsEdit:!1,insertItemOsStatistics:!1})},v=function(t){window.location.replace(f)},b=osGutenData.onCreateButtonClickOs+"?w_type=contact_form&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8",w=function(t){window.open(b,"_blank").focus()};if(""==osGutenData.isOsConnected)return wp.element.createElement("div",{className:t.className},wp.element.createElement("div",{className:"os-form-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:d,alt:""})),wp.element.createElement("p",{className:"components-heading"},"Please connect WordPress to Opinion Stage to start adding forms"),wp.element.createElement("button",{className:"components-button is-button is-default is-block is-primary",onClick:v},"Connect")),wp.element.createElement("div",null));if($(document).ready(function(){$("span#oswpLauncherContentPopupform").live("click",function(t){t.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500);var e=$(this).attr("data-os-block");$("button#dropbtn span").text(e);for(var n=$(".filter__itm"),r=0;r<n.length;r++){if($(n[r]).text()==e){setTimeout(function(){$(n[r]).trigger("click")},1e3),setTimeout(function(){$(".progress_message").css("display","none"),$(".content__list").css("display","block")},2500),$("button.content__links-itm").live("click",function(t){$(".tingle-modal.opinionstage-content-popup").hide(),$(".tingle-modal.opinionstage-content-popup.tingle-modal--visible").hide()});break}$(".progress_message").css("display","block"),$(".content__list").css("display","none")}})}),0!=m)for(var y=0;y<m.length;y++){var E=function(t){var e=document.createElement("a");return e.href=t,e}(m[y].attributes["landing-page-url"]),x=E.pathname;if(n==x){t.setAttributes({lockEmbed:!0,buttonText:"Change"}),t.setAttributes({insertItemImage:m[y].attributes["image-url"]}),t.setAttributes({insertItemOsTitle:m[y].attributes.title}),t.setAttributes({insertItemOsView:m[y].attributes["landing-page-url"]}),t.setAttributes({insertItemOsEdit:m[y].attributes["edit-url"]}),t.setAttributes({insertItemOsStatistics:m[y].attributes["stats-url"]});break}}var k=wp.element.createElement("div",{className:"os-form-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:d,alt:""})),wp.element.createElement("span",{id:"oswpLauncherContentPopupform",className:"components-button is-button is-default is-block is-primary","data-opinionstage-content-launch":!0,"data-os-block":"form",onClick:h},"Select a Form"),wp.element.createElement("input",{type:"button",value:"Create a New form",className:"components-button is-button is-default is-block is-primary",onClick:w}),wp.element.createElement("span",null));return""!=n&&n?"Embed"==o||"Change"==o&&(k=wp.element.createElement("div",{className:"os-form-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:d,alt:""})),wp.element.createElement("div",{className:"components-preview__block"},wp.element.createElement("div",{className:"components-preview__leftBlockImage"},wp.element.createElement("img",{src:a,alt:s,className:"image"}),wp.element.createElement("div",{className:"overlay"},wp.element.createElement("div",{className:"text"},wp.element.createElement("a",{href:c,target:"_blank"}," View "),wp.element.createElement("a",{href:l,target:"_blank"}," Edit "),wp.element.createElement("a",{href:u,target:"_blank"}," Statistics "),wp.element.createElement("input",{type:"button",value:o,className:"components-button is-button is-default is-large left-align",onClick:g})))),wp.element.createElement("div",{className:"components-preview__rightBlockContent"},wp.element.createElement("div",{className:"components-placeholder__label"},"Form: ",s))),wp.element.createElement("span",null))):""==n||"undefined"===jQuery.type(n)||t.setAttributes({buttonText:"Embed"}),wp.element.createElement("div",{className:t.className},k,wp.element.createElement("span",null))},save:function(t){var e=t.attributes,n=e.embedUrl,r=e.lockEmbed,o=e.buttonText,i=e.insertItemImage,a=e.insertItemOsTitle,s=e.insertItemOsView,c=e.insertItemOsEdit,l=e.insertItemOsStatistics;return wp.element.createElement("div",{class:"os-form-wrapper","data-type":"form","data-image-url":i,"data-title-url":a,"data-view-url":s,"data-statistics-url":l,"data-edit-url":c,"data-test-url":n,"data-lock-embed":r,"data-button-text":o},'[os-widget path="',n,'"]',wp.element.createElement("span",null))}})},function(t,e,n){t.exports=n(3)},function(t,e,n){var r=function(){return this}()||Function("return this")(),o=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,i=o&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,t.exports=n(4),o)r.regeneratorRuntime=i;else try{delete r.regeneratorRuntime}catch(t){r.regeneratorRuntime=void 0}},function(t,e){!function(e){"use strict";function n(t,e,n,r){var i=e&&e.prototype instanceof o?e:o,a=Object.create(i.prototype),s=new f(r||[]);return a._invoke=l(t,n,s),a}function r(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function o(){}function i(){}function a(){}function s(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function c(t){function e(n,o,i,a){var s=r(t[n],t,o);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"===typeof l&&b.call(l,"__await")?Promise.resolve(l.__await).then(function(t){e("next",t,i,a)},function(t){e("throw",t,i,a)}):Promise.resolve(l).then(function(t){c.value=t,i(c)},a)}a(s.arg)}function n(t,n){function r(){return new Promise(function(r,o){e(t,n,r,o)})}return o=o?o.then(r,r):r()}var o;this._invoke=n}function l(t,e,n){var o=_;return function(i,a){if(o===L)throw new Error("Generator is already running");if(o===N){if("throw"===i)throw a;return h()}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var c=u(s,n);if(c){if(c===T)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===_)throw o=N,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=L;var l=r(t,e,n);if("normal"===l.type){if(o=n.done?N:I,l.arg===T)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=N,n.method="throw",n.arg=l.arg)}}}function u(t,e){var n=t.iterator[e.method];if(n===g){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=g,u(t,e),"throw"===e.method))return T;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return T}var o=r(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,T;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=g),e.delegate=null,T):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,T)}function m(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function p(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function f(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(m,this),this.reset(!0)}function d(t){if(t){var e=t[y];if(e)return e.call(t);if("function"===typeof t.next)return t;if(!isNaN(t.length)){var n=-1,r=function e(){for(;++n<t.length;)if(b.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=g,e.done=!0,e};return r.next=r}}return{next:h}}function h(){return{value:g,done:!0}}var g,v=Object.prototype,b=v.hasOwnProperty,w="function"===typeof Symbol?Symbol:{},y=w.iterator||"@@iterator",E=w.asyncIterator||"@@asyncIterator",x=w.toStringTag||"@@toStringTag",k="object"===typeof t,O=e.regeneratorRuntime;if(O)return void(k&&(t.exports=O));O=e.regeneratorRuntime=k?t.exports:{},O.wrap=n;var _="suspendedStart",I="suspendedYield",L="executing",N="completed",T={},P={};P[y]=function(){return this};var S=Object.getPrototypeOf,j=S&&S(S(d([])));j&&j!==v&&b.call(j,y)&&(P=j);var C=a.prototype=o.prototype=Object.create(P);i.prototype=C.constructor=a,a.constructor=i,a[x]=i.displayName="GeneratorFunction",O.isGeneratorFunction=function(t){var e="function"===typeof t&&t.constructor;return!!e&&(e===i||"GeneratorFunction"===(e.displayName||e.name))},O.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,a):(t.__proto__=a,x in t||(t[x]="GeneratorFunction")),t.prototype=Object.create(C),t},O.awrap=function(t){return{__await:t}},s(c.prototype),c.prototype[E]=function(){return this},O.AsyncIterator=c,O.async=function(t,e,r,o){var i=new c(n(t,e,r,o));return O.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},s(C),C[x]="Generator",C[y]=function(){return this},C.toString=function(){return"[object Generator]"},O.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},O.values=d,f.prototype={constructor:f,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=g,this.done=!1,this.delegate=null,this.method="next",this.arg=g,this.tryEntries.forEach(p),!t)for(var e in this)"t"===e.charAt(0)&&b.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=g)},stop:function(){this.done=!0;var t=this.tryEntries[0],e=t.completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){function e(e,r){return i.type="throw",i.arg=t,n.next=e,r&&(n.method="next",n.arg=g),!!r}if(this.done)throw t;for(var n=this,r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],i=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=b.call(o,"catchLoc"),s=b.call(o,"finallyLoc");if(a&&s){if(this.prev<o.catchLoc)return e(o.catchLoc,!0);if(this.prev<o.finallyLoc)return e(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return e(o.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return e(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&b.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,T):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),T},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),p(n),T}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;p(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:d(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=g),T}}}(function(){return this}()||Function("return this")())},function(t,e){},function(t,e){}]);
gutenberg/form/src/.DS_Store CHANGED
Binary file
gutenberg/form/src/block/block.js CHANGED
@@ -6,13 +6,12 @@ const { registerBlockType } = wp.blocks;
6
  const { SelectControl, TextControl } = wp.components;
7
  const { RichText } = wp.editor ;
8
 
9
- var dropdownOptions = false;
10
- var previewBlockOsTitle;
11
- var previewBlockOsImageUrl;
12
- var previewBlockOsView;
13
- var previewBlockOsEdit;
14
- var previewBlockOsStatistics;
15
- var options;
16
 
17
  registerBlockType( 'opinion-stage/block-os-form', {
18
  title: __( 'Form' ),
@@ -21,18 +20,13 @@ var options;
21
  keywords: [
22
  __( 'Opinion Stage Form' ),
23
  __( 'Opinion Stage Form' ),
24
- ],
25
  attributes: {
26
  embedUrl: {
27
  source: 'attribute',
28
  attribute: 'data-test-url',
29
  selector: 'div[data-test-url]'
30
- },
31
- oswpUrlShortcode: {
32
- source: 'attribute',
33
- attribute: 'data-test-url',
34
- selector: 'div[data-test-url]'
35
- },
36
  lockEmbed: {
37
  source: 'attribute',
38
  attribute: 'data-lock-embed',
@@ -42,175 +36,132 @@ var options;
42
  source: 'attribute',
43
  attribute: 'data-button-text',
44
  selector: 'div[data-button-text]'
45
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  },
47
  edit: function( props ) {
48
- let {attributes: {embedUrl, oswpUrlShortcode, lockEmbed, buttonText}, setAttributes} = props;
49
- const onDropdownChange = val => {
50
- if(val == ''){
51
- props.setAttributes({ embedUrl: '' });
52
- }else if(val != ''){
53
- props.setAttributes({ embedUrl: val });
54
- for (var i = 0; i < dropdownOptions.length; i++) {
55
- var getLandingPageUrlOs = function(href) {
56
- var locationUrlOS = document.createElement("a");
57
- locationUrlOS.href = href;
58
- return locationUrlOS;
59
- };
60
- var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
61
- var matchValue = locationUrlOS.pathname;
62
- if(val == matchValue){
63
- previewBlockOsTitle = dropdownOptions[i].attributes['title'];
64
- previewBlockOsImageUrl = dropdownOptions[i].attributes['image-url'];
65
- previewBlockOsView = dropdownOptions[i].attributes['landing-page-url'];
66
- previewBlockOsEdit = dropdownOptions[i].attributes['edit-url'];
67
- previewBlockOsStatistics = dropdownOptions[i].attributes['stats-url'];
68
- break;
69
- }
70
- }
71
- }else{
72
- }
73
- };
74
- const onEmbedButtonClick = event => {
75
- if( event.target.value == "Embed" ){
76
- if(embedUrl == '' || embedUrl == 'Select' || embedUrl == 'createNew' || embedUrl == 'refresh'){
77
- props.setAttributes({ lockEmbed: false, buttonText: "Embed" });
78
- }else{
79
- props.setAttributes({ lockEmbed: true, buttonText: "Change" });
80
- contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} onChange={onDropdownChange} className="components-select-control__input" />);
81
- }
82
- }else{
83
- props.setAttributes({ lockEmbed: false, buttonText: "Embed" });
84
- }
85
- };
86
-
87
- window.verifyOSInsert = function(widget){
88
- props.setAttributes({ oswpUrlShortcode: widget });
89
- var myOpts = document.getElementById('selectID').options;
90
- for(var i = 0; i < myOpts.length; i++){
91
- if(myOpts[i].value == widget){
92
- myOpts[i].defaultSelected = true;
93
- props.setAttributes({ lockEmbed: true, buttonText: "Change", embedUrl: widget });
94
- break;
95
- }
96
- }
97
- }
98
-
99
- var getOsCreateButtonClickUrl = osGutenData.onCreateButtonClickOs+'?w_type=form&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8';
100
- const onCreateButtonClick = value => {
101
- // Open Create new form link in new page
102
- window.open(getOsCreateButtonClickUrl, '_blank').focus();
103
- };
104
-
105
- if(!buttonText){
106
- props.setAttributes({ buttonText: 'Embed' });
107
- }
108
 
 
109
  var getCallBackUrlOs = osGutenData.callbackUrlOs;
110
  var callback_url = getCallBackUrlOs;
111
  var formActionUrlOS = osGutenData.getActionUrlOS;
112
  var getlogoImageLinkOs = osGutenData.getLogoImageLink;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  const onConnectOSWPButtonClick = value => {
114
- // Open Connect to opinionstage
115
  window.location.replace(callback_url);
116
  };
117
- // Populate list ajax function
118
- function OsPolulateList() {
119
- var opinionStageWidgetVersion = osGutenData.OswpPluginVersion;
120
- var opinionStageClientToken = osGutenData.OswpClientToken;
121
- var opinionstageFetchDataUrl = osGutenData.OswpFetchDataUrl+'?type=form&page=1&per_page=99';
122
- fetch(opinionstageFetchDataUrl, {
123
- method: "GET",
124
- headers: {
125
- 'Accept':'application/vnd.api+json',
126
- 'Content-Type':'application/vnd.api+json',
127
- 'OSWP-Plugin-Version':opinionStageWidgetVersion,
128
- 'OSWP-Client-Token': opinionStageClientToken
129
- },
130
- })
131
- .then(async res => {
132
- var data = await res.json();
133
- data = data.data;
134
- dropdownOptions = data;
135
- // force reprinting instead!!
136
- props.setAttributes({ buttonText: 'Embed'});
137
- props.setAttributes({ buttonText: buttonText});
138
- if(buttonText == 'Change' && embedUrl !='Select'){
139
- props.setAttributes({ embedUrl: embedUrl });
140
- }else{
141
- props.setAttributes({ embedUrl: 'Select' });
142
- }
143
- })
144
- .catch(function(err) {
145
- console.log('ERROR: ' + err.message);
146
- });
147
- }
148
  // Checking for Opinion Stage connection
149
  if(osGutenData.isOsConnected == ''){
150
- $(document).ready(function () {
151
- $('span#oswpLauncherContentPopupform , #owspLaunchInputCreate').live('click', function(e) {
152
- e.preventDefault();
153
- setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
154
- });
155
- });
156
  return (
157
  <div className={ props.className }>
158
  <div className="os-form-wrapper components-placeholder">
159
  <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
160
  <p className="components-heading">Please connect WordPress to Opinion Stage to start adding forms</p>
161
  <button className="components-button is-button is-default is-block is-primary" onClick={onConnectOSWPButtonClick}>Connect</button>
162
- </div>
 
163
  </div>
164
  );
165
- }else{
166
- if(dropdownOptions == false){
167
- options = [{value:'Select',label:'Select a form'},{value:'refresh',label:'Refresh'}];
168
- OsPolulateList();
169
- }else{
170
- options = [{value:'Select',label:'Select a form'},{value:'refresh',label:'Refresh'},{value:'',label:'-----------------'}];
171
- for (var i = 0; i < dropdownOptions.length; i++) {
172
- options[options.length] = {
173
- value: dropdownOptions[i].attributes['landing-page-url'].replace('https://www.opinionstage.com',''),
174
- label: dropdownOptions[i].attributes['title'],
175
- };
176
- var getLandingPageUrlOs = function(href) {
177
- var locationUrlOS = document.createElement("a");
178
- locationUrlOS.href = href;
179
- return locationUrlOS;
180
- };
181
- var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
182
- var matchValue = locationUrlOS.pathname;
183
- if(embedUrl == matchValue){
184
- previewBlockOsTitle = dropdownOptions[i].attributes['title'];
185
- previewBlockOsImageUrl = dropdownOptions[i].attributes['image-url'];
186
- previewBlockOsView = dropdownOptions[i].attributes['landing-page-url'];
187
- previewBlockOsEdit = dropdownOptions[i].attributes['edit-url'];
188
- previewBlockOsStatistics = dropdownOptions[i].attributes['stats-url'];
189
- var previewBlockOsWidgetID = dropdownOptions[i].id;
190
-
191
- }
192
- }
193
- }
194
- if(embedUrl == 'refresh'){
195
- OsPolulateList();
196
- }
197
- var contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} onChange={onDropdownChange} className="components-select-control__input" />);
198
  $(document).ready(function () {
199
- $('.progress_message').css('display', 'block');
200
- $('.content__list').css('display', 'none');
201
  $('span#oswpLauncherContentPopupform').live('click', function(e) {
202
  e.preventDefault();
203
  setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
204
  var text = $(this).attr('data-os-block');
205
  $("button#dropbtn span").text(text);
206
- var inputs = $(".filter__itm");
207
  for(var i = 0; i < inputs.length; i++){
208
- if($(inputs[i]).text() == text){
209
- setTimeout(function(){$(inputs[i]).trigger('click');},1000);
210
  setTimeout(function(){
211
- $('.progress_message').css('display', 'none');
212
- $('.content__list').css('display', 'block');
213
- },2500);
 
 
 
214
  $('button.content__links-itm').live('click', function(e) {
215
  $('.tingle-modal.opinionstage-content-popup').hide();
216
  $('.tingle-modal.opinionstage-content-popup.tingle-modal--visible').hide();
@@ -220,83 +171,89 @@ var options;
220
  else {
221
  $('.progress_message').css('display', 'block');
222
  $('.content__list').css('display', 'none');
223
- console.log('test');
224
  }
225
  }
226
  });
227
  });
228
 
229
- var contentViewEditStatOs = (
230
- <div className="os-form-wrapper components-placeholder">
231
- <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
232
- <span id="oswpLauncherContentPopupform" className="components-button is-button is-default is-block is-primary" data-opinionstage-content-launch data-os-block="form">Select a Form</span>
233
- <input type="button" value="Create a New Form" className="components-button is-button is-default is-block is-primary" onClick={onCreateButtonClick} />
234
- <div className="components-placeholder__fieldset">
235
- {contentDropdown}
236
- <input type="button" value={buttonText} className="components-button is-button is-default is-large" id="clickMe" onClick={onEmbedButtonClick} />
237
- </div>
238
- </div>
239
- );
240
-
241
- var dataOpinionStageEmbedUrl = 'https://www.opinionstage.com/api/v1/widgets/'+embedUrl+'/code.json?comments=true&amp;sharing=true&amp;recommendations=false&amp;width=';
242
- var OpinionStageDataIframe = 'https://www.opinionstage.com/'+embedUrl+'?wid=0&amp;em=1&amp;comments=null&amp;referring_widget='+embedUrl+'&amp;autoswitch=1&amp;of=&amp;os_utm_source=null';
243
- (function(d, s, id){
244
- var js,
245
- fjs = d.getElementsByTagName(s)[0],
246
- r = Math.floor(new Date().getTime() / 1000000);
247
- if (d.getElementById(id)) {return;}
248
- js = d.createElement(s); js.id = id; js.async=1;
249
- js.src = "https://www.opinionstage.com/assets/loader.js?" + r;
250
- fjs.parentNode.insertBefore(js, fjs);
251
- }(document, 'script', 'os-widget-jssdk'));
252
- previewBlockOsWidgetID = 'os-widget-'+previewBlockOsWidgetID;
253
-
254
- if(embedUrl != '' && embedUrl != 'Select' && embedUrl){
 
 
 
 
 
 
 
255
  if(buttonText == 'Embed'){
256
  contentViewEditStatOs
257
- }else if(buttonText == 'Change'){
258
  contentViewEditStatOs = (
259
- <div className="os-form-wrapper components-placeholder">
260
- <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
261
- <div className="components-preview__block" >
262
- <div className="components-preview__leftBlockImage">
263
- <img src={previewBlockOsImageUrl} alt={previewBlockOsTitle} className="image" />
264
- <div className="overlay">
265
- <div className="text">
266
- <a href={previewBlockOsView} target="_blank"> View </a>
267
- <a href={previewBlockOsEdit} target="_blank"> Edit </a>
268
- <a href={previewBlockOsStatistics} target="_blank"> Statistics </a>
269
- <input type="button" value={buttonText} className="components-button is-button is-default is-large left-align" onClick={onEmbedButtonClick} />
270
- </div>
 
 
 
 
271
  </div>
272
- </div>
273
- <div className="components-preview__rightBlockContent">
274
- <div className="components-placeholder__label">Form: {previewBlockOsTitle}</div>
275
- </div>
276
- </div>
277
- </div>
278
- );
279
- contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} disabled onChange={onDropdownChange} className="components-select-control__input" />);
280
  }
281
- }else if(embedUrl == 'Select' || embedUrl == '' || embedUrl == 'refresh'){
282
  contentViewEditStatOs
283
  }else{
284
  props.setAttributes({ buttonText: 'Embed'});
285
  contentViewEditStatOs
286
  }
287
-
288
-
289
- return (
290
  <div className={ props.className }>
291
- {contentViewEditStatOs}
 
292
  </div>
293
  );
294
  }
295
  },
296
- save: function( {attributes: {embedUrl, oswpUrlShortcode, lockEmbed, buttonText}} ) {
297
  return (
298
- <div class="os-form-wrapper" data-type="form" data-test-url={oswpUrlShortcode} data-lock-embed={lockEmbed} data-button-text={buttonText}>
299
- [os-widget path="{oswpUrlShortcode}"]
 
300
  </div>
301
  );
302
  },
6
  const { SelectControl, TextControl } = wp.components;
7
  const { RichText } = wp.editor ;
8
 
9
+ var dropdownOptions = false;
10
+ var insertItemImage = false;
11
+ var insertItemOsTitle = false;
12
+ var insertItemOsView = false;
13
+ var insertItemOsEdit = false;
14
+ var insertItemOsStatistics = false;
 
15
 
16
  registerBlockType( 'opinion-stage/block-os-form', {
17
  title: __( 'Form' ),
20
  keywords: [
21
  __( 'Opinion Stage Form' ),
22
  __( 'Opinion Stage Form' ),
23
+ ],
24
  attributes: {
25
  embedUrl: {
26
  source: 'attribute',
27
  attribute: 'data-test-url',
28
  selector: 'div[data-test-url]'
29
+ },
 
 
 
 
 
30
  lockEmbed: {
31
  source: 'attribute',
32
  attribute: 'data-lock-embed',
36
  source: 'attribute',
37
  attribute: 'data-button-text',
38
  selector: 'div[data-button-text]'
39
+ },
40
+ insertItemImage: {
41
+ source: 'attribute',
42
+ attribute: 'data-image-url',
43
+ selector: 'div[data-image-url]'
44
+ },
45
+ insertItemOsTitle: {
46
+ source: 'attribute',
47
+ attribute: 'data-title-url',
48
+ selector: 'div[data-title-url]'
49
+ },
50
+ insertItemOsView: {
51
+ source: 'attribute',
52
+ attribute: 'data-view-url',
53
+ selector: 'div[data-view-url]'
54
+ },
55
+ insertItemOsEdit: {
56
+ source: 'attribute',
57
+ attribute: 'data-edit-url',
58
+ selector: 'div[data-edit-url]'
59
+ },
60
+ insertItemOsStatistics: {
61
+ source: 'attribute',
62
+ attribute: 'data-statistics-url',
63
+ selector: 'div[data-statistics-url]'
64
+ }
65
  },
66
  edit: function( props ) {
67
+ // Setting Attributes
68
+ let {attributes: {embedUrl, lockEmbed, buttonText, insertItemImage,insertItemOsTitle,insertItemOsView,insertItemOsEdit,insertItemOsStatistics}, setAttributes} = props;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ // Fetching Localized variables
71
  var getCallBackUrlOs = osGutenData.callbackUrlOs;
72
  var callback_url = getCallBackUrlOs;
73
  var formActionUrlOS = osGutenData.getActionUrlOS;
74
  var getlogoImageLinkOs = osGutenData.getLogoImageLink;
75
+
76
+ // Select Button Click functionality
77
+ const onSelectButtonClick = value => {
78
+ window.verifyOSInsert = function(widget){
79
+ props.setAttributes({ embedUrl: widget, buttonText:'Change' });
80
+
81
+ var opinionStageWidgetVersion = osGutenData.OswpPluginVersion;
82
+ var opinionStageClientToken = osGutenData.OswpClientToken;
83
+ var opinionstageFetchDataUrl = osGutenData.OswpFetchDataUrl+'?type=form&page=1&per_page=99';
84
+ fetch(opinionstageFetchDataUrl, {
85
+ method: "GET",
86
+ headers: {
87
+ 'Accept':'application/vnd.api+json',
88
+ 'Content-Type':'application/vnd.api+json',
89
+ 'OSWP-Plugin-Version':opinionStageWidgetVersion,
90
+ 'OSWP-Client-Token': opinionStageClientToken
91
+ },
92
+ })
93
+ .then(async res => {
94
+ var data = await res.json();
95
+ data = data.data;
96
+ dropdownOptions = data;
97
+ // force reprinting instead!!
98
+ props.setAttributes({ buttonText: buttonText});
99
+
100
+ })
101
+ .catch(function(err) {
102
+ console.log('ERROR: ' + err.message);
103
+ });
104
+ }
105
+ }
106
+
107
+ // Change Button Click functionality
108
+ const onChangeButtonClick = value => {
109
+ props.setAttributes({
110
+ embedUrl: '',
111
+ buttonText:'Embed',
112
+ lockEmbed: false,
113
+ insertItemImage: false,
114
+ insertItemOsTitle: false,
115
+ insertItemOsView: false,
116
+ insertItemOsEdit: false,
117
+ insertItemOsStatistics: false
118
+ });
119
+ }
120
+
121
+ // Connect to Opinionstage Callback Url
122
  const onConnectOSWPButtonClick = value => {
 
123
  window.location.replace(callback_url);
124
  };
125
+
126
+ // Create New Item Url (form)
127
+ var getOsCreateButtonClickUrl = osGutenData.onCreateButtonClickOs+'?w_type=contact_form&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8';
128
+ const onCreateButtonClick = value => {
129
+ // Open Create new form link in new page
130
+ window.open(getOsCreateButtonClickUrl, '_blank').focus();
131
+ };
132
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  // Checking for Opinion Stage connection
134
  if(osGutenData.isOsConnected == ''){
135
+ // Not Connected to opinionstage
 
 
 
 
 
136
  return (
137
  <div className={ props.className }>
138
  <div className="os-form-wrapper components-placeholder">
139
  <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
140
  <p className="components-heading">Please connect WordPress to Opinion Stage to start adding forms</p>
141
  <button className="components-button is-button is-default is-block is-primary" onClick={onConnectOSWPButtonClick}>Connect</button>
142
+ </div>
143
+ <div></div>
144
  </div>
145
  );
146
+ }else{
147
+ // Connected to opinionstage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  $(document).ready(function () {
149
+ // Content Popup Launch Working
 
150
  $('span#oswpLauncherContentPopupform').live('click', function(e) {
151
  e.preventDefault();
152
  setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
153
  var text = $(this).attr('data-os-block');
154
  $("button#dropbtn span").text(text);
155
+ var inputs = $(".filter__itm");
156
  for(var i = 0; i < inputs.length; i++){
157
+ if($(inputs[i]).text() == text){
 
158
  setTimeout(function(){
159
+ $(inputs[i]).trigger('click');
160
+ },1000);
161
+ setTimeout(function(){
162
+ $('.progress_message').css('display', 'none');
163
+ $('.content__list').css('display', 'block');
164
+ },2500);
165
  $('button.content__links-itm').live('click', function(e) {
166
  $('.tingle-modal.opinionstage-content-popup').hide();
167
  $('.tingle-modal.opinionstage-content-popup.tingle-modal--visible').hide();
171
  else {
172
  $('.progress_message').css('display', 'block');
173
  $('.content__list').css('display', 'none');
 
174
  }
175
  }
176
  });
177
  });
178
 
179
+ // Fetching Ajax Call Result
180
+ if(dropdownOptions != false){
181
+ for (var i = 0; i < dropdownOptions.length; i++) {
182
+ var getLandingPageUrlOs = function(href) {
183
+ var locationUrlOS = document.createElement("a");
184
+ locationUrlOS.href = href;
185
+ return locationUrlOS;
186
+ };
187
+ var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
188
+ var matchValue = locationUrlOS.pathname;
189
+ if(embedUrl == matchValue){
190
+ props.setAttributes({lockEmbed: true, buttonText: "Change" });
191
+ props.setAttributes({ insertItemImage : dropdownOptions[i].attributes['image-url'] });
192
+ props.setAttributes({ insertItemOsTitle : dropdownOptions[i].attributes['title'] });
193
+ props.setAttributes({ insertItemOsView : dropdownOptions[i].attributes['landing-page-url'] });
194
+ props.setAttributes({ insertItemOsEdit : dropdownOptions[i].attributes['edit-url'] });
195
+ props.setAttributes({ insertItemOsStatistics : dropdownOptions[i].attributes['stats-url'] });
196
+ break;
197
+ }
198
+ }
199
+ }
200
+
201
+ // Content On Editor
202
+ var contentViewEditStatOs = (
203
+ <div className="os-form-wrapper components-placeholder">
204
+ <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
205
+ <span id="oswpLauncherContentPopupform" className="components-button is-button is-default is-block is-primary" data-opinionstage-content-launch data-os-block="form" onClick={onSelectButtonClick} >Select a Form</span>
206
+ <input type="button" value="Create a New form" className="components-button is-button is-default is-block is-primary" onClick={onCreateButtonClick} />
207
+ <span></span>
208
+ </div>
209
+ );
210
+
211
+ if(embedUrl != '' && embedUrl){
212
  if(buttonText == 'Embed'){
213
  contentViewEditStatOs
214
+ }else if(buttonText == 'Change'){
215
  contentViewEditStatOs = (
216
+ <div className="os-form-wrapper components-placeholder">
217
+ <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
218
+ <div className="components-preview__block" >
219
+ <div className="components-preview__leftBlockImage">
220
+ <img src={insertItemImage} alt={insertItemOsTitle} className="image" />
221
+ <div className="overlay">
222
+ <div className="text">
223
+ <a href={insertItemOsView} target="_blank"> View </a>
224
+ <a href={insertItemOsEdit} target="_blank"> Edit </a>
225
+ <a href={insertItemOsStatistics} target="_blank"> Statistics </a>
226
+ <input type="button" value={buttonText} className="components-button is-button is-default is-large left-align" onClick={onChangeButtonClick}/>
227
+ </div>
228
+ </div>
229
+ </div>
230
+ <div className="components-preview__rightBlockContent">
231
+ <div className="components-placeholder__label">Form: {insertItemOsTitle}</div>
232
  </div>
233
+ </div>
234
+ <span></span>
235
+ </div>
236
+ );
 
 
 
 
237
  }
238
+ }else if(embedUrl == '' || jQuery.type(embedUrl) === "undefined"){
239
  contentViewEditStatOs
240
  }else{
241
  props.setAttributes({ buttonText: 'Embed'});
242
  contentViewEditStatOs
243
  }
244
+ return (
 
 
245
  <div className={ props.className }>
246
+ {contentViewEditStatOs}
247
+ <span></span>
248
  </div>
249
  );
250
  }
251
  },
252
+ save: function( {attributes: {embedUrl, lockEmbed, buttonText, insertItemImage, insertItemOsTitle, insertItemOsView, insertItemOsEdit, insertItemOsStatistics }} ) {
253
  return (
254
+ <div class="os-form-wrapper" data-type="form" data-image-url={insertItemImage} data-title-url={insertItemOsTitle} data-view-url={insertItemOsView} data-statistics-url={insertItemOsStatistics} data-edit-url={insertItemOsEdit} data-test-url={embedUrl} data-lock-embed={lockEmbed} data-button-text={buttonText}>
255
+ [os-widget path="{embedUrl}"]
256
+ <span></span>
257
  </div>
258
  );
259
  },
gutenberg/init.php CHANGED
@@ -56,24 +56,29 @@ function oswp_gutenberg_enqueue_scripts() {
56
  $OswpPluginVersion = OPINIONSTAGE_WIDGET_VERSION;
57
 
58
  // Fetch Url For Ajax Call Opinion Stage
59
- $FetchUrlOS = 'https://www.opinionstage.com/api/wp/v1/my/widgets';
60
 
61
  // Url For Creating New Content OR Template On Opinion Stage
62
- $getUrlFormAction = 'https://www.opinionstage.com/integrations/wordpress/new';
63
 
64
  // Opninionstge logo image link
65
  $logoImagelinkOs = plugin_dir_url( __FILE__ ) . 'image/os-logo.png';
66
 
 
 
 
 
67
  // Data to pass to gutenberg editor
68
  $dataToPass = array(
69
  'isOsConnected' => (isset($os_options['uid']) && $os_options['uid'] != '') ? true : false,
70
- 'onCreateButtonClickOs' => 'https://www.opinionstage.com/api/wp/redirects/widgets/new',
71
  'callbackUrlOs' => $adminUrlForOs,
72
  'OswpPluginVersion' => $OswpPluginVersion,
73
  'OswpClientToken' => opinionstage_user_access_token(),
74
  'OswpFetchDataUrl' => $FetchUrlOS,
75
  'getActionUrlOS' => $getUrlFormAction,
76
  'getLogoImageLink' => $logoImagelinkOs,
 
77
  );
78
  wp_localize_script( 'opinionStage_poll_oswp_block_js_set', 'osGutenData', $dataToPass );
79
  }
56
  $OswpPluginVersion = OPINIONSTAGE_WIDGET_VERSION;
57
 
58
  // Fetch Url For Ajax Call Opinion Stage
59
+ $FetchUrlOS = OPINIONSTAGE_SERVER_BASE.'/api/wp/v1/my/widgets';
60
 
61
  // Url For Creating New Content OR Template On Opinion Stage
62
+ $getUrlFormAction = OPINIONSTAGE_SERVER_BASE.'/integrations/wordpress/new';
63
 
64
  // Opninionstge logo image link
65
  $logoImagelinkOs = plugin_dir_url( __FILE__ ) . 'image/os-logo.png';
66
 
67
+ // Opinionstage view item count
68
+ $OsOptions = (array) get_option(OPINIONSTAGE_OPTIONS_KEY);
69
+
70
+
71
  // Data to pass to gutenberg editor
72
  $dataToPass = array(
73
  'isOsConnected' => (isset($os_options['uid']) && $os_options['uid'] != '') ? true : false,
74
+ 'onCreateButtonClickOs' => OPINIONSTAGE_SERVER_BASE.'/api/wp/redirects/widgets/new',
75
  'callbackUrlOs' => $adminUrlForOs,
76
  'OswpPluginVersion' => $OswpPluginVersion,
77
  'OswpClientToken' => opinionstage_user_access_token(),
78
  'OswpFetchDataUrl' => $FetchUrlOS,
79
  'getActionUrlOS' => $getUrlFormAction,
80
  'getLogoImageLink' => $logoImagelinkOs,
81
+ 'getOsOption' => $OsOptions,
82
  );
83
  wp_localize_script( 'opinionStage_poll_oswp_block_js_set', 'osGutenData', $dataToPass );
84
  }
gutenberg/personality/dist/blocks.build.js CHANGED
@@ -1 +1 @@
1
- !function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});n(1)},function(e,t,n){"use strict";function r(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){function r(o,a){try{var i=t[o](a),s=i.value}catch(e){return void n(e)}if(!i.done)return Promise.resolve(s).then(function(e){r("next",e)},function(e){r("throw",e)});e(s)}return r("next")})}}var o,a,i,s,l,c,u=n(2),p=n.n(u),m=n(5),f=(n.n(m),n(6)),d=(n.n(f),wp.i18n.__),h=wp.blocks.registerBlockType,g=wp.components,v=g.SelectControl,b=(g.TextControl,wp.editor.RichText,!1);h("opinion-stage/block-os-personality",{title:d("Personality Quiz"),icon:"smiley",category:"opinion-stage",keywords:[d("Opinion Stage Personality Quiz"),d("Opinion Stage Personality")],attributes:{embedUrl:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},oswpUrlShortcode:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},lockEmbed:{source:"attribute",attribute:"data-lock-embed",selector:"div[data-lock-embed]"},buttonText:{source:"attribute",attribute:"data-button-text",selector:"div[data-button-text]"}},edit:function(e){function t(){var t=this,n=osGutenData.OswpPluginVersion,o=osGutenData.OswpClientToken,a=osGutenData.OswpFetchDataUrl+"?type=outcome&page=1&per_page=99";fetch(a,{method:"GET",headers:{Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json","OSWP-Plugin-Version":n,"OSWP-Client-Token":o}}).then(function(){var n=r(p.a.mark(function n(r){var o;return p.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.json();case 2:o=t.sent,o=o.data,b=o,e.setAttributes({buttonText:"Embed"}),e.setAttributes({buttonText:m}),"Change"==m&&"Select"!=u?e.setAttributes({embedUrl:u}):e.setAttributes({embedUrl:"Select"});case 8:case"end":return t.stop()}},n,t)}));return function(e){return n.apply(this,arguments)}}()).catch(function(e){console.log("ERROR: "+e.message)})}var n=e.attributes,u=n.embedUrl,m=(n.oswpUrlShortcode,n.lockEmbed,n.buttonText),f=(e.setAttributes,function(t){if(""==t)e.setAttributes({embedUrl:""});else if(""!=t){e.setAttributes({embedUrl:t});for(var n=0;n<b.length;n++){var r=function(e){var t=document.createElement("a");return t.href=e,t}(b[n].attributes["landing-page-url"]),c=r.pathname;if(t==c){o=b[n].attributes.title,a=b[n].attributes["image-url"],i=b[n].attributes["landing-page-url"],s=b[n].attributes["edit-url"],l=b[n].attributes["stats-url"];break}}}}),d=function(t){"Embed"==t.target.value?""==u||"Select"==u||"createNew"==u||"refresh"==u?e.setAttributes({lockEmbed:!1,buttonText:"Embed"}):(e.setAttributes({lockEmbed:!0,buttonText:"Change"}),O=wp.element.createElement(v,{id:"selectID",options:c,value:u,onChange:f,className:"components-select-control__input"})):e.setAttributes({lockEmbed:!1,buttonText:"Embed"})};window.verifyOSInsert=function(t){e.setAttributes({oswpUrlShortcode:t});for(var n=document.getElementById("selectID").options,r=0;r<n.length;r++)if(n[r].value==t){n[r].defaultSelected=!0,e.setAttributes({lockEmbed:!0,buttonText:"Change",embedUrl:t});break}};var h=osGutenData.onCreateButtonClickOs+"?w_type=outcome&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8",g=function(e){window.open(h,"_blank").focus()};m||e.setAttributes({buttonText:"Embed"});var y=osGutenData.callbackUrlOs,w=y,E=(osGutenData.getActionUrlOS,osGutenData.getLogoImageLink),k=function(e){window.location.replace(w)};if(""==osGutenData.isOsConnected)return $(document).ready(function(){$("span#oswpLauncherContentPopuppersonality , #owspLaunchInputCreate").live("click",function(e){e.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500)})}),wp.element.createElement("div",{className:e.className},wp.element.createElement("div",{className:"os-personality-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:E,alt:""})),wp.element.createElement("p",{className:"components-heading"},"Please connect WordPress to Opinion Stage to start adding personality"),wp.element.createElement("button",{className:"components-button is-button is-default is-block is-primary",onClick:k},"Connect")));if(0==b)c=[{value:"Select",label:"Select a personality"},{value:"refresh",label:"Refresh"}],t();else{c=[{value:"Select",label:"Select a personality"},{value:"refresh",label:"Refresh"},{value:"",label:"-----------------"}];for(var x=0;x<b.length;x++){c[c.length]={value:b[x].attributes["landing-page-url"].replace("https://www.opinionstage.com",""),label:b[x].attributes.title};var _=function(e){var t=document.createElement("a");return t.href=e,t}(b[x].attributes["landing-page-url"]),N=_.pathname;if(u==N){o=b[x].attributes.title,a=b[x].attributes["image-url"],i=b[x].attributes["landing-page-url"],s=b[x].attributes["edit-url"],l=b[x].attributes["stats-url"];var L=b[x].id}}}"refresh"==u&&t();var O=wp.element.createElement(v,{id:"selectID",options:c,value:u,onChange:f,className:"components-select-control__input"});$(document).ready(function(){$("span#oswpLauncherContentPopuppersonality").live("click",function(e){e.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500);var t=$(this).attr("data-os-block");$("button#dropbtn span").text(t);for(var n=$(".filter__itm"),r=0;r<n.length;r++){if($(n[r]).text()==t){setTimeout(function(){$(n[r]).trigger("click")},1e3),setTimeout(function(){$(".progress_message").css("display","none"),$(".content__list").css("display","block")},2500),$("button.content__links-itm").live("click",function(e){$(".tingle-modal.opinionstage-content-popup").hide(),$(".tingle-modal.opinionstage-content-popup.tingle-modal--visible").hide()});break}$(".progress_message").css("display","block"),$(".content__list").css("display","none"),console.log("test")}})});var P=wp.element.createElement("div",{className:"os-personality-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:E,alt:""})),wp.element.createElement("span",{id:"oswpLauncherContentPopuppersonality",className:"components-button is-button is-default is-block is-primary","data-opinionstage-content-launch":!0,"data-os-block":"personality quiz"},"Select a Personality Quiz"),wp.element.createElement("input",{type:"button",value:"Create a New Personality Quiz",className:"components-button is-button is-default is-block is-primary",onClick:g}),wp.element.createElement("div",{className:"components-placeholder__fieldset"},O,wp.element.createElement("input",{type:"button",value:m,className:"components-button is-button is-default is-large",id:"clickMe",onClick:d})));return function(e,t,n){var r,o=e.getElementsByTagName(t)[0],a=Math.floor((new Date).getTime()/1e6);e.getElementById(n)||(r=e.createElement(t),r.id=n,r.async=1,r.src="https://www.opinionstage.com/assets/loader.js?"+a,o.parentNode.insertBefore(r,o))}(document,"script","os-widget-jssdk"),L="os-widget-"+L,""!=u&&"Select"!=u&&u?"Embed"==m||"Change"==m&&(P=wp.element.createElement("div",{className:"os-personality-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:E,alt:""})),wp.element.createElement("div",{className:"components-preview__block"},wp.element.createElement("div",{className:"components-preview__leftBlockImage"},wp.element.createElement("img",{src:a,alt:o,className:"image"}),wp.element.createElement("div",{className:"overlay"},wp.element.createElement("div",{className:"text"},wp.element.createElement("a",{href:i,target:"_blank"}," View "),wp.element.createElement("a",{href:s,target:"_blank"}," Edit "),wp.element.createElement("a",{href:l,target:"_blank"}," Statistics "),wp.element.createElement("input",{type:"button",value:m,className:"components-button is-button is-default is-large left-align",onClick:d})))),wp.element.createElement("div",{className:"components-preview__rightBlockContent"},wp.element.createElement("div",{className:"components-placeholder__label"},"Personality Quiz: ",o)))),O=wp.element.createElement(v,{id:"selectID",options:c,value:u,disabled:!0,onChange:f,className:"components-select-control__input"})):"Select"==u||""==u||"refresh"==u||e.setAttributes({buttonText:"Embed"}),wp.element.createElement("div",{className:e.className},P)},save:function(e){var t=e.attributes,n=(t.embedUrl,t.oswpUrlShortcode),r=t.lockEmbed,o=t.buttonText;return wp.element.createElement("div",{class:"os-personality-wrapper","data-type":"personality","data-test-url":n,"data-lock-embed":r,"data-button-text":o},'[os-widget path="',n,'"]')}})},function(e,t,n){e.exports=n(3)},function(e,t,n){var r=function(){return this}()||Function("return this")(),o=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,a=o&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,e.exports=n(4),o)r.regeneratorRuntime=a;else try{delete r.regeneratorRuntime}catch(e){r.regeneratorRuntime=void 0}},function(e,t){!function(t){"use strict";function n(e,t,n,r){var a=t&&t.prototype instanceof o?t:o,i=Object.create(a.prototype),s=new f(r||[]);return i._invoke=c(e,n,s),i}function r(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}function o(){}function a(){}function i(){}function s(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function l(e){function t(n,o,a,i){var s=r(e[n],e,o);if("throw"!==s.type){var l=s.arg,c=l.value;return c&&"object"===typeof c&&b.call(c,"__await")?Promise.resolve(c.__await).then(function(e){t("next",e,a,i)},function(e){t("throw",e,a,i)}):Promise.resolve(c).then(function(e){l.value=e,a(l)},i)}i(s.arg)}function n(e,n){function r(){return new Promise(function(r,o){t(e,n,r,o)})}return o=o?o.then(r,r):r()}var o;this._invoke=n}function c(e,t,n){var o=N;return function(a,i){if(o===O)throw new Error("Generator is already running");if(o===P){if("throw"===a)throw i;return h()}for(n.method=a,n.arg=i;;){var s=n.delegate;if(s){var l=u(s,n);if(l){if(l===S)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===N)throw o=P,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=O;var c=r(e,t,n);if("normal"===c.type){if(o=n.done?P:L,c.arg===S)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=P,n.method="throw",n.arg=c.arg)}}}function u(e,t){var n=e.iterator[t.method];if(n===g){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=g,u(e,t),"throw"===t.method))return S;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return S}var o=r(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,S;var a=o.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=g),t.delegate=null,S):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,S)}function p(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function m(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function f(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(p,this),this.reset(!0)}function d(e){if(e){var t=e[w];if(t)return t.call(e);if("function"===typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(b.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=g,t.done=!0,t};return r.next=r}}return{next:h}}function h(){return{value:g,done:!0}}var g,v=Object.prototype,b=v.hasOwnProperty,y="function"===typeof Symbol?Symbol:{},w=y.iterator||"@@iterator",E=y.asyncIterator||"@@asyncIterator",k=y.toStringTag||"@@toStringTag",x="object"===typeof e,_=t.regeneratorRuntime;if(_)return void(x&&(e.exports=_));_=t.regeneratorRuntime=x?e.exports:{},_.wrap=n;var N="suspendedStart",L="suspendedYield",O="executing",P="completed",S={},T={};T[w]=function(){return this};var C=Object.getPrototypeOf,j=C&&C(C(d([])));j&&j!==v&&b.call(j,w)&&(T=j);var A=i.prototype=o.prototype=Object.create(T);a.prototype=A.constructor=i,i.constructor=a,i[k]=a.displayName="GeneratorFunction",_.isGeneratorFunction=function(e){var t="function"===typeof e&&e.constructor;return!!t&&(t===a||"GeneratorFunction"===(t.displayName||t.name))},_.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,i):(e.__proto__=i,k in e||(e[k]="GeneratorFunction")),e.prototype=Object.create(A),e},_.awrap=function(e){return{__await:e}},s(l.prototype),l.prototype[E]=function(){return this},_.AsyncIterator=l,_.async=function(e,t,r,o){var a=new l(n(e,t,r,o));return _.isGeneratorFunction(t)?a:a.next().then(function(e){return e.done?e.value:a.next()})},s(A),A[k]="Generator",A[w]=function(){return this},A.toString=function(){return"[object Generator]"},_.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},_.values=d,f.prototype={constructor:f,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=g,this.done=!1,this.delegate=null,this.method="next",this.arg=g,this.tryEntries.forEach(m),!e)for(var t in this)"t"===t.charAt(0)&&b.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=g)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){function t(t,r){return a.type="throw",a.arg=e,n.next=t,r&&(n.method="next",n.arg=g),!!r}if(this.done)throw e;for(var n=this,r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var i=b.call(o,"catchLoc"),s=b.call(o,"finallyLoc");if(i&&s){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(i){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&b.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,S):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),S},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),m(n),S}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;m(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:d(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=g),S}}}(function(){return this}()||Function("return this")())},function(e,t){},function(e,t){}]);
1
+ !function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});n(1)},function(t,e,n){"use strict";function r(t){return function(){var e=t.apply(this,arguments);return new Promise(function(t,n){function r(i,o){try{var a=e[i](o),s=a.value}catch(t){return void n(t)}if(!a.done)return Promise.resolve(s).then(function(t){r("next",t)},function(t){r("throw",t)});t(s)}return r("next")})}}var i=n(2),o=n.n(i),a=n(5),s=(n.n(a),n(6)),c=(n.n(s),wp.i18n.__),l=wp.blocks.registerBlockType,u=wp.components,p=(u.SelectControl,u.TextControl,wp.editor.RichText,!1);l("opinion-stage/block-os-personality",{title:c("Personality Quiz"),icon:"smiley",category:"opinion-stage",keywords:[c("Opinion Stage Personality Quiz"),c("Opinion Stage Personality")],attributes:{embedUrl:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},lockEmbed:{source:"attribute",attribute:"data-lock-embed",selector:"div[data-lock-embed]"},buttonText:{source:"attribute",attribute:"data-button-text",selector:"div[data-button-text]"},insertItemImage:{source:"attribute",attribute:"data-image-url",selector:"div[data-image-url]"},insertItemOsTitle:{source:"attribute",attribute:"data-title-url",selector:"div[data-title-url]"},insertItemOsView:{source:"attribute",attribute:"data-view-url",selector:"div[data-view-url]"},insertItemOsEdit:{source:"attribute",attribute:"data-edit-url",selector:"div[data-edit-url]"},insertItemOsStatistics:{source:"attribute",attribute:"data-statistics-url",selector:"div[data-statistics-url]"}},edit:function(t){var e=t.attributes,n=e.embedUrl,i=(e.lockEmbed,e.buttonText),a=e.insertItemImage,s=e.insertItemOsTitle,c=e.insertItemOsView,l=e.insertItemOsEdit,u=e.insertItemOsStatistics,m=(t.setAttributes,osGutenData.callbackUrlOs),d=m,f=(osGutenData.getActionUrlOS,osGutenData.getLogoImageLink),h=function(e){window.verifyOSInsert=function(e){var n=this;t.setAttributes({embedUrl:e,buttonText:"Change"});var a=osGutenData.OswpPluginVersion,s=osGutenData.OswpClientToken,c=osGutenData.OswpFetchDataUrl+"?type=outcome&page=1&per_page=99";fetch(c,{method:"GET",headers:{Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json","OSWP-Plugin-Version":a,"OSWP-Client-Token":s}}).then(function(){var e=r(o.a.mark(function e(r){var a;return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.json();case 2:a=e.sent,a=a.data,p=a,t.setAttributes({buttonText:i});case 6:case"end":return e.stop()}},e,n)}));return function(t){return e.apply(this,arguments)}}()).catch(function(t){console.log("ERROR: "+t.message)})}},g=function(e){t.setAttributes({embedUrl:"",buttonText:"Embed",lockEmbed:!1,insertItemImage:!1,insertItemOsTitle:!1,insertItemOsView:!1,insertItemOsEdit:!1,insertItemOsStatistics:!1})},v=function(t){window.location.replace(d)},y=osGutenData.onCreateButtonClickOs+"?w_type=outcome&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8",b=function(t){window.open(y,"_blank").focus()};if(""==osGutenData.isOsConnected)return wp.element.createElement("div",{className:t.className},wp.element.createElement("div",{className:"os-personality-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:f,alt:""})),wp.element.createElement("p",{className:"components-heading"},"Please connect WordPress to Opinion Stage to start adding personality"),wp.element.createElement("button",{className:"components-button is-button is-default is-block is-primary",onClick:v},"Connect")),wp.element.createElement("div",null));if($(document).ready(function(){$("span#oswpLauncherContentPopuppersonality").live("click",function(t){t.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500);var e=$(this).attr("data-os-block");$("button#dropbtn span").text(e);for(var n=$(".filter__itm"),r=0;r<n.length;r++){if($(n[r]).text()==e){setTimeout(function(){$(n[r]).trigger("click")},1e3),setTimeout(function(){$(".progress_message").css("display","none"),$(".content__list").css("display","block")},2500),$("button.content__links-itm").live("click",function(t){$(".tingle-modal.opinionstage-content-popup").hide(),$(".tingle-modal.opinionstage-content-popup.tingle-modal--visible").hide()});break}$(".progress_message").css("display","block"),$(".content__list").css("display","none")}})}),0!=p)for(var w=0;w<p.length;w++){var E=function(t){var e=document.createElement("a");return e.href=t,e}(p[w].attributes["landing-page-url"]),x=E.pathname;if(n==x){t.setAttributes({lockEmbed:!0,buttonText:"Change"}),t.setAttributes({insertItemImage:p[w].attributes["image-url"]}),t.setAttributes({insertItemOsTitle:p[w].attributes.title}),t.setAttributes({insertItemOsView:p[w].attributes["landing-page-url"]}),t.setAttributes({insertItemOsEdit:p[w].attributes["edit-url"]}),t.setAttributes({insertItemOsStatistics:p[w].attributes["stats-url"]});break}}var k=wp.element.createElement("div",{className:"os-personality-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:f,alt:""})),wp.element.createElement("span",{id:"oswpLauncherContentPopuppersonality",className:"components-button is-button is-default is-block is-primary","data-opinionstage-content-launch":!0,"data-os-block":"personality quiz",onClick:h},"Select a Personality Quiz"),wp.element.createElement("input",{type:"button",value:"Create a New Personality Quiz",className:"components-button is-button is-default is-block is-primary",onClick:b}),wp.element.createElement("span",null));return""!=n&&n?"Embed"==i||"Change"==i&&(k=wp.element.createElement("div",{className:"os-personality-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:f,alt:""})),wp.element.createElement("div",{className:"components-preview__block"},wp.element.createElement("div",{className:"components-preview__leftBlockImage"},wp.element.createElement("img",{src:a,alt:s,className:"image"}),wp.element.createElement("div",{className:"overlay"},wp.element.createElement("div",{className:"text"},wp.element.createElement("a",{href:c,target:"_blank"}," View "),wp.element.createElement("a",{href:l,target:"_blank"}," Edit "),wp.element.createElement("a",{href:u,target:"_blank"}," Statistics "),wp.element.createElement("input",{type:"button",value:i,className:"components-button is-button is-default is-large left-align",onClick:g})))),wp.element.createElement("div",{className:"components-preview__rightBlockContent"},wp.element.createElement("div",{className:"components-placeholder__label"},"Personality Quiz: ",s))),wp.element.createElement("span",null))):""==n||"undefined"===jQuery.type(n)||t.setAttributes({buttonText:"Embed"}),wp.element.createElement("div",{className:t.className},k,wp.element.createElement("span",null))},save:function(t){var e=t.attributes,n=e.embedUrl,r=e.lockEmbed,i=e.buttonText,o=e.insertItemImage,a=e.insertItemOsTitle,s=e.insertItemOsView,c=e.insertItemOsEdit,l=e.insertItemOsStatistics;return wp.element.createElement("div",{class:"os-personality-wrapper","data-type":"personality","data-image-url":o,"data-title-url":a,"data-view-url":s,"data-statistics-url":l,"data-edit-url":c,"data-test-url":n,"data-lock-embed":r,"data-button-text":i},'[os-widget path="',n,'"]',wp.element.createElement("span",null))}})},function(t,e,n){t.exports=n(3)},function(t,e,n){var r=function(){return this}()||Function("return this")(),i=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,o=i&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,t.exports=n(4),i)r.regeneratorRuntime=o;else try{delete r.regeneratorRuntime}catch(t){r.regeneratorRuntime=void 0}},function(t,e){!function(e){"use strict";function n(t,e,n,r){var o=e&&e.prototype instanceof i?e:i,a=Object.create(o.prototype),s=new d(r||[]);return a._invoke=l(t,n,s),a}function r(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function i(){}function o(){}function a(){}function s(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function c(t){function e(n,i,o,a){var s=r(t[n],t,i);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"===typeof l&&y.call(l,"__await")?Promise.resolve(l.__await).then(function(t){e("next",t,o,a)},function(t){e("throw",t,o,a)}):Promise.resolve(l).then(function(t){c.value=t,o(c)},a)}a(s.arg)}function n(t,n){function r(){return new Promise(function(r,i){e(t,n,r,i)})}return i=i?i.then(r,r):r()}var i;this._invoke=n}function l(t,e,n){var i=_;return function(o,a){if(i===L)throw new Error("Generator is already running");if(i===N){if("throw"===o)throw a;return h()}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var c=u(s,n);if(c){if(c===P)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===_)throw i=N,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=L;var l=r(t,e,n);if("normal"===l.type){if(i=n.done?N:I,l.arg===P)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(i=N,n.method="throw",n.arg=l.arg)}}}function u(t,e){var n=t.iterator[e.method];if(n===g){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=g,u(t,e),"throw"===e.method))return P;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return P}var i=r(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,P;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=g),e.delegate=null,P):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,P)}function p(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function m(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function d(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(p,this),this.reset(!0)}function f(t){if(t){var e=t[w];if(e)return e.call(t);if("function"===typeof t.next)return t;if(!isNaN(t.length)){var n=-1,r=function e(){for(;++n<t.length;)if(y.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=g,e.done=!0,e};return r.next=r}}return{next:h}}function h(){return{value:g,done:!0}}var g,v=Object.prototype,y=v.hasOwnProperty,b="function"===typeof Symbol?Symbol:{},w=b.iterator||"@@iterator",E=b.asyncIterator||"@@asyncIterator",x=b.toStringTag||"@@toStringTag",k="object"===typeof t,O=e.regeneratorRuntime;if(O)return void(k&&(t.exports=O));O=e.regeneratorRuntime=k?t.exports:{},O.wrap=n;var _="suspendedStart",I="suspendedYield",L="executing",N="completed",P={},T={};T[w]=function(){return this};var S=Object.getPrototypeOf,C=S&&S(S(f([])));C&&C!==v&&y.call(C,w)&&(T=C);var j=a.prototype=i.prototype=Object.create(T);o.prototype=j.constructor=a,a.constructor=o,a[x]=o.displayName="GeneratorFunction",O.isGeneratorFunction=function(t){var e="function"===typeof t&&t.constructor;return!!e&&(e===o||"GeneratorFunction"===(e.displayName||e.name))},O.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,a):(t.__proto__=a,x in t||(t[x]="GeneratorFunction")),t.prototype=Object.create(j),t},O.awrap=function(t){return{__await:t}},s(c.prototype),c.prototype[E]=function(){return this},O.AsyncIterator=c,O.async=function(t,e,r,i){var o=new c(n(t,e,r,i));return O.isGeneratorFunction(e)?o:o.next().then(function(t){return t.done?t.value:o.next()})},s(j),j[x]="Generator",j[w]=function(){return this},j.toString=function(){return"[object Generator]"},O.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},O.values=f,d.prototype={constructor:d,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=g,this.done=!1,this.delegate=null,this.method="next",this.arg=g,this.tryEntries.forEach(m),!t)for(var e in this)"t"===e.charAt(0)&&y.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=g)},stop:function(){this.done=!0;var t=this.tryEntries[0],e=t.completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){function e(e,r){return o.type="throw",o.arg=t,n.next=e,r&&(n.method="next",n.arg=g),!!r}if(this.done)throw t;for(var n=this,r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],o=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var a=y.call(i,"catchLoc"),s=y.call(i,"finallyLoc");if(a&&s){if(this.prev<i.catchLoc)return e(i.catchLoc,!0);if(this.prev<i.finallyLoc)return e(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return e(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return e(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&y.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,P):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),P},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),m(n),P}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;m(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:f(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=g),P}}}(function(){return this}()||Function("return this")())},function(t,e){},function(t,e){}]);
gutenberg/personality/src/.DS_Store CHANGED
Binary file
gutenberg/personality/src/block/block.js CHANGED
@@ -6,13 +6,12 @@ const { registerBlockType } = wp.blocks;
6
  const { SelectControl, TextControl } = wp.components;
7
  const { RichText } = wp.editor ;
8
 
9
- var dropdownOptions = false;
10
- var previewBlockOsTitle;
11
- var previewBlockOsImageUrl;
12
- var previewBlockOsView;
13
- var previewBlockOsEdit;
14
- var previewBlockOsStatistics;
15
- var options;
16
 
17
  registerBlockType( 'opinion-stage/block-os-personality', {
18
  title: __( 'Personality Quiz' ),
@@ -21,18 +20,13 @@ var options;
21
  keywords: [
22
  __( 'Opinion Stage Personality Quiz' ),
23
  __( 'Opinion Stage Personality' ),
24
- ],
25
  attributes: {
26
  embedUrl: {
27
  source: 'attribute',
28
  attribute: 'data-test-url',
29
  selector: 'div[data-test-url]'
30
- },
31
- oswpUrlShortcode: {
32
- source: 'attribute',
33
- attribute: 'data-test-url',
34
- selector: 'div[data-test-url]'
35
- },
36
  lockEmbed: {
37
  source: 'attribute',
38
  attribute: 'data-lock-embed',
@@ -42,173 +36,132 @@ var options;
42
  source: 'attribute',
43
  attribute: 'data-button-text',
44
  selector: 'div[data-button-text]'
45
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  },
47
  edit: function( props ) {
48
- let {attributes: {embedUrl, oswpUrlShortcode, lockEmbed, buttonText}, setAttributes} = props;
49
- const onDropdownChange = val => {
50
- if(val == ''){
51
- props.setAttributes({ embedUrl: '' });
52
- }else if(val != ''){
53
- props.setAttributes({ embedUrl: val });
54
- for (var i = 0; i < dropdownOptions.length; i++) {
55
- var getLandingPageUrlOs = function(href) {
56
- var locationUrlOS = document.createElement("a");
57
- locationUrlOS.href = href;
58
- return locationUrlOS;
59
- };
60
- var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
61
- var matchValue = locationUrlOS.pathname;
62
- if(val == matchValue){
63
- previewBlockOsTitle = dropdownOptions[i].attributes['title'];
64
- previewBlockOsImageUrl = dropdownOptions[i].attributes['image-url'];
65
- previewBlockOsView = dropdownOptions[i].attributes['landing-page-url'];
66
- previewBlockOsEdit = dropdownOptions[i].attributes['edit-url'];
67
- previewBlockOsStatistics = dropdownOptions[i].attributes['stats-url'];
68
- break;
69
- }
70
- }
71
- }else{
72
- }
73
- };
74
- const onEmbedButtonClick = event => {
75
- if( event.target.value == "Embed" ){
76
- if(embedUrl == '' || embedUrl == 'Select' || embedUrl == 'createNew' || embedUrl == 'refresh'){
77
- props.setAttributes({ lockEmbed: false, buttonText: "Embed" });
78
- }else{
79
- props.setAttributes({ lockEmbed: true, buttonText: "Change" });
80
- contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} onChange={onDropdownChange} className="components-select-control__input" />);
81
- }
82
- }else{
83
- props.setAttributes({ lockEmbed: false, buttonText: "Embed" });
84
- }
85
- };
86
-
87
- window.verifyOSInsert = function(widget){
88
- props.setAttributes({ oswpUrlShortcode: widget });
89
- var myOpts = document.getElementById('selectID').options;
90
- for(var i = 0; i < myOpts.length; i++){
91
- if(myOpts[i].value == widget){
92
- myOpts[i].defaultSelected = true;
93
- props.setAttributes({ lockEmbed: true, buttonText: "Change", embedUrl: widget });
94
- break;
95
- }
96
- }
97
- }
98
-
99
- var getOsCreateButtonClickUrl = osGutenData.onCreateButtonClickOs+'?w_type=outcome&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8';
100
- const onCreateButtonClick = value => {
101
- // Open Create new personality link in new page
102
- window.open(getOsCreateButtonClickUrl, '_blank').focus();
103
- };
104
-
105
- if(!buttonText){
106
- props.setAttributes({ buttonText: 'Embed' });
107
- }
108
 
 
109
  var getCallBackUrlOs = osGutenData.callbackUrlOs;
110
  var callback_url = getCallBackUrlOs;
111
  var formActionUrlOS = osGutenData.getActionUrlOS;
112
  var getlogoImageLinkOs = osGutenData.getLogoImageLink;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  const onConnectOSWPButtonClick = value => {
114
- // Open Connect to opinionstage
115
  window.location.replace(callback_url);
116
  };
117
- // Populate list ajax function
118
- function OsPolulateList() {
119
- var opinionStageWidgetVersion = osGutenData.OswpPluginVersion;
120
- var opinionStageClientToken = osGutenData.OswpClientToken;
121
- var opinionstageFetchDataUrl = osGutenData.OswpFetchDataUrl+'?type=outcome&page=1&per_page=99';
122
- fetch(opinionstageFetchDataUrl, {
123
- method: "GET",
124
- headers: {
125
- 'Accept':'application/vnd.api+json',
126
- 'Content-Type':'application/vnd.api+json',
127
- 'OSWP-Plugin-Version':opinionStageWidgetVersion,
128
- 'OSWP-Client-Token': opinionStageClientToken
129
- },
130
- })
131
- .then(async res => {
132
- var data = await res.json();
133
- data = data.data;
134
- dropdownOptions = data;
135
- // force reprinting instead!!
136
- props.setAttributes({ buttonText: 'Embed'});
137
- props.setAttributes({ buttonText: buttonText});
138
- if(buttonText == 'Change' && embedUrl !='Select'){
139
- props.setAttributes({ embedUrl: embedUrl });
140
- }else{
141
- props.setAttributes({ embedUrl: 'Select' });
142
- }
143
- })
144
- .catch(function(err) {
145
- console.log('ERROR: ' + err.message);
146
- });
147
- }
148
  // Checking for Opinion Stage connection
149
  if(osGutenData.isOsConnected == ''){
150
- $(document).ready(function () {
151
- $('span#oswpLauncherContentPopuppersonality , #owspLaunchInputCreate').live('click', function(e) {
152
- e.preventDefault();
153
- setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
154
- });
155
- });
156
  return (
157
  <div className={ props.className }>
158
  <div className="os-personality-wrapper components-placeholder">
159
  <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
160
  <p className="components-heading">Please connect WordPress to Opinion Stage to start adding personality</p>
161
  <button className="components-button is-button is-default is-block is-primary" onClick={onConnectOSWPButtonClick}>Connect</button>
162
- </div>
 
163
  </div>
164
  );
165
- }else{
166
- if(dropdownOptions == false){
167
- options = [{value:'Select',label:'Select a personality'},{value:'refresh',label:'Refresh'}];
168
- OsPolulateList();
169
- }else{
170
- options = [{value:'Select',label:'Select a personality'},{value:'refresh',label:'Refresh'},{value:'',label:'-----------------'}];
171
- for (var i = 0; i < dropdownOptions.length; i++) {
172
- options[options.length] = {
173
- value: dropdownOptions[i].attributes['landing-page-url'].replace('https://www.opinionstage.com',''),
174
- label: dropdownOptions[i].attributes['title'],
175
- };
176
- var getLandingPageUrlOs = function(href) {
177
- var locationUrlOS = document.createElement("a");
178
- locationUrlOS.href = href;
179
- return locationUrlOS;
180
- };
181
- var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
182
- var matchValue = locationUrlOS.pathname;
183
- if(embedUrl == matchValue){
184
- previewBlockOsTitle = dropdownOptions[i].attributes['title'];
185
- previewBlockOsImageUrl = dropdownOptions[i].attributes['image-url'];
186
- previewBlockOsView = dropdownOptions[i].attributes['landing-page-url'];
187
- previewBlockOsEdit = dropdownOptions[i].attributes['edit-url'];
188
- previewBlockOsStatistics = dropdownOptions[i].attributes['stats-url'];
189
- var previewBlockOsWidgetID = dropdownOptions[i].id;
190
-
191
- }
192
- }
193
- }
194
- if(embedUrl == 'refresh'){
195
- OsPolulateList();
196
- }
197
- var contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} onChange={onDropdownChange} className="components-select-control__input" />);
198
  $(document).ready(function () {
 
199
  $('span#oswpLauncherContentPopuppersonality').live('click', function(e) {
200
  e.preventDefault();
201
  setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
202
  var text = $(this).attr('data-os-block');
203
  $("button#dropbtn span").text(text);
204
- var inputs = $(".filter__itm");
205
  for(var i = 0; i < inputs.length; i++){
206
- if($(inputs[i]).text() == text){
207
- setTimeout(function(){$(inputs[i]).trigger('click');},1000);
208
  setTimeout(function(){
209
- $('.progress_message').css('display', 'none');
210
- $('.content__list').css('display', 'block');
211
- },2500);
 
 
 
212
  $('button.content__links-itm').live('click', function(e) {
213
  $('.tingle-modal.opinionstage-content-popup').hide();
214
  $('.tingle-modal.opinionstage-content-popup.tingle-modal--visible').hide();
@@ -218,83 +171,89 @@ var options;
218
  else {
219
  $('.progress_message').css('display', 'block');
220
  $('.content__list').css('display', 'none');
221
- console.log('test');
222
  }
223
  }
224
  });
225
  });
226
 
227
- var contentViewEditStatOs = (
228
- <div className="os-personality-wrapper components-placeholder">
229
- <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
230
- <span id="oswpLauncherContentPopuppersonality" className="components-button is-button is-default is-block is-primary" data-opinionstage-content-launch data-os-block="personality quiz">Select a Personality Quiz</span>
231
- <input type="button" value="Create a New Personality Quiz" className="components-button is-button is-default is-block is-primary" onClick={onCreateButtonClick} />
232
- <div className="components-placeholder__fieldset">
233
- {contentDropdown}
234
- <input type="button" value={buttonText} className="components-button is-button is-default is-large" id="clickMe" onClick={onEmbedButtonClick} />
235
- </div>
236
- </div>
237
- );
238
-
239
- var dataOpinionStageEmbedUrl = 'https://www.opinionstage.com/api/v1/widgets/'+embedUrl+'/code.json?comments=true&amp;sharing=true&amp;recommendations=false&amp;width=';
240
- var OpinionStageDataIframe = 'https://www.opinionstage.com/'+embedUrl+'?wid=0&amp;em=1&amp;comments=null&amp;referring_widget='+embedUrl+'&amp;autoswitch=1&amp;of=&amp;os_utm_source=null';
241
- (function(d, s, id){
242
- var js,
243
- fjs = d.getElementsByTagName(s)[0],
244
- r = Math.floor(new Date().getTime() / 1000000);
245
- if (d.getElementById(id)) {return;}
246
- js = d.createElement(s); js.id = id; js.async=1;
247
- js.src = "https://www.opinionstage.com/assets/loader.js?" + r;
248
- fjs.parentNode.insertBefore(js, fjs);
249
- }(document, 'script', 'os-widget-jssdk'));
250
- previewBlockOsWidgetID = 'os-widget-'+previewBlockOsWidgetID;
251
-
252
- if(embedUrl != '' && embedUrl != 'Select' && embedUrl){
 
 
 
 
 
 
 
253
  if(buttonText == 'Embed'){
254
  contentViewEditStatOs
255
- }else if(buttonText == 'Change'){
256
  contentViewEditStatOs = (
257
- <div className="os-personality-wrapper components-placeholder">
258
- <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
259
- <div className="components-preview__block" >
260
- <div className="components-preview__leftBlockImage">
261
- <img src={previewBlockOsImageUrl} alt={previewBlockOsTitle} className="image" />
262
- <div className="overlay">
263
- <div className="text">
264
- <a href={previewBlockOsView} target="_blank"> View </a>
265
- <a href={previewBlockOsEdit} target="_blank"> Edit </a>
266
- <a href={previewBlockOsStatistics} target="_blank"> Statistics </a>
267
- <input type="button" value={buttonText} className="components-button is-button is-default is-large left-align" onClick={onEmbedButtonClick} />
268
- </div>
 
 
 
 
269
  </div>
270
- </div>
271
- <div className="components-preview__rightBlockContent">
272
- <div className="components-placeholder__label">Personality Quiz: {previewBlockOsTitle}</div>
273
- </div>
274
- </div>
275
- </div>
276
- );
277
- contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} disabled onChange={onDropdownChange} className="components-select-control__input" />);
278
  }
279
- }else if(embedUrl == 'Select' || embedUrl == '' || embedUrl == 'refresh'){
280
  contentViewEditStatOs
281
  }else{
282
  props.setAttributes({ buttonText: 'Embed'});
283
  contentViewEditStatOs
284
  }
285
-
286
-
287
- return (
288
  <div className={ props.className }>
289
- {contentViewEditStatOs}
 
290
  </div>
291
  );
292
  }
293
  },
294
- save: function( {attributes: {embedUrl, oswpUrlShortcode, lockEmbed, buttonText}} ) {
295
  return (
296
- <div class="os-personality-wrapper" data-type="personality" data-test-url={oswpUrlShortcode} data-lock-embed={lockEmbed} data-button-text={buttonText}>
297
- [os-widget path="{oswpUrlShortcode}"]
 
298
  </div>
299
  );
300
  },
6
  const { SelectControl, TextControl } = wp.components;
7
  const { RichText } = wp.editor ;
8
 
9
+ var dropdownOptions = false;
10
+ var insertItemImage = false;
11
+ var insertItemOsTitle = false;
12
+ var insertItemOsView = false;
13
+ var insertItemOsEdit = false;
14
+ var insertItemOsStatistics = false;
 
15
 
16
  registerBlockType( 'opinion-stage/block-os-personality', {
17
  title: __( 'Personality Quiz' ),
20
  keywords: [
21
  __( 'Opinion Stage Personality Quiz' ),
22
  __( 'Opinion Stage Personality' ),
23
+ ],
24
  attributes: {
25
  embedUrl: {
26
  source: 'attribute',
27
  attribute: 'data-test-url',
28
  selector: 'div[data-test-url]'
29
+ },
 
 
 
 
 
30
  lockEmbed: {
31
  source: 'attribute',
32
  attribute: 'data-lock-embed',
36
  source: 'attribute',
37
  attribute: 'data-button-text',
38
  selector: 'div[data-button-text]'
39
+ },
40
+ insertItemImage: {
41
+ source: 'attribute',
42
+ attribute: 'data-image-url',
43
+ selector: 'div[data-image-url]'
44
+ },
45
+ insertItemOsTitle: {
46
+ source: 'attribute',
47
+ attribute: 'data-title-url',
48
+ selector: 'div[data-title-url]'
49
+ },
50
+ insertItemOsView: {
51
+ source: 'attribute',
52
+ attribute: 'data-view-url',
53
+ selector: 'div[data-view-url]'
54
+ },
55
+ insertItemOsEdit: {
56
+ source: 'attribute',
57
+ attribute: 'data-edit-url',
58
+ selector: 'div[data-edit-url]'
59
+ },
60
+ insertItemOsStatistics: {
61
+ source: 'attribute',
62
+ attribute: 'data-statistics-url',
63
+ selector: 'div[data-statistics-url]'
64
+ }
65
  },
66
  edit: function( props ) {
67
+ // Setting Attributes
68
+ let {attributes: {embedUrl, lockEmbed, buttonText, insertItemImage,insertItemOsTitle,insertItemOsView,insertItemOsEdit,insertItemOsStatistics}, setAttributes} = props;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ // Fetching Localized variables
71
  var getCallBackUrlOs = osGutenData.callbackUrlOs;
72
  var callback_url = getCallBackUrlOs;
73
  var formActionUrlOS = osGutenData.getActionUrlOS;
74
  var getlogoImageLinkOs = osGutenData.getLogoImageLink;
75
+
76
+ // Select Button Click functionality
77
+ const onSelectButtonClick = value => {
78
+ window.verifyOSInsert = function(widget){
79
+ props.setAttributes({ embedUrl: widget, buttonText:'Change' });
80
+
81
+ var opinionStageWidgetVersion = osGutenData.OswpPluginVersion;
82
+ var opinionStageClientToken = osGutenData.OswpClientToken;
83
+ var opinionstageFetchDataUrl = osGutenData.OswpFetchDataUrl+'?type=outcome&page=1&per_page=99';
84
+ fetch(opinionstageFetchDataUrl, {
85
+ method: "GET",
86
+ headers: {
87
+ 'Accept':'application/vnd.api+json',
88
+ 'Content-Type':'application/vnd.api+json',
89
+ 'OSWP-Plugin-Version':opinionStageWidgetVersion,
90
+ 'OSWP-Client-Token': opinionStageClientToken
91
+ },
92
+ })
93
+ .then(async res => {
94
+ var data = await res.json();
95
+ data = data.data;
96
+ dropdownOptions = data;
97
+ // force reprinting instead!!
98
+ props.setAttributes({ buttonText: buttonText});
99
+
100
+ })
101
+ .catch(function(err) {
102
+ console.log('ERROR: ' + err.message);
103
+ });
104
+ }
105
+ }
106
+
107
+ // Change Button Click functionality
108
+ const onChangeButtonClick = value => {
109
+ props.setAttributes({
110
+ embedUrl: '',
111
+ buttonText:'Embed',
112
+ lockEmbed: false,
113
+ insertItemImage: false,
114
+ insertItemOsTitle: false,
115
+ insertItemOsView: false,
116
+ insertItemOsEdit: false,
117
+ insertItemOsStatistics: false
118
+ });
119
+ }
120
+
121
+ // Connect to Opinionstage Callback Url
122
  const onConnectOSWPButtonClick = value => {
 
123
  window.location.replace(callback_url);
124
  };
125
+
126
+ // Create New Item Url (personality)
127
+ var getOsCreateButtonClickUrl = osGutenData.onCreateButtonClickOs+'?w_type=outcome&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8';
128
+ const onCreateButtonClick = value => {
129
+ // Open Create new personality link in new page
130
+ window.open(getOsCreateButtonClickUrl, '_blank').focus();
131
+ };
132
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  // Checking for Opinion Stage connection
134
  if(osGutenData.isOsConnected == ''){
135
+ // Not Connected to opinionstage
 
 
 
 
 
136
  return (
137
  <div className={ props.className }>
138
  <div className="os-personality-wrapper components-placeholder">
139
  <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
140
  <p className="components-heading">Please connect WordPress to Opinion Stage to start adding personality</p>
141
  <button className="components-button is-button is-default is-block is-primary" onClick={onConnectOSWPButtonClick}>Connect</button>
142
+ </div>
143
+ <div></div>
144
  </div>
145
  );
146
+ }else{
147
+ // Connected to opinionstage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  $(document).ready(function () {
149
+ // Content Popup Launch Working
150
  $('span#oswpLauncherContentPopuppersonality').live('click', function(e) {
151
  e.preventDefault();
152
  setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
153
  var text = $(this).attr('data-os-block');
154
  $("button#dropbtn span").text(text);
155
+ var inputs = $(".filter__itm");
156
  for(var i = 0; i < inputs.length; i++){
157
+ if($(inputs[i]).text() == text){
 
158
  setTimeout(function(){
159
+ $(inputs[i]).trigger('click');
160
+ },1000);
161
+ setTimeout(function(){
162
+ $('.progress_message').css('display', 'none');
163
+ $('.content__list').css('display', 'block');
164
+ },2500);
165
  $('button.content__links-itm').live('click', function(e) {
166
  $('.tingle-modal.opinionstage-content-popup').hide();
167
  $('.tingle-modal.opinionstage-content-popup.tingle-modal--visible').hide();
171
  else {
172
  $('.progress_message').css('display', 'block');
173
  $('.content__list').css('display', 'none');
 
174
  }
175
  }
176
  });
177
  });
178
 
179
+ // Fetching Ajax Call Result
180
+ if(dropdownOptions != false){
181
+ for (var i = 0; i < dropdownOptions.length; i++) {
182
+ var getLandingPageUrlOs = function(href) {
183
+ var locationUrlOS = document.createElement("a");
184
+ locationUrlOS.href = href;
185
+ return locationUrlOS;
186
+ };
187
+ var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
188
+ var matchValue = locationUrlOS.pathname;
189
+ if(embedUrl == matchValue){
190
+ props.setAttributes({lockEmbed: true, buttonText: "Change" });
191
+ props.setAttributes({ insertItemImage : dropdownOptions[i].attributes['image-url'] });
192
+ props.setAttributes({ insertItemOsTitle : dropdownOptions[i].attributes['title'] });
193
+ props.setAttributes({ insertItemOsView : dropdownOptions[i].attributes['landing-page-url'] });
194
+ props.setAttributes({ insertItemOsEdit : dropdownOptions[i].attributes['edit-url'] });
195
+ props.setAttributes({ insertItemOsStatistics : dropdownOptions[i].attributes['stats-url'] });
196
+ break;
197
+ }
198
+ }
199
+ }
200
+
201
+ // Content On Editor
202
+ var contentViewEditStatOs = (
203
+ <div className="os-personality-wrapper components-placeholder">
204
+ <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
205
+ <span id="oswpLauncherContentPopuppersonality" className="components-button is-button is-default is-block is-primary" data-opinionstage-content-launch data-os-block="personality quiz" onClick={onSelectButtonClick} >Select a Personality Quiz</span>
206
+ <input type="button" value="Create a New Personality Quiz" className="components-button is-button is-default is-block is-primary" onClick={onCreateButtonClick} />
207
+ <span></span>
208
+ </div>
209
+ );
210
+
211
+ if(embedUrl != '' && embedUrl){
212
  if(buttonText == 'Embed'){
213
  contentViewEditStatOs
214
+ }else if(buttonText == 'Change'){
215
  contentViewEditStatOs = (
216
+ <div className="os-personality-wrapper components-placeholder">
217
+ <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
218
+ <div className="components-preview__block" >
219
+ <div className="components-preview__leftBlockImage">
220
+ <img src={insertItemImage} alt={insertItemOsTitle} className="image" />
221
+ <div className="overlay">
222
+ <div className="text">
223
+ <a href={insertItemOsView} target="_blank"> View </a>
224
+ <a href={insertItemOsEdit} target="_blank"> Edit </a>
225
+ <a href={insertItemOsStatistics} target="_blank"> Statistics </a>
226
+ <input type="button" value={buttonText} className="components-button is-button is-default is-large left-align" onClick={onChangeButtonClick}/>
227
+ </div>
228
+ </div>
229
+ </div>
230
+ <div className="components-preview__rightBlockContent">
231
+ <div className="components-placeholder__label">Personality Quiz: {insertItemOsTitle}</div>
232
  </div>
233
+ </div>
234
+ <span></span>
235
+ </div>
236
+ );
 
 
 
 
237
  }
238
+ }else if(embedUrl == '' || jQuery.type(embedUrl) === "undefined"){
239
  contentViewEditStatOs
240
  }else{
241
  props.setAttributes({ buttonText: 'Embed'});
242
  contentViewEditStatOs
243
  }
244
+ return (
 
 
245
  <div className={ props.className }>
246
+ {contentViewEditStatOs}
247
+ <span></span>
248
  </div>
249
  );
250
  }
251
  },
252
+ save: function( {attributes: {embedUrl, lockEmbed, buttonText, insertItemImage, insertItemOsTitle, insertItemOsView, insertItemOsEdit, insertItemOsStatistics }} ) {
253
  return (
254
+ <div class="os-personality-wrapper" data-type="personality" data-image-url={insertItemImage} data-title-url={insertItemOsTitle} data-view-url={insertItemOsView} data-statistics-url={insertItemOsStatistics} data-edit-url={insertItemOsEdit} data-test-url={embedUrl} data-lock-embed={lockEmbed} data-button-text={buttonText}>
255
+ [os-widget path="{embedUrl}"]
256
+ <span></span>
257
  </div>
258
  );
259
  },
gutenberg/poll/dist/blocks.build.js CHANGED
@@ -1 +1 @@
1
- !function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});n(1)},function(e,t,n){"use strict";function r(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){function r(o,a){try{var i=t[o](a),l=i.value}catch(e){return void n(e)}if(!i.done)return Promise.resolve(l).then(function(e){r("next",e)},function(e){r("throw",e)});e(l)}return r("next")})}}var o,a,i,l,s,c,u=n(2),p=n.n(u),m=n(5),f=(n.n(m),n(6)),d=(n.n(f),wp.i18n.__),h=wp.blocks.registerBlockType,g=wp.components,v=g.SelectControl,b=(g.TextControl,wp.editor.RichText,!1);h("opinion-stage/block-os-poll",{title:d("Poll"),icon:"chart-bar",category:"opinion-stage",keywords:[d("Opinion Stage Poll"),d("Opinion Stage Poll")],attributes:{embedUrl:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},oswpUrlShortcode:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},lockEmbed:{source:"attribute",attribute:"data-lock-embed",selector:"div[data-lock-embed]"},buttonText:{source:"attribute",attribute:"data-button-text",selector:"div[data-button-text]"}},edit:function(e){function t(){var t=this,n=osGutenData.OswpPluginVersion,o=osGutenData.OswpClientToken,a=osGutenData.OswpFetchDataUrl+"?type=poll&page=1&per_page=99";fetch(a,{method:"GET",headers:{Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json","OSWP-Plugin-Version":n,"OSWP-Client-Token":o}}).then(function(){var n=r(p.a.mark(function n(r){var o;return p.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.json();case 2:o=t.sent,o=o.data,b=o,e.setAttributes({buttonText:"Embed"}),e.setAttributes({buttonText:m}),"Change"==m&&"Select"!=u?e.setAttributes({embedUrl:u}):e.setAttributes({embedUrl:"Select"});case 8:case"end":return t.stop()}},n,t)}));return function(e){return n.apply(this,arguments)}}()).catch(function(e){console.log("ERROR: "+e.message)})}var n=e.attributes,u=n.embedUrl,m=(n.oswpUrlShortcode,n.lockEmbed,n.buttonText),f=(e.setAttributes,function(t){if(""==t)e.setAttributes({embedUrl:""});else if(""!=t){e.setAttributes({embedUrl:t});for(var n=0;n<b.length;n++){var r=function(e){var t=document.createElement("a");return t.href=e,t}(b[n].attributes["landing-page-url"]),c=r.pathname;if(t==c){o=b[n].attributes.title,a=b[n].attributes["image-url"],i=b[n].attributes["landing-page-url"],l=b[n].attributes["edit-url"],s=b[n].attributes["stats-url"];break}}}}),d=function(t){"Embed"==t.target.value?""==u||"Select"==u||"createNew"==u||"refresh"==u?e.setAttributes({lockEmbed:!1,buttonText:"Embed"}):(e.setAttributes({lockEmbed:!0,buttonText:"Change"}),O=wp.element.createElement(v,{id:"selectID",options:c,value:u,onChange:f,className:"components-select-control__input"})):e.setAttributes({lockEmbed:!1,buttonText:"Embed"})};window.verifyOSInsert=function(t){e.setAttributes({oswpUrlShortcode:t});for(var n=document.getElementById("selectID").options,r=0;r<n.length;r++)if(n[r].value==t){n[r].defaultSelected=!0,e.setAttributes({lockEmbed:!0,buttonText:"Change",embedUrl:t});break}};var h=osGutenData.onCreateButtonClickOs+"?w_type=poll&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8",g=function(e){window.open(h,"_blank").focus()};m||e.setAttributes({buttonText:"Embed"});var w=osGutenData.callbackUrlOs,y=w,E=(osGutenData.getActionUrlOS,osGutenData.getLogoImageLink),k=function(e){window.location.replace(y)};if(""==osGutenData.isOsConnected)return $(document).ready(function(){$("span#oswpLauncherContentPopuppoll , #owspLaunchInputCreate").live("click",function(e){e.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500)})}),wp.element.createElement("div",{className:e.className},wp.element.createElement("div",{className:"os-poll-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:E,alt:""})),wp.element.createElement("p",{className:"components-heading"},"Please connect WordPress to Opinion Stage to start adding polls"),wp.element.createElement("button",{className:"components-button is-button is-default is-block is-primary",onClick:k},"Connect")));if(0==b)c=[{value:"Select",label:"Select a poll"},{value:"refresh",label:"Refresh"}],t();else{c=[{value:"Select",label:"Select a poll"},{value:"refresh",label:"Refresh"},{value:"",label:"-----------------"}];for(var x=0;x<b.length;x++){c[c.length]={value:b[x].attributes["landing-page-url"].replace("https://www.opinionstage.com",""),label:b[x].attributes.title};var _=function(e){var t=document.createElement("a");return t.href=e,t}(b[x].attributes["landing-page-url"]),N=_.pathname;if(u==N){o=b[x].attributes.title,a=b[x].attributes["image-url"],i=b[x].attributes["landing-page-url"],l=b[x].attributes["edit-url"],s=b[x].attributes["stats-url"];var L=b[x].id}}}"refresh"==u&&t();var O=wp.element.createElement(v,{id:"selectID",options:c,value:u,onChange:f,className:"components-select-control__input"});$(document).ready(function(){$("span#oswpLauncherContentPopuppoll").live("click",function(e){e.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500);var t=$(this).attr("data-os-block");$("button#dropbtn span").text(t);for(var n=$(".filter__itm"),r=0;r<n.length;r++){if($(n[r]).text()==t){setTimeout(function(){$(n[r]).trigger("click")},1e3),setTimeout(function(){$(".progress_message").css("display","none"),$(".content__list").css("display","block")},2500),$("button.content__links-itm").live("click",function(e){$(".tingle-modal.opinionstage-content-popup").hide(),$(".tingle-modal.opinionstage-content-popup.tingle-modal--visible").hide()});break}$(".progress_message").css("display","block"),$(".content__list").css("display","none"),console.log("test")}})});var P=wp.element.createElement("div",{className:"os-poll-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:E,alt:""})),wp.element.createElement("span",{id:"oswpLauncherContentPopuppoll",className:"components-button is-button is-default is-block is-primary","data-opinionstage-content-launch":!0,"data-os-block":"poll"},"Select a Poll"),wp.element.createElement("input",{type:"button",value:"Create a New Poll",className:"components-button is-button is-default is-block is-primary",onClick:g}),wp.element.createElement("div",{className:"components-placeholder__fieldset"},O,wp.element.createElement("input",{type:"button",value:m,className:"components-button is-button is-default is-large",id:"clickMe",onClick:d})));return function(e,t,n){var r,o=e.getElementsByTagName(t)[0],a=Math.floor((new Date).getTime()/1e6);e.getElementById(n)||(r=e.createElement(t),r.id=n,r.async=1,r.src="https://www.opinionstage.com/assets/loader.js?"+a,o.parentNode.insertBefore(r,o))}(document,"script","os-widget-jssdk"),L="os-widget-"+L,""!=u&&"Select"!=u&&u?"Embed"==m||"Change"==m&&(P=wp.element.createElement("div",{className:"os-poll-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:E,alt:""})),wp.element.createElement("div",{className:"components-preview__block"},wp.element.createElement("div",{className:"components-preview__leftBlockImage"},wp.element.createElement("img",{src:a,alt:o,className:"image"}),wp.element.createElement("div",{className:"overlay"},wp.element.createElement("div",{className:"text"},wp.element.createElement("a",{href:i,target:"_blank"}," View "),wp.element.createElement("a",{href:l,target:"_blank"}," Edit "),wp.element.createElement("a",{href:s,target:"_blank"}," Statistics "),wp.element.createElement("input",{type:"button",value:m,className:"components-button is-button is-default is-large left-align",onClick:d})))),wp.element.createElement("div",{className:"components-preview__rightBlockContent"},wp.element.createElement("div",{className:"components-placeholder__label"},"Poll: ",o)))),O=wp.element.createElement(v,{id:"selectID",options:c,value:u,disabled:!0,onChange:f,className:"components-select-control__input"})):"Select"==u||""==u||"refresh"==u||e.setAttributes({buttonText:"Embed"}),wp.element.createElement("div",{className:e.className},P)},save:function(e){var t=e.attributes,n=(t.embedUrl,t.oswpUrlShortcode),r=t.lockEmbed,o=t.buttonText;return wp.element.createElement("div",{class:"os-poll-wrapper","data-type":"poll","data-test-url":n,"data-lock-embed":r,"data-button-text":o},'[os-widget path="',n,'"]')}})},function(e,t,n){e.exports=n(3)},function(e,t,n){var r=function(){return this}()||Function("return this")(),o=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,a=o&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,e.exports=n(4),o)r.regeneratorRuntime=a;else try{delete r.regeneratorRuntime}catch(e){r.regeneratorRuntime=void 0}},function(e,t){!function(t){"use strict";function n(e,t,n,r){var a=t&&t.prototype instanceof o?t:o,i=Object.create(a.prototype),l=new f(r||[]);return i._invoke=c(e,n,l),i}function r(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}function o(){}function a(){}function i(){}function l(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function s(e){function t(n,o,a,i){var l=r(e[n],e,o);if("throw"!==l.type){var s=l.arg,c=s.value;return c&&"object"===typeof c&&b.call(c,"__await")?Promise.resolve(c.__await).then(function(e){t("next",e,a,i)},function(e){t("throw",e,a,i)}):Promise.resolve(c).then(function(e){s.value=e,a(s)},i)}i(l.arg)}function n(e,n){function r(){return new Promise(function(r,o){t(e,n,r,o)})}return o=o?o.then(r,r):r()}var o;this._invoke=n}function c(e,t,n){var o=N;return function(a,i){if(o===O)throw new Error("Generator is already running");if(o===P){if("throw"===a)throw i;return h()}for(n.method=a,n.arg=i;;){var l=n.delegate;if(l){var s=u(l,n);if(s){if(s===S)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===N)throw o=P,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=O;var c=r(e,t,n);if("normal"===c.type){if(o=n.done?P:L,c.arg===S)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=P,n.method="throw",n.arg=c.arg)}}}function u(e,t){var n=e.iterator[t.method];if(n===g){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=g,u(e,t),"throw"===t.method))return S;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return S}var o=r(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,S;var a=o.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=g),t.delegate=null,S):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,S)}function p(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function m(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function f(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(p,this),this.reset(!0)}function d(e){if(e){var t=e[y];if(t)return t.call(e);if("function"===typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(b.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=g,t.done=!0,t};return r.next=r}}return{next:h}}function h(){return{value:g,done:!0}}var g,v=Object.prototype,b=v.hasOwnProperty,w="function"===typeof Symbol?Symbol:{},y=w.iterator||"@@iterator",E=w.asyncIterator||"@@asyncIterator",k=w.toStringTag||"@@toStringTag",x="object"===typeof e,_=t.regeneratorRuntime;if(_)return void(x&&(e.exports=_));_=t.regeneratorRuntime=x?e.exports:{},_.wrap=n;var N="suspendedStart",L="suspendedYield",O="executing",P="completed",S={},T={};T[y]=function(){return this};var C=Object.getPrototypeOf,j=C&&C(C(d([])));j&&j!==v&&b.call(j,y)&&(T=j);var A=i.prototype=o.prototype=Object.create(T);a.prototype=A.constructor=i,i.constructor=a,i[k]=a.displayName="GeneratorFunction",_.isGeneratorFunction=function(e){var t="function"===typeof e&&e.constructor;return!!t&&(t===a||"GeneratorFunction"===(t.displayName||t.name))},_.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,i):(e.__proto__=i,k in e||(e[k]="GeneratorFunction")),e.prototype=Object.create(A),e},_.awrap=function(e){return{__await:e}},l(s.prototype),s.prototype[E]=function(){return this},_.AsyncIterator=s,_.async=function(e,t,r,o){var a=new s(n(e,t,r,o));return _.isGeneratorFunction(t)?a:a.next().then(function(e){return e.done?e.value:a.next()})},l(A),A[k]="Generator",A[y]=function(){return this},A.toString=function(){return"[object Generator]"},_.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},_.values=d,f.prototype={constructor:f,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=g,this.done=!1,this.delegate=null,this.method="next",this.arg=g,this.tryEntries.forEach(m),!e)for(var t in this)"t"===t.charAt(0)&&b.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=g)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){function t(t,r){return a.type="throw",a.arg=e,n.next=t,r&&(n.method="next",n.arg=g),!!r}if(this.done)throw e;for(var n=this,r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var i=b.call(o,"catchLoc"),l=b.call(o,"finallyLoc");if(i&&l){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(i){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&b.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,S):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),S},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),m(n),S}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;m(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:d(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=g),S}}}(function(){return this}()||Function("return this")())},function(e,t){},function(e,t){}]);
1
+ !function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});n(1)},function(t,e,n){"use strict";function r(t){return function(){var e=t.apply(this,arguments);return new Promise(function(t,n){function r(o,i){try{var a=e[o](i),s=a.value}catch(t){return void n(t)}if(!a.done)return Promise.resolve(s).then(function(t){r("next",t)},function(t){r("throw",t)});t(s)}return r("next")})}}var o=n(2),i=n.n(o),a=n(5),s=(n.n(a),n(6)),l=(n.n(s),wp.i18n.__),c=wp.blocks.registerBlockType,u=wp.components,p=(u.SelectControl,u.TextControl,wp.editor.RichText,!1);c("opinion-stage/block-os-poll",{title:l("Poll"),icon:"chart-bar",category:"opinion-stage",keywords:[l("Opinion Stage Poll"),l("Opinion Stage Poll")],attributes:{embedUrl:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},lockEmbed:{source:"attribute",attribute:"data-lock-embed",selector:"div[data-lock-embed]"},buttonText:{source:"attribute",attribute:"data-button-text",selector:"div[data-button-text]"},insertItemImage:{source:"attribute",attribute:"data-image-url",selector:"div[data-image-url]"},insertItemOsTitle:{source:"attribute",attribute:"data-title-url",selector:"div[data-title-url]"},insertItemOsView:{source:"attribute",attribute:"data-view-url",selector:"div[data-view-url]"},insertItemOsEdit:{source:"attribute",attribute:"data-edit-url",selector:"div[data-edit-url]"},insertItemOsStatistics:{source:"attribute",attribute:"data-statistics-url",selector:"div[data-statistics-url]"}},edit:function(t){var e=t.attributes,n=e.embedUrl,o=(e.lockEmbed,e.buttonText),a=e.insertItemImage,s=e.insertItemOsTitle,l=e.insertItemOsView,c=e.insertItemOsEdit,u=e.insertItemOsStatistics,m=(t.setAttributes,osGutenData.callbackUrlOs),d=m,f=(osGutenData.getActionUrlOS,osGutenData.getLogoImageLink),h=function(e){window.verifyOSInsert=function(e){var n=this;t.setAttributes({embedUrl:e,buttonText:"Change"});var a=osGutenData.OswpPluginVersion,s=osGutenData.OswpClientToken,l=osGutenData.OswpFetchDataUrl+"?type=poll&page=1&per_page=99";fetch(l,{method:"GET",headers:{Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json","OSWP-Plugin-Version":a,"OSWP-Client-Token":s}}).then(function(){var e=r(i.a.mark(function e(r){var a;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.json();case 2:a=e.sent,a=a.data,p=a,t.setAttributes({buttonText:o});case 6:case"end":return e.stop()}},e,n)}));return function(t){return e.apply(this,arguments)}}()).catch(function(t){console.log("ERROR: "+t.message)})}},g=function(e){t.setAttributes({embedUrl:"",buttonText:"Embed",lockEmbed:!1,insertItemImage:!1,insertItemOsTitle:!1,insertItemOsView:!1,insertItemOsEdit:!1,insertItemOsStatistics:!1})},v=function(t){window.location.replace(d)},b=osGutenData.onCreateButtonClickOs+"?w_type=poll&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8",w=function(t){window.open(b,"_blank").focus()};if(""==osGutenData.isOsConnected)return wp.element.createElement("div",{className:t.className},wp.element.createElement("div",{className:"os-poll-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:f,alt:""})),wp.element.createElement("p",{className:"components-heading"},"Please connect WordPress to Opinion Stage to start adding polls"),wp.element.createElement("button",{className:"components-button is-button is-default is-block is-primary",onClick:v},"Connect")),wp.element.createElement("div",null));if($(document).ready(function(){$("span#oswpLauncherContentPopuppoll").live("click",function(t){t.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500);var e=$(this).attr("data-os-block");$("button#dropbtn span").text(e);for(var n=$(".filter__itm"),r=0;r<n.length;r++){if($(n[r]).text()==e){setTimeout(function(){$(n[r]).trigger("click")},1e3),setTimeout(function(){$(".progress_message").css("display","none"),$(".content__list").css("display","block")},2500),$("button.content__links-itm").live("click",function(t){$(".tingle-modal.opinionstage-content-popup").hide(),$(".tingle-modal.opinionstage-content-popup.tingle-modal--visible").hide()});break}$(".progress_message").css("display","block"),$(".content__list").css("display","none")}})}),0!=p)for(var y=0;y<p.length;y++){var E=function(t){var e=document.createElement("a");return e.href=t,e}(p[y].attributes["landing-page-url"]),x=E.pathname;if(n==x){t.setAttributes({lockEmbed:!0,buttonText:"Change"}),t.setAttributes({insertItemImage:p[y].attributes["image-url"]}),t.setAttributes({insertItemOsTitle:p[y].attributes.title}),t.setAttributes({insertItemOsView:p[y].attributes["landing-page-url"]}),t.setAttributes({insertItemOsEdit:p[y].attributes["edit-url"]}),t.setAttributes({insertItemOsStatistics:p[y].attributes["stats-url"]});break}}var k=wp.element.createElement("div",{className:"os-poll-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:f,alt:""})),wp.element.createElement("span",{id:"oswpLauncherContentPopuppoll",className:"components-button is-button is-default is-block is-primary","data-opinionstage-content-launch":!0,"data-os-block":"poll",onClick:h},"Select a Poll"),wp.element.createElement("input",{type:"button",value:"Create a New Poll",className:"components-button is-button is-default is-block is-primary",onClick:w}),wp.element.createElement("span",null));return""!=n&&n?"Embed"==o||"Change"==o&&(k=wp.element.createElement("div",{className:"os-poll-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:f,alt:""})),wp.element.createElement("div",{className:"components-preview__block"},wp.element.createElement("div",{className:"components-preview__leftBlockImage"},wp.element.createElement("img",{src:a,alt:s,className:"image"}),wp.element.createElement("div",{className:"overlay"},wp.element.createElement("div",{className:"text"},wp.element.createElement("a",{href:l,target:"_blank"}," View "),wp.element.createElement("a",{href:c,target:"_blank"}," Edit "),wp.element.createElement("a",{href:u,target:"_blank"}," Statistics "),wp.element.createElement("input",{type:"button",value:o,className:"components-button is-button is-default is-large left-align",onClick:g})))),wp.element.createElement("div",{className:"components-preview__rightBlockContent"},wp.element.createElement("div",{className:"components-placeholder__label"},"Poll: ",s))),wp.element.createElement("span",null))):""==n||"undefined"===jQuery.type(n)||t.setAttributes({buttonText:"Embed"}),wp.element.createElement("div",{className:t.className},k,wp.element.createElement("span",null))},save:function(t){var e=t.attributes,n=e.embedUrl,r=e.lockEmbed,o=e.buttonText,i=e.insertItemImage,a=e.insertItemOsTitle,s=e.insertItemOsView,l=e.insertItemOsEdit,c=e.insertItemOsStatistics;return wp.element.createElement("div",{class:"os-poll-wrapper","data-type":"poll","data-image-url":i,"data-title-url":a,"data-view-url":s,"data-statistics-url":c,"data-edit-url":l,"data-test-url":n,"data-lock-embed":r,"data-button-text":o},'[os-widget path="',n,'"]',wp.element.createElement("span",null))}})},function(t,e,n){t.exports=n(3)},function(t,e,n){var r=function(){return this}()||Function("return this")(),o=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,i=o&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,t.exports=n(4),o)r.regeneratorRuntime=i;else try{delete r.regeneratorRuntime}catch(t){r.regeneratorRuntime=void 0}},function(t,e){!function(e){"use strict";function n(t,e,n,r){var i=e&&e.prototype instanceof o?e:o,a=Object.create(i.prototype),s=new d(r||[]);return a._invoke=c(t,n,s),a}function r(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function o(){}function i(){}function a(){}function s(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function l(t){function e(n,o,i,a){var s=r(t[n],t,o);if("throw"!==s.type){var l=s.arg,c=l.value;return c&&"object"===typeof c&&b.call(c,"__await")?Promise.resolve(c.__await).then(function(t){e("next",t,i,a)},function(t){e("throw",t,i,a)}):Promise.resolve(c).then(function(t){l.value=t,i(l)},a)}a(s.arg)}function n(t,n){function r(){return new Promise(function(r,o){e(t,n,r,o)})}return o=o?o.then(r,r):r()}var o;this._invoke=n}function c(t,e,n){var o=_;return function(i,a){if(o===L)throw new Error("Generator is already running");if(o===N){if("throw"===i)throw a;return h()}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var l=u(s,n);if(l){if(l===P)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===_)throw o=N,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=L;var c=r(t,e,n);if("normal"===c.type){if(o=n.done?N:I,c.arg===P)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=N,n.method="throw",n.arg=c.arg)}}}function u(t,e){var n=t.iterator[e.method];if(n===g){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=g,u(t,e),"throw"===e.method))return P;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return P}var o=r(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,P;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=g),e.delegate=null,P):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,P)}function p(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function m(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function d(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(p,this),this.reset(!0)}function f(t){if(t){var e=t[y];if(e)return e.call(t);if("function"===typeof t.next)return t;if(!isNaN(t.length)){var n=-1,r=function e(){for(;++n<t.length;)if(b.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=g,e.done=!0,e};return r.next=r}}return{next:h}}function h(){return{value:g,done:!0}}var g,v=Object.prototype,b=v.hasOwnProperty,w="function"===typeof Symbol?Symbol:{},y=w.iterator||"@@iterator",E=w.asyncIterator||"@@asyncIterator",x=w.toStringTag||"@@toStringTag",k="object"===typeof t,O=e.regeneratorRuntime;if(O)return void(k&&(t.exports=O));O=e.regeneratorRuntime=k?t.exports:{},O.wrap=n;var _="suspendedStart",I="suspendedYield",L="executing",N="completed",P={},T={};T[y]=function(){return this};var S=Object.getPrototypeOf,C=S&&S(S(f([])));C&&C!==v&&b.call(C,y)&&(T=C);var j=a.prototype=o.prototype=Object.create(T);i.prototype=j.constructor=a,a.constructor=i,a[x]=i.displayName="GeneratorFunction",O.isGeneratorFunction=function(t){var e="function"===typeof t&&t.constructor;return!!e&&(e===i||"GeneratorFunction"===(e.displayName||e.name))},O.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,a):(t.__proto__=a,x in t||(t[x]="GeneratorFunction")),t.prototype=Object.create(j),t},O.awrap=function(t){return{__await:t}},s(l.prototype),l.prototype[E]=function(){return this},O.AsyncIterator=l,O.async=function(t,e,r,o){var i=new l(n(t,e,r,o));return O.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},s(j),j[x]="Generator",j[y]=function(){return this},j.toString=function(){return"[object Generator]"},O.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},O.values=f,d.prototype={constructor:d,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=g,this.done=!1,this.delegate=null,this.method="next",this.arg=g,this.tryEntries.forEach(m),!t)for(var e in this)"t"===e.charAt(0)&&b.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=g)},stop:function(){this.done=!0;var t=this.tryEntries[0],e=t.completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){function e(e,r){return i.type="throw",i.arg=t,n.next=e,r&&(n.method="next",n.arg=g),!!r}if(this.done)throw t;for(var n=this,r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],i=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=b.call(o,"catchLoc"),s=b.call(o,"finallyLoc");if(a&&s){if(this.prev<o.catchLoc)return e(o.catchLoc,!0);if(this.prev<o.finallyLoc)return e(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return e(o.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return e(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&b.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,P):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),P},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),m(n),P}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;m(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:f(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=g),P}}}(function(){return this}()||Function("return this")())},function(t,e){},function(t,e){}]);
gutenberg/poll/src/.DS_Store CHANGED
Binary file
gutenberg/poll/src/block/block.js CHANGED
@@ -6,13 +6,12 @@ const { registerBlockType } = wp.blocks;
6
  const { SelectControl, TextControl } = wp.components;
7
  const { RichText } = wp.editor ;
8
 
9
- var dropdownOptions = false;
10
- var previewBlockOsTitle;
11
- var previewBlockOsImageUrl;
12
- var previewBlockOsView;
13
- var previewBlockOsEdit;
14
- var previewBlockOsStatistics;
15
- var options;
16
 
17
  registerBlockType( 'opinion-stage/block-os-poll', {
18
  title: __( 'Poll' ),
@@ -27,12 +26,7 @@ var options;
27
  source: 'attribute',
28
  attribute: 'data-test-url',
29
  selector: 'div[data-test-url]'
30
- },
31
- oswpUrlShortcode: {
32
- source: 'attribute',
33
- attribute: 'data-test-url',
34
- selector: 'div[data-test-url]'
35
- },
36
  lockEmbed: {
37
  source: 'attribute',
38
  attribute: 'data-lock-embed',
@@ -42,173 +36,132 @@ var options;
42
  source: 'attribute',
43
  attribute: 'data-button-text',
44
  selector: 'div[data-button-text]'
45
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  },
47
  edit: function( props ) {
48
- let {attributes: {embedUrl, oswpUrlShortcode, lockEmbed, buttonText}, setAttributes} = props;
49
- const onDropdownChange = val => {
50
- if(val == ''){
51
- props.setAttributes({ embedUrl: '' });
52
- }else if(val != ''){
53
- props.setAttributes({ embedUrl: val });
54
- for (var i = 0; i < dropdownOptions.length; i++) {
55
- var getLandingPageUrlOs = function(href) {
56
- var locationUrlOS = document.createElement("a");
57
- locationUrlOS.href = href;
58
- return locationUrlOS;
59
- };
60
- var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
61
- var matchValue = locationUrlOS.pathname;
62
- if(val == matchValue){
63
- previewBlockOsTitle = dropdownOptions[i].attributes['title'];
64
- previewBlockOsImageUrl = dropdownOptions[i].attributes['image-url'];
65
- previewBlockOsView = dropdownOptions[i].attributes['landing-page-url'];
66
- previewBlockOsEdit = dropdownOptions[i].attributes['edit-url'];
67
- previewBlockOsStatistics = dropdownOptions[i].attributes['stats-url'];
68
- break;
69
- }
70
- }
71
- }else{
72
- }
73
- };
74
- const onEmbedButtonClick = event => {
75
- if( event.target.value == "Embed" ){
76
- if(embedUrl == '' || embedUrl == 'Select' || embedUrl == 'createNew' || embedUrl == 'refresh'){
77
- props.setAttributes({ lockEmbed: false, buttonText: "Embed" });
78
- }else{
79
- props.setAttributes({ lockEmbed: true, buttonText: "Change" });
80
- contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} onChange={onDropdownChange} className="components-select-control__input" />);
81
- }
82
- }else{
83
- props.setAttributes({ lockEmbed: false, buttonText: "Embed" });
84
- }
85
- };
86
-
87
- window.verifyOSInsert = function(widget){
88
- props.setAttributes({ oswpUrlShortcode: widget });
89
- var myOpts = document.getElementById('selectID').options;
90
- for(var i = 0; i < myOpts.length; i++){
91
- if(myOpts[i].value == widget){
92
- myOpts[i].defaultSelected = true;
93
- props.setAttributes({ lockEmbed: true, buttonText: "Change", embedUrl: widget });
94
- break;
95
- }
96
- }
97
- }
98
-
99
- var getOsCreateButtonClickUrl = osGutenData.onCreateButtonClickOs+'?w_type=poll&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8';
100
- const onCreateButtonClick = value => {
101
- // Open Create new poll link in new page
102
- window.open(getOsCreateButtonClickUrl, '_blank').focus();
103
- };
104
-
105
- if(!buttonText){
106
- props.setAttributes({ buttonText: 'Embed' });
107
- }
108
 
 
109
  var getCallBackUrlOs = osGutenData.callbackUrlOs;
110
  var callback_url = getCallBackUrlOs;
111
  var formActionUrlOS = osGutenData.getActionUrlOS;
112
  var getlogoImageLinkOs = osGutenData.getLogoImageLink;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  const onConnectOSWPButtonClick = value => {
114
- // Open Connect to opinionstage
115
  window.location.replace(callback_url);
116
  };
117
- // Populate list ajax function
118
- function OsPolulateList() {
119
- var opinionStageWidgetVersion = osGutenData.OswpPluginVersion;
120
- var opinionStageClientToken = osGutenData.OswpClientToken;
121
- var opinionstageFetchDataUrl = osGutenData.OswpFetchDataUrl+'?type=poll&page=1&per_page=99';
122
- fetch(opinionstageFetchDataUrl, {
123
- method: "GET",
124
- headers: {
125
- 'Accept':'application/vnd.api+json',
126
- 'Content-Type':'application/vnd.api+json',
127
- 'OSWP-Plugin-Version':opinionStageWidgetVersion,
128
- 'OSWP-Client-Token': opinionStageClientToken
129
- },
130
- })
131
- .then(async res => {
132
- var data = await res.json();
133
- data = data.data;
134
- dropdownOptions = data;
135
- // force reprinting instead!!
136
- props.setAttributes({ buttonText: 'Embed'});
137
- props.setAttributes({ buttonText: buttonText});
138
- if(buttonText == 'Change' && embedUrl !='Select'){
139
- props.setAttributes({ embedUrl: embedUrl });
140
- }else{
141
- props.setAttributes({ embedUrl: 'Select' });
142
- }
143
- })
144
- .catch(function(err) {
145
- console.log('ERROR: ' + err.message);
146
- });
147
- }
148
  // Checking for Opinion Stage connection
149
  if(osGutenData.isOsConnected == ''){
150
- $(document).ready(function () {
151
- $('span#oswpLauncherContentPopuppoll , #owspLaunchInputCreate').live('click', function(e) {
152
- e.preventDefault();
153
- setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
154
- });
155
- });
156
  return (
157
  <div className={ props.className }>
158
  <div className="os-poll-wrapper components-placeholder">
159
  <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
160
  <p className="components-heading">Please connect WordPress to Opinion Stage to start adding polls</p>
161
  <button className="components-button is-button is-default is-block is-primary" onClick={onConnectOSWPButtonClick}>Connect</button>
162
- </div>
 
163
  </div>
164
  );
165
- }else{
166
- if(dropdownOptions == false){
167
- options = [{value:'Select',label:'Select a poll'},{value:'refresh',label:'Refresh'}];
168
- OsPolulateList();
169
- }else{
170
- options = [{value:'Select',label:'Select a poll'},{value:'refresh',label:'Refresh'},{value:'',label:'-----------------'}];
171
- for (var i = 0; i < dropdownOptions.length; i++) {
172
- options[options.length] = {
173
- value: dropdownOptions[i].attributes['landing-page-url'].replace('https://www.opinionstage.com',''),
174
- label: dropdownOptions[i].attributes['title'],
175
- };
176
- var getLandingPageUrlOs = function(href) {
177
- var locationUrlOS = document.createElement("a");
178
- locationUrlOS.href = href;
179
- return locationUrlOS;
180
- };
181
- var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
182
- var matchValue = locationUrlOS.pathname;
183
- if(embedUrl == matchValue){
184
- previewBlockOsTitle = dropdownOptions[i].attributes['title'];
185
- previewBlockOsImageUrl = dropdownOptions[i].attributes['image-url'];
186
- previewBlockOsView = dropdownOptions[i].attributes['landing-page-url'];
187
- previewBlockOsEdit = dropdownOptions[i].attributes['edit-url'];
188
- previewBlockOsStatistics = dropdownOptions[i].attributes['stats-url'];
189
- var previewBlockOsWidgetID = dropdownOptions[i].id;
190
-
191
- }
192
- }
193
- }
194
- if(embedUrl == 'refresh'){
195
- OsPolulateList();
196
- }
197
- var contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} onChange={onDropdownChange} className="components-select-control__input" />);
198
  $(document).ready(function () {
 
199
  $('span#oswpLauncherContentPopuppoll').live('click', function(e) {
200
  e.preventDefault();
201
  setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
202
  var text = $(this).attr('data-os-block');
203
  $("button#dropbtn span").text(text);
204
- var inputs = $(".filter__itm");
205
  for(var i = 0; i < inputs.length; i++){
206
- if($(inputs[i]).text() == text){
207
- setTimeout(function(){$(inputs[i]).trigger('click');},1000);
208
  setTimeout(function(){
209
- $('.progress_message').css('display', 'none');
210
- $('.content__list').css('display', 'block');
211
- },2500);
 
 
 
212
  $('button.content__links-itm').live('click', function(e) {
213
  $('.tingle-modal.opinionstage-content-popup').hide();
214
  $('.tingle-modal.opinionstage-content-popup.tingle-modal--visible').hide();
@@ -218,83 +171,89 @@ var options;
218
  else {
219
  $('.progress_message').css('display', 'block');
220
  $('.content__list').css('display', 'none');
221
- console.log('test');
222
  }
223
  }
224
  });
225
  });
226
 
227
- var contentViewEditStatOs = (
228
- <div className="os-poll-wrapper components-placeholder">
229
- <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
230
- <span id="oswpLauncherContentPopuppoll" className="components-button is-button is-default is-block is-primary" data-opinionstage-content-launch data-os-block="poll">Select a Poll</span>
231
- <input type="button" value="Create a New Poll" className="components-button is-button is-default is-block is-primary" onClick={onCreateButtonClick} />
232
- <div className="components-placeholder__fieldset">
233
- {contentDropdown}
234
- <input type="button" value={buttonText} className="components-button is-button is-default is-large" id="clickMe" onClick={onEmbedButtonClick} />
235
- </div>
236
- </div>
237
- );
238
-
239
- var dataOpinionStageEmbedUrl = 'https://www.opinionstage.com/api/v1/widgets/'+embedUrl+'/code.json?comments=true&amp;sharing=true&amp;recommendations=false&amp;width=';
240
- var OpinionStageDataIframe = 'https://www.opinionstage.com/'+embedUrl+'?wid=0&amp;em=1&amp;comments=null&amp;referring_widget='+embedUrl+'&amp;autoswitch=1&amp;of=&amp;os_utm_source=null';
241
- (function(d, s, id){
242
- var js,
243
- fjs = d.getElementsByTagName(s)[0],
244
- r = Math.floor(new Date().getTime() / 1000000);
245
- if (d.getElementById(id)) {return;}
246
- js = d.createElement(s); js.id = id; js.async=1;
247
- js.src = "https://www.opinionstage.com/assets/loader.js?" + r;
248
- fjs.parentNode.insertBefore(js, fjs);
249
- }(document, 'script', 'os-widget-jssdk'));
250
- previewBlockOsWidgetID = 'os-widget-'+previewBlockOsWidgetID;
251
-
252
- if(embedUrl != '' && embedUrl != 'Select' && embedUrl){
 
 
 
 
 
 
 
253
  if(buttonText == 'Embed'){
254
  contentViewEditStatOs
255
- }else if(buttonText == 'Change'){
256
  contentViewEditStatOs = (
257
- <div className="os-poll-wrapper components-placeholder">
258
- <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
259
- <div className="components-preview__block" >
260
- <div className="components-preview__leftBlockImage">
261
- <img src={previewBlockOsImageUrl} alt={previewBlockOsTitle} className="image" />
262
- <div className="overlay">
263
- <div className="text">
264
- <a href={previewBlockOsView} target="_blank"> View </a>
265
- <a href={previewBlockOsEdit} target="_blank"> Edit </a>
266
- <a href={previewBlockOsStatistics} target="_blank"> Statistics </a>
267
- <input type="button" value={buttonText} className="components-button is-button is-default is-large left-align" onClick={onEmbedButtonClick} />
268
- </div>
 
 
 
 
269
  </div>
270
- </div>
271
- <div className="components-preview__rightBlockContent">
272
- <div className="components-placeholder__label">Poll: {previewBlockOsTitle}</div>
273
- </div>
274
- </div>
275
- </div>
276
- );
277
- contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} disabled onChange={onDropdownChange} className="components-select-control__input" />);
278
  }
279
- }else if(embedUrl == 'Select' || embedUrl == '' || embedUrl == 'refresh'){
280
  contentViewEditStatOs
281
  }else{
282
  props.setAttributes({ buttonText: 'Embed'});
283
  contentViewEditStatOs
284
  }
285
-
286
-
287
- return (
288
  <div className={ props.className }>
289
- {contentViewEditStatOs}
 
290
  </div>
291
  );
292
  }
293
  },
294
- save: function( {attributes: {embedUrl, oswpUrlShortcode, lockEmbed, buttonText}} ) {
295
  return (
296
- <div class="os-poll-wrapper" data-type="poll" data-test-url={oswpUrlShortcode} data-lock-embed={lockEmbed} data-button-text={buttonText}>
297
- [os-widget path="{oswpUrlShortcode}"]
 
298
  </div>
299
  );
300
  },
6
  const { SelectControl, TextControl } = wp.components;
7
  const { RichText } = wp.editor ;
8
 
9
+ var dropdownOptions = false;
10
+ var insertItemImage = false;
11
+ var insertItemOsTitle = false;
12
+ var insertItemOsView = false;
13
+ var insertItemOsEdit = false;
14
+ var insertItemOsStatistics = false;
 
15
 
16
  registerBlockType( 'opinion-stage/block-os-poll', {
17
  title: __( 'Poll' ),
26
  source: 'attribute',
27
  attribute: 'data-test-url',
28
  selector: 'div[data-test-url]'
29
+ },
 
 
 
 
 
30
  lockEmbed: {
31
  source: 'attribute',
32
  attribute: 'data-lock-embed',
36
  source: 'attribute',
37
  attribute: 'data-button-text',
38
  selector: 'div[data-button-text]'
39
+ },
40
+ insertItemImage: {
41
+ source: 'attribute',
42
+ attribute: 'data-image-url',
43
+ selector: 'div[data-image-url]'
44
+ },
45
+ insertItemOsTitle: {
46
+ source: 'attribute',
47
+ attribute: 'data-title-url',
48
+ selector: 'div[data-title-url]'
49
+ },
50
+ insertItemOsView: {
51
+ source: 'attribute',
52
+ attribute: 'data-view-url',
53
+ selector: 'div[data-view-url]'
54
+ },
55
+ insertItemOsEdit: {
56
+ source: 'attribute',
57
+ attribute: 'data-edit-url',
58
+ selector: 'div[data-edit-url]'
59
+ },
60
+ insertItemOsStatistics: {
61
+ source: 'attribute',
62
+ attribute: 'data-statistics-url',
63
+ selector: 'div[data-statistics-url]'
64
+ }
65
  },
66
  edit: function( props ) {
67
+ // Setting Attributes
68
+ let {attributes: {embedUrl, lockEmbed, buttonText, insertItemImage,insertItemOsTitle,insertItemOsView,insertItemOsEdit,insertItemOsStatistics}, setAttributes} = props;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ // Fetching Localized variables
71
  var getCallBackUrlOs = osGutenData.callbackUrlOs;
72
  var callback_url = getCallBackUrlOs;
73
  var formActionUrlOS = osGutenData.getActionUrlOS;
74
  var getlogoImageLinkOs = osGutenData.getLogoImageLink;
75
+
76
+ // Select Button Click functionality
77
+ const onSelectButtonClick = value => {
78
+ window.verifyOSInsert = function(widget){
79
+ props.setAttributes({ embedUrl: widget, buttonText:'Change' });
80
+
81
+ var opinionStageWidgetVersion = osGutenData.OswpPluginVersion;
82
+ var opinionStageClientToken = osGutenData.OswpClientToken;
83
+ var opinionstageFetchDataUrl = osGutenData.OswpFetchDataUrl+'?type=poll&page=1&per_page=99';
84
+ fetch(opinionstageFetchDataUrl, {
85
+ method: "GET",
86
+ headers: {
87
+ 'Accept':'application/vnd.api+json',
88
+ 'Content-Type':'application/vnd.api+json',
89
+ 'OSWP-Plugin-Version':opinionStageWidgetVersion,
90
+ 'OSWP-Client-Token': opinionStageClientToken
91
+ },
92
+ })
93
+ .then(async res => {
94
+ var data = await res.json();
95
+ data = data.data;
96
+ dropdownOptions = data;
97
+ // force reprinting instead!!
98
+ props.setAttributes({ buttonText: buttonText});
99
+
100
+ })
101
+ .catch(function(err) {
102
+ console.log('ERROR: ' + err.message);
103
+ });
104
+ }
105
+ }
106
+
107
+ // Change Button Click functionality
108
+ const onChangeButtonClick = value => {
109
+ props.setAttributes({
110
+ embedUrl: '',
111
+ buttonText:'Embed',
112
+ lockEmbed: false,
113
+ insertItemImage: false,
114
+ insertItemOsTitle: false,
115
+ insertItemOsView: false,
116
+ insertItemOsEdit: false,
117
+ insertItemOsStatistics: false
118
+ });
119
+ }
120
+
121
+ // Connect to Opinionstage Callback Url
122
  const onConnectOSWPButtonClick = value => {
 
123
  window.location.replace(callback_url);
124
  };
125
+
126
+ // Create New Item Url (Poll)
127
+ var getOsCreateButtonClickUrl = osGutenData.onCreateButtonClickOs+'?w_type=poll&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8';
128
+ const onCreateButtonClick = value => {
129
+ // Open Create new poll link in new page
130
+ window.open(getOsCreateButtonClickUrl, '_blank').focus();
131
+ };
132
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  // Checking for Opinion Stage connection
134
  if(osGutenData.isOsConnected == ''){
135
+ // Not Connected to opinionstage
 
 
 
 
 
136
  return (
137
  <div className={ props.className }>
138
  <div className="os-poll-wrapper components-placeholder">
139
  <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
140
  <p className="components-heading">Please connect WordPress to Opinion Stage to start adding polls</p>
141
  <button className="components-button is-button is-default is-block is-primary" onClick={onConnectOSWPButtonClick}>Connect</button>
142
+ </div>
143
+ <div></div>
144
  </div>
145
  );
146
+ }else{
147
+ // Connected to opinionstage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  $(document).ready(function () {
149
+ // Content Popup Launch Working
150
  $('span#oswpLauncherContentPopuppoll').live('click', function(e) {
151
  e.preventDefault();
152
  setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
153
  var text = $(this).attr('data-os-block');
154
  $("button#dropbtn span").text(text);
155
+ var inputs = $(".filter__itm");
156
  for(var i = 0; i < inputs.length; i++){
157
+ if($(inputs[i]).text() == text){
 
158
  setTimeout(function(){
159
+ $(inputs[i]).trigger('click');
160
+ },1000);
161
+ setTimeout(function(){
162
+ $('.progress_message').css('display', 'none');
163
+ $('.content__list').css('display', 'block');
164
+ },2500);
165
  $('button.content__links-itm').live('click', function(e) {
166
  $('.tingle-modal.opinionstage-content-popup').hide();
167
  $('.tingle-modal.opinionstage-content-popup.tingle-modal--visible').hide();
171
  else {
172
  $('.progress_message').css('display', 'block');
173
  $('.content__list').css('display', 'none');
 
174
  }
175
  }
176
  });
177
  });
178
 
179
+ // Fetching Ajax Call Result
180
+ if(dropdownOptions != false){
181
+ for (var i = 0; i < dropdownOptions.length; i++) {
182
+ var getLandingPageUrlOs = function(href) {
183
+ var locationUrlOS = document.createElement("a");
184
+ locationUrlOS.href = href;
185
+ return locationUrlOS;
186
+ };
187
+ var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
188
+ var matchValue = locationUrlOS.pathname;
189
+ if(embedUrl == matchValue){
190
+ props.setAttributes({lockEmbed: true, buttonText: "Change" });
191
+ props.setAttributes({ insertItemImage : dropdownOptions[i].attributes['image-url'] });
192
+ props.setAttributes({ insertItemOsTitle : dropdownOptions[i].attributes['title'] });
193
+ props.setAttributes({ insertItemOsView : dropdownOptions[i].attributes['landing-page-url'] });
194
+ props.setAttributes({ insertItemOsEdit : dropdownOptions[i].attributes['edit-url'] });
195
+ props.setAttributes({ insertItemOsStatistics : dropdownOptions[i].attributes['stats-url'] });
196
+ break;
197
+ }
198
+ }
199
+ }
200
+
201
+ // Content On Editor
202
+ var contentViewEditStatOs = (
203
+ <div className="os-poll-wrapper components-placeholder">
204
+ <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
205
+ <span id="oswpLauncherContentPopuppoll" className="components-button is-button is-default is-block is-primary" data-opinionstage-content-launch data-os-block="poll" onClick={onSelectButtonClick} >Select a Poll</span>
206
+ <input type="button" value="Create a New Poll" className="components-button is-button is-default is-block is-primary" onClick={onCreateButtonClick} />
207
+ <span></span>
208
+ </div>
209
+ );
210
+
211
+ if(embedUrl != '' && embedUrl){
212
  if(buttonText == 'Embed'){
213
  contentViewEditStatOs
214
+ }else if(buttonText == 'Change'){
215
  contentViewEditStatOs = (
216
+ <div className="os-poll-wrapper components-placeholder">
217
+ <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
218
+ <div className="components-preview__block" >
219
+ <div className="components-preview__leftBlockImage">
220
+ <img src={insertItemImage} alt={insertItemOsTitle} className="image" />
221
+ <div className="overlay">
222
+ <div className="text">
223
+ <a href={insertItemOsView} target="_blank"> View </a>
224
+ <a href={insertItemOsEdit} target="_blank"> Edit </a>
225
+ <a href={insertItemOsStatistics} target="_blank"> Statistics </a>
226
+ <input type="button" value={buttonText} className="components-button is-button is-default is-large left-align" onClick={onChangeButtonClick}/>
227
+ </div>
228
+ </div>
229
+ </div>
230
+ <div className="components-preview__rightBlockContent">
231
+ <div className="components-placeholder__label">Poll: {insertItemOsTitle}</div>
232
  </div>
233
+ </div>
234
+ <span></span>
235
+ </div>
236
+ );
 
 
 
 
237
  }
238
+ }else if(embedUrl == '' || jQuery.type(embedUrl) === "undefined"){
239
  contentViewEditStatOs
240
  }else{
241
  props.setAttributes({ buttonText: 'Embed'});
242
  contentViewEditStatOs
243
  }
244
+ return (
 
 
245
  <div className={ props.className }>
246
+ {contentViewEditStatOs}
247
+ <span></span>
248
  </div>
249
  );
250
  }
251
  },
252
+ save: function( {attributes: {embedUrl, lockEmbed, buttonText, insertItemImage, insertItemOsTitle, insertItemOsView, insertItemOsEdit, insertItemOsStatistics }} ) {
253
  return (
254
+ <div class="os-poll-wrapper" data-type="poll" data-image-url={insertItemImage} data-title-url={insertItemOsTitle} data-view-url={insertItemOsView} data-statistics-url={insertItemOsStatistics} data-edit-url={insertItemOsEdit} data-test-url={embedUrl} data-lock-embed={lockEmbed} data-button-text={buttonText}>
255
+ [os-widget path="{embedUrl}"]
256
+ <span></span>
257
  </div>
258
  );
259
  },
gutenberg/slideshow/dist/blocks.build.js CHANGED
@@ -1 +1 @@
1
- !function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});n(1)},function(e,t,n){"use strict";function r(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){function r(o,a){try{var i=t[o](a),s=i.value}catch(e){return void n(e)}if(!i.done)return Promise.resolve(s).then(function(e){r("next",e)},function(e){r("throw",e)});e(s)}return r("next")})}}var o,a,i,s,l,c,u=n(2),p=n.n(u),m=n(5),d=(n.n(m),n(6)),h=(n.n(d),wp.i18n.__),f=wp.blocks.registerBlockType,g=wp.components,v=g.SelectControl,b=(g.TextControl,wp.editor.RichText,!1);f("opinion-stage/block-os-slideshow",{title:h("Slideshow"),icon:"playlist-video",category:"opinion-stage",keywords:[h("Opinion Stage Slideshow"),h("Opinion Stage Slideshow")],attributes:{embedUrl:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},oswpUrlShortcode:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},lockEmbed:{source:"attribute",attribute:"data-lock-embed",selector:"div[data-lock-embed]"},buttonText:{source:"attribute",attribute:"data-button-text",selector:"div[data-button-text]"}},edit:function(e){function t(){var t=this,n=osGutenData.OswpPluginVersion,o=osGutenData.OswpClientToken,a=osGutenData.OswpFetchDataUrl+"?type=slideshow&page=1&per_page=99";fetch(a,{method:"GET",headers:{Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json","OSWP-Plugin-Version":n,"OSWP-Client-Token":o}}).then(function(){var n=r(p.a.mark(function n(r){var o;return p.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.json();case 2:o=t.sent,o=o.data,b=o,e.setAttributes({buttonText:"Embed"}),e.setAttributes({buttonText:m}),"Change"==m&&"Select"!=u?e.setAttributes({embedUrl:u}):e.setAttributes({embedUrl:"Select"});case 8:case"end":return t.stop()}},n,t)}));return function(e){return n.apply(this,arguments)}}()).catch(function(e){console.log("ERROR: "+e.message)})}var n=e.attributes,u=n.embedUrl,m=(n.oswpUrlShortcode,n.lockEmbed,n.buttonText),d=(e.setAttributes,function(t){if(""==t)e.setAttributes({embedUrl:""});else if(""!=t){e.setAttributes({embedUrl:t});for(var n=0;n<b.length;n++){var r=function(e){var t=document.createElement("a");return t.href=e,t}(b[n].attributes["landing-page-url"]),c=r.pathname;if(t==c){o=b[n].attributes.title,a=b[n].attributes["image-url"],i=b[n].attributes["landing-page-url"],s=b[n].attributes["edit-url"],l=b[n].attributes["stats-url"];break}}}}),h=function(t){"Embed"==t.target.value?""==u||"Select"==u||"createNew"==u||"refresh"==u?e.setAttributes({lockEmbed:!1,buttonText:"Embed"}):(e.setAttributes({lockEmbed:!0,buttonText:"Change"}),L=wp.element.createElement(v,{id:"selectID",options:c,value:u,onChange:d,className:"components-select-control__input"})):e.setAttributes({lockEmbed:!1,buttonText:"Embed"})};window.verifyOSInsert=function(t){e.setAttributes({oswpUrlShortcode:t});for(var n=document.getElementById("selectID").options,r=0;r<n.length;r++)if(n[r].value==t){n[r].defaultSelected=!0,e.setAttributes({lockEmbed:!0,buttonText:"Change",embedUrl:t});break}};var f=osGutenData.onCreateButtonClickOs+"?w_type=slideshow&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8",g=function(e){window.open(f,"_blank").focus()};m||e.setAttributes({buttonText:"Embed"});var w=osGutenData.callbackUrlOs,y=w,E=(osGutenData.getActionUrlOS,osGutenData.getLogoImageLink);console.log(y);var k=function(e){window.location.replace(y)};if(""==osGutenData.isOsConnected)return $(document).ready(function(){$("span#oswpLauncherContentPopupslideshow , #owspLaunchInputCreate").live("click",function(e){e.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500)})}),wp.element.createElement("div",{className:e.className},wp.element.createElement("div",{className:"os-slideshow-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:E,alt:""})),wp.element.createElement("p",{className:"components-heading"},"Please connect WordPress to Opinion Stage to start adding slideshows"),wp.element.createElement("button",{className:"components-button is-button is-default is-block is-primary",onClick:k},"Connect")));if(0==b)c=[{value:"Select",label:"Select a slideshow"},{value:"refresh",label:"Refresh"}],t();else{c=[{value:"Select",label:"Select a slideshow"},{value:"refresh",label:"Refresh"},{value:"",label:"-----------------"}];for(var x=0;x<b.length;x++){c[c.length]={value:b[x].attributes["landing-page-url"].replace("https://www.opinionstage.com",""),label:b[x].attributes.title};var _=function(e){var t=document.createElement("a");return t.href=e,t}(b[x].attributes["landing-page-url"]),N=_.pathname;if(u==N){o=b[x].attributes.title,a=b[x].attributes["image-url"],i=b[x].attributes["landing-page-url"],s=b[x].attributes["edit-url"],l=b[x].attributes["stats-url"];var S=b[x].id}}}"refresh"==u&&t();var L=wp.element.createElement(v,{id:"selectID",options:c,value:u,onChange:d,className:"components-select-control__input"});$(document).ready(function(){$("span#oswpLauncherContentPopupslideshow").live("click",function(e){e.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500);var t=$(this).attr("data-os-block");$("button#dropbtn span").text(t);for(var n=$(".filter__itm"),r=0;r<n.length;r++){if($(n[r]).text()==t){setTimeout(function(){$(n[r]).trigger("click")},1e3),setTimeout(function(){$(".progress_message").css("display","none"),$(".content__list").css("display","block")},2500),$("button.content__links-itm").live("click",function(e){$(".tingle-modal.opinionstage-content-popup").hide(),$(".tingle-modal.opinionstage-content-popup.tingle-modal--visible").hide()});break}$(".progress_message").css("display","block"),$(".content__list").css("display","none"),console.log("test")}})});var O=wp.element.createElement("div",{className:"os-slideshow-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:E,alt:""})),wp.element.createElement("span",{id:"oswpLauncherContentPopupslideshow",className:"components-button is-button is-default is-block is-primary","data-opinionstage-content-launch":!0,"data-os-block":"slideshow"},"Select a Slideshow"),wp.element.createElement("input",{type:"button",value:"Create a New Slideshow",className:"components-button is-button is-default is-block is-primary",onClick:g}),wp.element.createElement("div",{className:"components-placeholder__fieldset"},L,wp.element.createElement("input",{type:"button",value:m,className:"components-button is-button is-default is-large",id:"clickMe",onClick:h})));return function(e,t,n){var r,o=e.getElementsByTagName(t)[0],a=Math.floor((new Date).getTime()/1e6);e.getElementById(n)||(r=e.createElement(t),r.id=n,r.async=1,r.src="https://www.opinionstage.com/assets/loader.js?"+a,o.parentNode.insertBefore(r,o))}(document,"script","os-widget-jssdk"),S="os-widget-"+S,""!=u&&"Select"!=u&&u?"Embed"==m||"Change"==m&&(O=wp.element.createElement("div",{className:"os-slideshow-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:E,alt:""})),wp.element.createElement("div",{className:"components-preview__block"},wp.element.createElement("div",{className:"components-preview__leftBlockImage"},wp.element.createElement("img",{src:a,alt:o,className:"image"}),wp.element.createElement("div",{className:"overlay"},wp.element.createElement("div",{className:"text"},wp.element.createElement("a",{href:i,target:"_blank"}," View "),wp.element.createElement("a",{href:s,target:"_blank"}," Edit "),wp.element.createElement("a",{href:l,target:"_blank"}," Statistics "),wp.element.createElement("input",{type:"button",value:m,className:"components-button is-button is-default is-large left-align",onClick:h})))),wp.element.createElement("div",{className:"components-preview__rightBlockContent"},wp.element.createElement("div",{className:"components-placeholder__label"},"Slideshow: ",o)))),L=wp.element.createElement(v,{id:"selectID",options:c,value:u,disabled:!0,onChange:d,className:"components-select-control__input"})):"Select"==u||""==u||"refresh"==u||e.setAttributes({buttonText:"Embed"}),wp.element.createElement("div",{className:e.className},O)},save:function(e){var t=e.attributes,n=(t.embedUrl,t.oswpUrlShortcode),r=t.lockEmbed,o=t.buttonText;return wp.element.createElement("div",{class:"os-slideshow-wrapper","data-type":"slideshow","data-test-url":n,"data-lock-embed":r,"data-button-text":o},'[os-widget path="',n,'"]')}})},function(e,t,n){e.exports=n(3)},function(e,t,n){var r=function(){return this}()||Function("return this")(),o=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,a=o&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,e.exports=n(4),o)r.regeneratorRuntime=a;else try{delete r.regeneratorRuntime}catch(e){r.regeneratorRuntime=void 0}},function(e,t){!function(t){"use strict";function n(e,t,n,r){var a=t&&t.prototype instanceof o?t:o,i=Object.create(a.prototype),s=new d(r||[]);return i._invoke=c(e,n,s),i}function r(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}function o(){}function a(){}function i(){}function s(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function l(e){function t(n,o,a,i){var s=r(e[n],e,o);if("throw"!==s.type){var l=s.arg,c=l.value;return c&&"object"===typeof c&&b.call(c,"__await")?Promise.resolve(c.__await).then(function(e){t("next",e,a,i)},function(e){t("throw",e,a,i)}):Promise.resolve(c).then(function(e){l.value=e,a(l)},i)}i(s.arg)}function n(e,n){function r(){return new Promise(function(r,o){t(e,n,r,o)})}return o=o?o.then(r,r):r()}var o;this._invoke=n}function c(e,t,n){var o=N;return function(a,i){if(o===L)throw new Error("Generator is already running");if(o===O){if("throw"===a)throw i;return f()}for(n.method=a,n.arg=i;;){var s=n.delegate;if(s){var l=u(s,n);if(l){if(l===T)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===N)throw o=O,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=L;var c=r(e,t,n);if("normal"===c.type){if(o=n.done?O:S,c.arg===T)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=O,n.method="throw",n.arg=c.arg)}}}function u(e,t){var n=e.iterator[t.method];if(n===g){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=g,u(e,t),"throw"===t.method))return T;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return T}var o=r(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,T;var a=o.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=g),t.delegate=null,T):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,T)}function p(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function m(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function d(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(p,this),this.reset(!0)}function h(e){if(e){var t=e[y];if(t)return t.call(e);if("function"===typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(b.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=g,t.done=!0,t};return r.next=r}}return{next:f}}function f(){return{value:g,done:!0}}var g,v=Object.prototype,b=v.hasOwnProperty,w="function"===typeof Symbol?Symbol:{},y=w.iterator||"@@iterator",E=w.asyncIterator||"@@asyncIterator",k=w.toStringTag||"@@toStringTag",x="object"===typeof e,_=t.regeneratorRuntime;if(_)return void(x&&(e.exports=_));_=t.regeneratorRuntime=x?e.exports:{},_.wrap=n;var N="suspendedStart",S="suspendedYield",L="executing",O="completed",T={},C={};C[y]=function(){return this};var P=Object.getPrototypeOf,j=P&&P(P(h([])));j&&j!==v&&b.call(j,y)&&(C=j);var A=i.prototype=o.prototype=Object.create(C);a.prototype=A.constructor=i,i.constructor=a,i[k]=a.displayName="GeneratorFunction",_.isGeneratorFunction=function(e){var t="function"===typeof e&&e.constructor;return!!t&&(t===a||"GeneratorFunction"===(t.displayName||t.name))},_.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,i):(e.__proto__=i,k in e||(e[k]="GeneratorFunction")),e.prototype=Object.create(A),e},_.awrap=function(e){return{__await:e}},s(l.prototype),l.prototype[E]=function(){return this},_.AsyncIterator=l,_.async=function(e,t,r,o){var a=new l(n(e,t,r,o));return _.isGeneratorFunction(t)?a:a.next().then(function(e){return e.done?e.value:a.next()})},s(A),A[k]="Generator",A[y]=function(){return this},A.toString=function(){return"[object Generator]"},_.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},_.values=h,d.prototype={constructor:d,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=g,this.done=!1,this.delegate=null,this.method="next",this.arg=g,this.tryEntries.forEach(m),!e)for(var t in this)"t"===t.charAt(0)&&b.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=g)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){function t(t,r){return a.type="throw",a.arg=e,n.next=t,r&&(n.method="next",n.arg=g),!!r}if(this.done)throw e;for(var n=this,r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var i=b.call(o,"catchLoc"),s=b.call(o,"finallyLoc");if(i&&s){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(i){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&b.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,T):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),T},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),m(n),T}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;m(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:h(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=g),T}}}(function(){return this}()||Function("return this")())},function(e,t){},function(e,t){}]);
1
+ !function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});n(1)},function(t,e,n){"use strict";function r(t){return function(){var e=t.apply(this,arguments);return new Promise(function(t,n){function r(i,o){try{var a=e[i](o),s=a.value}catch(t){return void n(t)}if(!a.done)return Promise.resolve(s).then(function(t){r("next",t)},function(t){r("throw",t)});t(s)}return r("next")})}}var i=n(2),o=n.n(i),a=n(5),s=(n.n(a),n(6)),c=(n.n(s),wp.i18n.__),l=wp.blocks.registerBlockType,u=wp.components,p=(u.SelectControl,u.TextControl,wp.editor.RichText,!1);l("opinion-stage/block-os-slideshow",{title:c("Slideshow"),icon:"playlist-video",category:"opinion-stage",keywords:[c("Opinion Stage Slideshow"),c("Opinion Stage Slideshow")],attributes:{embedUrl:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},lockEmbed:{source:"attribute",attribute:"data-lock-embed",selector:"div[data-lock-embed]"},buttonText:{source:"attribute",attribute:"data-button-text",selector:"div[data-button-text]"},insertItemImage:{source:"attribute",attribute:"data-image-url",selector:"div[data-image-url]"},insertItemOsTitle:{source:"attribute",attribute:"data-title-url",selector:"div[data-title-url]"},insertItemOsView:{source:"attribute",attribute:"data-view-url",selector:"div[data-view-url]"},insertItemOsEdit:{source:"attribute",attribute:"data-edit-url",selector:"div[data-edit-url]"},insertItemOsStatistics:{source:"attribute",attribute:"data-statistics-url",selector:"div[data-statistics-url]"}},edit:function(t){var e=t.attributes,n=e.embedUrl,i=(e.lockEmbed,e.buttonText),a=e.insertItemImage,s=e.insertItemOsTitle,c=e.insertItemOsView,l=e.insertItemOsEdit,u=e.insertItemOsStatistics,m=(t.setAttributes,osGutenData.callbackUrlOs),d=m,f=(osGutenData.getActionUrlOS,osGutenData.getLogoImageLink),h=function(e){window.verifyOSInsert=function(e){var n=this;t.setAttributes({embedUrl:e,buttonText:"Change"});var a=osGutenData.OswpPluginVersion,s=osGutenData.OswpClientToken,c=osGutenData.OswpFetchDataUrl+"?type=slideshow&page=1&per_page=99";fetch(c,{method:"GET",headers:{Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json","OSWP-Plugin-Version":a,"OSWP-Client-Token":s}}).then(function(){var e=r(o.a.mark(function e(r){var a;return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.json();case 2:a=e.sent,a=a.data,p=a,t.setAttributes({buttonText:i});case 6:case"end":return e.stop()}},e,n)}));return function(t){return e.apply(this,arguments)}}()).catch(function(t){console.log("ERROR: "+t.message)})}},g=function(e){t.setAttributes({embedUrl:"",buttonText:"Embed",lockEmbed:!1,insertItemImage:!1,insertItemOsTitle:!1,insertItemOsView:!1,insertItemOsEdit:!1,insertItemOsStatistics:!1})},w=function(t){window.location.replace(d)},v=osGutenData.onCreateButtonClickOs+"?w_type=slideshow&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8",b=function(t){window.open(v,"_blank").focus()};if(""==osGutenData.isOsConnected)return wp.element.createElement("div",{className:t.className},wp.element.createElement("div",{className:"os-slideshow-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:f,alt:""})),wp.element.createElement("p",{className:"components-heading"},"Please connect WordPress to Opinion Stage to start adding slideshows"),wp.element.createElement("button",{className:"components-button is-button is-default is-block is-primary",onClick:w},"Connect")),wp.element.createElement("div",null));if($(document).ready(function(){$("span#oswpLauncherContentPopupslideshow").live("click",function(t){t.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500);var e=$(this).attr("data-os-block");$("button#dropbtn span").text(e);for(var n=$(".filter__itm"),r=0;r<n.length;r++){if($(n[r]).text()==e){setTimeout(function(){$(n[r]).trigger("click")},1e3),setTimeout(function(){$(".progress_message").css("display","none"),$(".content__list").css("display","block")},2500),$("button.content__links-itm").live("click",function(t){$(".tingle-modal.opinionstage-content-popup").hide(),$(".tingle-modal.opinionstage-content-popup.tingle-modal--visible").hide()});break}$(".progress_message").css("display","block"),$(".content__list").css("display","none")}})}),0!=p)for(var y=0;y<p.length;y++){var E=function(t){var e=document.createElement("a");return e.href=t,e}(p[y].attributes["landing-page-url"]),x=E.pathname;if(n==x){t.setAttributes({lockEmbed:!0,buttonText:"Change"}),t.setAttributes({insertItemImage:p[y].attributes["image-url"]}),t.setAttributes({insertItemOsTitle:p[y].attributes.title}),t.setAttributes({insertItemOsView:p[y].attributes["landing-page-url"]}),t.setAttributes({insertItemOsEdit:p[y].attributes["edit-url"]}),t.setAttributes({insertItemOsStatistics:p[y].attributes["stats-url"]});break}}var k=wp.element.createElement("div",{className:"os-slideshow-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:f,alt:""})),wp.element.createElement("span",{id:"oswpLauncherContentPopupslideshow",className:"components-button is-button is-default is-block is-primary","data-opinionstage-content-launch":!0,"data-os-block":"slideshow",onClick:h},"Select a Slideshow"),wp.element.createElement("input",{type:"button",value:"Create a New Slideshow",className:"components-button is-button is-default is-block is-primary",onClick:b}),wp.element.createElement("span",null));return""!=n&&n?"Embed"==i||"Change"==i&&(k=wp.element.createElement("div",{className:"os-slideshow-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:f,alt:""})),wp.element.createElement("div",{className:"components-preview__block"},wp.element.createElement("div",{className:"components-preview__leftBlockImage"},wp.element.createElement("img",{src:a,alt:s,className:"image"}),wp.element.createElement("div",{className:"overlay"},wp.element.createElement("div",{className:"text"},wp.element.createElement("a",{href:c,target:"_blank"}," View "),wp.element.createElement("a",{href:l,target:"_blank"}," Edit "),wp.element.createElement("a",{href:u,target:"_blank"}," Statistics "),wp.element.createElement("input",{type:"button",value:i,className:"components-button is-button is-default is-large left-align",onClick:g})))),wp.element.createElement("div",{className:"components-preview__rightBlockContent"},wp.element.createElement("div",{className:"components-placeholder__label"},"Slideshow: ",s))),wp.element.createElement("span",null))):""==n||"undefined"===jQuery.type(n)||t.setAttributes({buttonText:"Embed"}),wp.element.createElement("div",{className:t.className},k,wp.element.createElement("span",null))},save:function(t){var e=t.attributes,n=e.embedUrl,r=e.lockEmbed,i=e.buttonText,o=e.insertItemImage,a=e.insertItemOsTitle,s=e.insertItemOsView,c=e.insertItemOsEdit,l=e.insertItemOsStatistics;return wp.element.createElement("div",{class:"os-slideshow-wrapper","data-type":"slideshow","data-image-url":o,"data-title-url":a,"data-view-url":s,"data-statistics-url":l,"data-edit-url":c,"data-test-url":n,"data-lock-embed":r,"data-button-text":i},'[os-widget path="',n,'"]',wp.element.createElement("span",null))}})},function(t,e,n){t.exports=n(3)},function(t,e,n){var r=function(){return this}()||Function("return this")(),i=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,o=i&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,t.exports=n(4),i)r.regeneratorRuntime=o;else try{delete r.regeneratorRuntime}catch(t){r.regeneratorRuntime=void 0}},function(t,e){!function(e){"use strict";function n(t,e,n,r){var o=e&&e.prototype instanceof i?e:i,a=Object.create(o.prototype),s=new d(r||[]);return a._invoke=l(t,n,s),a}function r(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function i(){}function o(){}function a(){}function s(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function c(t){function e(n,i,o,a){var s=r(t[n],t,i);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"===typeof l&&v.call(l,"__await")?Promise.resolve(l.__await).then(function(t){e("next",t,o,a)},function(t){e("throw",t,o,a)}):Promise.resolve(l).then(function(t){c.value=t,o(c)},a)}a(s.arg)}function n(t,n){function r(){return new Promise(function(r,i){e(t,n,r,i)})}return i=i?i.then(r,r):r()}var i;this._invoke=n}function l(t,e,n){var i=_;return function(o,a){if(i===L)throw new Error("Generator is already running");if(i===N){if("throw"===o)throw a;return h()}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var c=u(s,n);if(c){if(c===T)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===_)throw i=N,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=L;var l=r(t,e,n);if("normal"===l.type){if(i=n.done?N:I,l.arg===T)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(i=N,n.method="throw",n.arg=l.arg)}}}function u(t,e){var n=t.iterator[e.method];if(n===g){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=g,u(t,e),"throw"===e.method))return T;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return T}var i=r(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,T;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=g),e.delegate=null,T):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,T)}function p(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function m(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function d(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(p,this),this.reset(!0)}function f(t){if(t){var e=t[y];if(e)return e.call(t);if("function"===typeof t.next)return t;if(!isNaN(t.length)){var n=-1,r=function e(){for(;++n<t.length;)if(v.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=g,e.done=!0,e};return r.next=r}}return{next:h}}function h(){return{value:g,done:!0}}var g,w=Object.prototype,v=w.hasOwnProperty,b="function"===typeof Symbol?Symbol:{},y=b.iterator||"@@iterator",E=b.asyncIterator||"@@asyncIterator",x=b.toStringTag||"@@toStringTag",k="object"===typeof t,O=e.regeneratorRuntime;if(O)return void(k&&(t.exports=O));O=e.regeneratorRuntime=k?t.exports:{},O.wrap=n;var _="suspendedStart",I="suspendedYield",L="executing",N="completed",T={},S={};S[y]=function(){return this};var P=Object.getPrototypeOf,C=P&&P(P(f([])));C&&C!==w&&v.call(C,y)&&(S=C);var j=a.prototype=i.prototype=Object.create(S);o.prototype=j.constructor=a,a.constructor=o,a[x]=o.displayName="GeneratorFunction",O.isGeneratorFunction=function(t){var e="function"===typeof t&&t.constructor;return!!e&&(e===o||"GeneratorFunction"===(e.displayName||e.name))},O.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,a):(t.__proto__=a,x in t||(t[x]="GeneratorFunction")),t.prototype=Object.create(j),t},O.awrap=function(t){return{__await:t}},s(c.prototype),c.prototype[E]=function(){return this},O.AsyncIterator=c,O.async=function(t,e,r,i){var o=new c(n(t,e,r,i));return O.isGeneratorFunction(e)?o:o.next().then(function(t){return t.done?t.value:o.next()})},s(j),j[x]="Generator",j[y]=function(){return this},j.toString=function(){return"[object Generator]"},O.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},O.values=f,d.prototype={constructor:d,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=g,this.done=!1,this.delegate=null,this.method="next",this.arg=g,this.tryEntries.forEach(m),!t)for(var e in this)"t"===e.charAt(0)&&v.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=g)},stop:function(){this.done=!0;var t=this.tryEntries[0],e=t.completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){function e(e,r){return o.type="throw",o.arg=t,n.next=e,r&&(n.method="next",n.arg=g),!!r}if(this.done)throw t;for(var n=this,r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],o=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var a=v.call(i,"catchLoc"),s=v.call(i,"finallyLoc");if(a&&s){if(this.prev<i.catchLoc)return e(i.catchLoc,!0);if(this.prev<i.finallyLoc)return e(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return e(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return e(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&v.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,T):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),T},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),m(n),T}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;m(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:f(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=g),T}}}(function(){return this}()||Function("return this")())},function(t,e){},function(t,e){}]);
gutenberg/slideshow/src/.DS_Store CHANGED
Binary file
gutenberg/slideshow/src/block/block.js CHANGED
@@ -6,13 +6,12 @@ const { registerBlockType } = wp.blocks;
6
  const { SelectControl, TextControl } = wp.components;
7
  const { RichText } = wp.editor ;
8
 
9
- var dropdownOptions = false;
10
- var previewBlockOsTitle;
11
- var previewBlockOsImageUrl;
12
- var previewBlockOsView;
13
- var previewBlockOsEdit;
14
- var previewBlockOsStatistics;
15
- var options;
16
 
17
  registerBlockType( 'opinion-stage/block-os-slideshow', {
18
  title: __( 'Slideshow' ),
@@ -21,18 +20,13 @@ var options;
21
  keywords: [
22
  __( 'Opinion Stage Slideshow' ),
23
  __( 'Opinion Stage Slideshow' ),
24
- ],
25
  attributes: {
26
  embedUrl: {
27
  source: 'attribute',
28
  attribute: 'data-test-url',
29
  selector: 'div[data-test-url]'
30
- },
31
- oswpUrlShortcode: {
32
- source: 'attribute',
33
- attribute: 'data-test-url',
34
- selector: 'div[data-test-url]'
35
- },
36
  lockEmbed: {
37
  source: 'attribute',
38
  attribute: 'data-lock-embed',
@@ -42,174 +36,132 @@ var options;
42
  source: 'attribute',
43
  attribute: 'data-button-text',
44
  selector: 'div[data-button-text]'
45
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  },
47
  edit: function( props ) {
48
- let {attributes: {embedUrl, oswpUrlShortcode, lockEmbed, buttonText}, setAttributes} = props;
49
- const onDropdownChange = val => {
50
- if(val == ''){
51
- props.setAttributes({ embedUrl: '' });
52
- }else if(val != ''){
53
- props.setAttributes({ embedUrl: val });
54
- for (var i = 0; i < dropdownOptions.length; i++) {
55
- var getLandingPageUrlOs = function(href) {
56
- var locationUrlOS = document.createElement("a");
57
- locationUrlOS.href = href;
58
- return locationUrlOS;
59
- };
60
- var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
61
- var matchValue = locationUrlOS.pathname;
62
- if(val == matchValue){
63
- previewBlockOsTitle = dropdownOptions[i].attributes['title'];
64
- previewBlockOsImageUrl = dropdownOptions[i].attributes['image-url'];
65
- previewBlockOsView = dropdownOptions[i].attributes['landing-page-url'];
66
- previewBlockOsEdit = dropdownOptions[i].attributes['edit-url'];
67
- previewBlockOsStatistics = dropdownOptions[i].attributes['stats-url'];
68
- break;
69
- }
70
- }
71
- }else{
72
- }
73
- };
74
- const onEmbedButtonClick = event => {
75
- if( event.target.value == "Embed" ){
76
- if(embedUrl == '' || embedUrl == 'Select' || embedUrl == 'createNew' || embedUrl == 'refresh'){
77
- props.setAttributes({ lockEmbed: false, buttonText: "Embed" });
78
- }else{
79
- props.setAttributes({ lockEmbed: true, buttonText: "Change" });
80
- contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} onChange={onDropdownChange} className="components-select-control__input" />);
81
- }
82
- }else{
83
- props.setAttributes({ lockEmbed: false, buttonText: "Embed" });
84
- }
85
- };
86
-
87
- window.verifyOSInsert = function(widget){
88
- props.setAttributes({ oswpUrlShortcode: widget });
89
- var myOpts = document.getElementById('selectID').options;
90
- for(var i = 0; i < myOpts.length; i++){
91
- if(myOpts[i].value == widget){
92
- myOpts[i].defaultSelected = true;
93
- props.setAttributes({ lockEmbed: true, buttonText: "Change", embedUrl: widget });
94
- break;
95
- }
96
- }
97
- }
98
-
99
- var getOsCreateButtonClickUrl = osGutenData.onCreateButtonClickOs+'?w_type=slideshow&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8';
100
- const onCreateButtonClick = value => {
101
- // Open Create new slideshow link in new page
102
- window.open(getOsCreateButtonClickUrl, '_blank').focus();
103
- };
104
-
105
- if(!buttonText){
106
- props.setAttributes({ buttonText: 'Embed' });
107
- }
108
 
 
109
  var getCallBackUrlOs = osGutenData.callbackUrlOs;
110
  var callback_url = getCallBackUrlOs;
111
  var formActionUrlOS = osGutenData.getActionUrlOS;
112
  var getlogoImageLinkOs = osGutenData.getLogoImageLink;
113
- console.log(callback_url);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  const onConnectOSWPButtonClick = value => {
115
- // Open Connect to opinionstage
116
  window.location.replace(callback_url);
117
  };
118
- // Populate list ajax function
119
- function OsPolulateList() {
120
- var opinionStageWidgetVersion = osGutenData.OswpPluginVersion;
121
- var opinionStageClientToken = osGutenData.OswpClientToken;
122
- var opinionstageFetchDataUrl = osGutenData.OswpFetchDataUrl+'?type=slideshow&page=1&per_page=99';
123
- fetch(opinionstageFetchDataUrl, {
124
- method: "GET",
125
- headers: {
126
- 'Accept':'application/vnd.api+json',
127
- 'Content-Type':'application/vnd.api+json',
128
- 'OSWP-Plugin-Version':opinionStageWidgetVersion,
129
- 'OSWP-Client-Token': opinionStageClientToken
130
- },
131
- })
132
- .then(async res => {
133
- var data = await res.json();
134
- data = data.data;
135
- dropdownOptions = data;
136
- // force reprinting instead!!
137
- props.setAttributes({ buttonText: 'Embed'});
138
- props.setAttributes({ buttonText: buttonText});
139
- if(buttonText == 'Change' && embedUrl !='Select'){
140
- props.setAttributes({ embedUrl: embedUrl });
141
- }else{
142
- props.setAttributes({ embedUrl: 'Select' });
143
- }
144
- })
145
- .catch(function(err) {
146
- console.log('ERROR: ' + err.message);
147
- });
148
- }
149
  // Checking for Opinion Stage connection
150
  if(osGutenData.isOsConnected == ''){
151
- $(document).ready(function () {
152
- $('span#oswpLauncherContentPopupslideshow , #owspLaunchInputCreate').live('click', function(e) {
153
- e.preventDefault();
154
- setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
155
- });
156
- });
157
  return (
158
  <div className={ props.className }>
159
  <div className="os-slideshow-wrapper components-placeholder">
160
  <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
161
  <p className="components-heading">Please connect WordPress to Opinion Stage to start adding slideshows</p>
162
  <button className="components-button is-button is-default is-block is-primary" onClick={onConnectOSWPButtonClick}>Connect</button>
163
- </div>
 
164
  </div>
165
  );
166
- }else{
167
- if(dropdownOptions == false){
168
- options = [{value:'Select',label:'Select a slideshow'},{value:'refresh',label:'Refresh'}];
169
- OsPolulateList();
170
- }else{
171
- options = [{value:'Select',label:'Select a slideshow'},{value:'refresh',label:'Refresh'},{value:'',label:'-----------------'}];
172
- for (var i = 0; i < dropdownOptions.length; i++) {
173
- options[options.length] = {
174
- value: dropdownOptions[i].attributes['landing-page-url'].replace('https://www.opinionstage.com',''),
175
- label: dropdownOptions[i].attributes['title'],
176
- };
177
- var getLandingPageUrlOs = function(href) {
178
- var locationUrlOS = document.createElement("a");
179
- locationUrlOS.href = href;
180
- return locationUrlOS;
181
- };
182
- var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
183
- var matchValue = locationUrlOS.pathname;
184
- if(embedUrl == matchValue){
185
- previewBlockOsTitle = dropdownOptions[i].attributes['title'];
186
- previewBlockOsImageUrl = dropdownOptions[i].attributes['image-url'];
187
- previewBlockOsView = dropdownOptions[i].attributes['landing-page-url'];
188
- previewBlockOsEdit = dropdownOptions[i].attributes['edit-url'];
189
- previewBlockOsStatistics = dropdownOptions[i].attributes['stats-url'];
190
- var previewBlockOsWidgetID = dropdownOptions[i].id;
191
-
192
- }
193
- }
194
- }
195
- if(embedUrl == 'refresh'){
196
- OsPolulateList();
197
- }
198
- var contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} onChange={onDropdownChange} className="components-select-control__input" />);
199
  $(document).ready(function () {
 
200
  $('span#oswpLauncherContentPopupslideshow').live('click', function(e) {
201
  e.preventDefault();
202
  setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
203
  var text = $(this).attr('data-os-block');
204
  $("button#dropbtn span").text(text);
205
- var inputs = $(".filter__itm");
206
  for(var i = 0; i < inputs.length; i++){
207
- if($(inputs[i]).text() == text){
208
- setTimeout(function(){$(inputs[i]).trigger('click');},1000);
209
  setTimeout(function(){
210
- $('.progress_message').css('display', 'none');
211
- $('.content__list').css('display', 'block');
212
- },2500);
 
 
 
213
  $('button.content__links-itm').live('click', function(e) {
214
  $('.tingle-modal.opinionstage-content-popup').hide();
215
  $('.tingle-modal.opinionstage-content-popup.tingle-modal--visible').hide();
@@ -219,83 +171,89 @@ var options;
219
  else {
220
  $('.progress_message').css('display', 'block');
221
  $('.content__list').css('display', 'none');
222
- console.log('test');
223
  }
224
  }
225
  });
226
  });
227
 
228
- var contentViewEditStatOs = (
229
- <div className="os-slideshow-wrapper components-placeholder">
230
- <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
231
- <span id="oswpLauncherContentPopupslideshow" className="components-button is-button is-default is-block is-primary" data-opinionstage-content-launch data-os-block="slideshow">Select a Slideshow</span>
232
- <input type="button" value="Create a New Slideshow" className="components-button is-button is-default is-block is-primary" onClick={onCreateButtonClick} />
233
- <div className="components-placeholder__fieldset">
234
- {contentDropdown}
235
- <input type="button" value={buttonText} className="components-button is-button is-default is-large" id="clickMe" onClick={onEmbedButtonClick} />
236
- </div>
237
- </div>
238
- );
239
-
240
- var dataOpinionStageEmbedUrl = 'https://www.opinionstage.com/api/v1/widgets/'+embedUrl+'/code.json?comments=true&amp;sharing=true&amp;recommendations=false&amp;width=';
241
- var OpinionStageDataIframe = 'https://www.opinionstage.com/'+embedUrl+'?wid=0&amp;em=1&amp;comments=null&amp;referring_widget='+embedUrl+'&amp;autoswitch=1&amp;of=&amp;os_utm_source=null';
242
- (function(d, s, id){
243
- var js,
244
- fjs = d.getElementsByTagName(s)[0],
245
- r = Math.floor(new Date().getTime() / 1000000);
246
- if (d.getElementById(id)) {return;}
247
- js = d.createElement(s); js.id = id; js.async=1;
248
- js.src = "https://www.opinionstage.com/assets/loader.js?" + r;
249
- fjs.parentNode.insertBefore(js, fjs);
250
- }(document, 'script', 'os-widget-jssdk'));
251
- previewBlockOsWidgetID = 'os-widget-'+previewBlockOsWidgetID;
252
-
253
- if(embedUrl != '' && embedUrl != 'Select' && embedUrl){
 
 
 
 
 
 
 
254
  if(buttonText == 'Embed'){
255
  contentViewEditStatOs
256
- }else if(buttonText == 'Change'){
257
  contentViewEditStatOs = (
258
- <div className="os-slideshow-wrapper components-placeholder">
259
- <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
260
- <div className="components-preview__block" >
261
- <div className="components-preview__leftBlockImage">
262
- <img src={previewBlockOsImageUrl} alt={previewBlockOsTitle} className="image" />
263
- <div className="overlay">
264
- <div className="text">
265
- <a href={previewBlockOsView} target="_blank"> View </a>
266
- <a href={previewBlockOsEdit} target="_blank"> Edit </a>
267
- <a href={previewBlockOsStatistics} target="_blank"> Statistics </a>
268
- <input type="button" value={buttonText} className="components-button is-button is-default is-large left-align" onClick={onEmbedButtonClick} />
269
- </div>
 
 
 
 
270
  </div>
271
- </div>
272
- <div className="components-preview__rightBlockContent">
273
- <div className="components-placeholder__label">Slideshow: {previewBlockOsTitle}</div>
274
- </div>
275
- </div>
276
- </div>
277
- );
278
- contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} disabled onChange={onDropdownChange} className="components-select-control__input" />);
279
  }
280
- }else if(embedUrl == 'Select' || embedUrl == '' || embedUrl == 'refresh'){
281
  contentViewEditStatOs
282
  }else{
283
  props.setAttributes({ buttonText: 'Embed'});
284
  contentViewEditStatOs
285
  }
286
-
287
-
288
- return (
289
  <div className={ props.className }>
290
- {contentViewEditStatOs}
 
291
  </div>
292
  );
293
  }
294
  },
295
- save: function( {attributes: {embedUrl, oswpUrlShortcode, lockEmbed, buttonText}} ) {
296
  return (
297
- <div class="os-slideshow-wrapper" data-type="slideshow" data-test-url={oswpUrlShortcode} data-lock-embed={lockEmbed} data-button-text={buttonText}>
298
- [os-widget path="{oswpUrlShortcode}"]
 
299
  </div>
300
  );
301
  },
6
  const { SelectControl, TextControl } = wp.components;
7
  const { RichText } = wp.editor ;
8
 
9
+ var dropdownOptions = false;
10
+ var insertItemImage = false;
11
+ var insertItemOsTitle = false;
12
+ var insertItemOsView = false;
13
+ var insertItemOsEdit = false;
14
+ var insertItemOsStatistics = false;
 
15
 
16
  registerBlockType( 'opinion-stage/block-os-slideshow', {
17
  title: __( 'Slideshow' ),
20
  keywords: [
21
  __( 'Opinion Stage Slideshow' ),
22
  __( 'Opinion Stage Slideshow' ),
23
+ ],
24
  attributes: {
25
  embedUrl: {
26
  source: 'attribute',
27
  attribute: 'data-test-url',
28
  selector: 'div[data-test-url]'
29
+ },
 
 
 
 
 
30
  lockEmbed: {
31
  source: 'attribute',
32
  attribute: 'data-lock-embed',
36
  source: 'attribute',
37
  attribute: 'data-button-text',
38
  selector: 'div[data-button-text]'
39
+ },
40
+ insertItemImage: {
41
+ source: 'attribute',
42
+ attribute: 'data-image-url',
43
+ selector: 'div[data-image-url]'
44
+ },
45
+ insertItemOsTitle: {
46
+ source: 'attribute',
47
+ attribute: 'data-title-url',
48
+ selector: 'div[data-title-url]'
49
+ },
50
+ insertItemOsView: {
51
+ source: 'attribute',
52
+ attribute: 'data-view-url',
53
+ selector: 'div[data-view-url]'
54
+ },
55
+ insertItemOsEdit: {
56
+ source: 'attribute',
57
+ attribute: 'data-edit-url',
58
+ selector: 'div[data-edit-url]'
59
+ },
60
+ insertItemOsStatistics: {
61
+ source: 'attribute',
62
+ attribute: 'data-statistics-url',
63
+ selector: 'div[data-statistics-url]'
64
+ }
65
  },
66
  edit: function( props ) {
67
+ // Setting Attributes
68
+ let {attributes: {embedUrl, lockEmbed, buttonText, insertItemImage,insertItemOsTitle,insertItemOsView,insertItemOsEdit,insertItemOsStatistics}, setAttributes} = props;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ // Fetching Localized variables
71
  var getCallBackUrlOs = osGutenData.callbackUrlOs;
72
  var callback_url = getCallBackUrlOs;
73
  var formActionUrlOS = osGutenData.getActionUrlOS;
74
  var getlogoImageLinkOs = osGutenData.getLogoImageLink;
75
+
76
+ // Select Button Click functionality
77
+ const onSelectButtonClick = value => {
78
+ window.verifyOSInsert = function(widget){
79
+ props.setAttributes({ embedUrl: widget, buttonText:'Change' });
80
+
81
+ var opinionStageWidgetVersion = osGutenData.OswpPluginVersion;
82
+ var opinionStageClientToken = osGutenData.OswpClientToken;
83
+ var opinionstageFetchDataUrl = osGutenData.OswpFetchDataUrl+'?type=slideshow&page=1&per_page=99';
84
+ fetch(opinionstageFetchDataUrl, {
85
+ method: "GET",
86
+ headers: {
87
+ 'Accept':'application/vnd.api+json',
88
+ 'Content-Type':'application/vnd.api+json',
89
+ 'OSWP-Plugin-Version':opinionStageWidgetVersion,
90
+ 'OSWP-Client-Token': opinionStageClientToken
91
+ },
92
+ })
93
+ .then(async res => {
94
+ var data = await res.json();
95
+ data = data.data;
96
+ dropdownOptions = data;
97
+ // force reprinting instead!!
98
+ props.setAttributes({ buttonText: buttonText});
99
+
100
+ })
101
+ .catch(function(err) {
102
+ console.log('ERROR: ' + err.message);
103
+ });
104
+ }
105
+ }
106
+
107
+ // Change Button Click functionality
108
+ const onChangeButtonClick = value => {
109
+ props.setAttributes({
110
+ embedUrl: '',
111
+ buttonText:'Embed',
112
+ lockEmbed: false,
113
+ insertItemImage: false,
114
+ insertItemOsTitle: false,
115
+ insertItemOsView: false,
116
+ insertItemOsEdit: false,
117
+ insertItemOsStatistics: false
118
+ });
119
+ }
120
+
121
+ // Connect to Opinionstage Callback Url
122
  const onConnectOSWPButtonClick = value => {
 
123
  window.location.replace(callback_url);
124
  };
125
+
126
+ // Create New Item Url (slideshow)
127
+ var getOsCreateButtonClickUrl = osGutenData.onCreateButtonClickOs+'?w_type=slideshow&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8';
128
+ const onCreateButtonClick = value => {
129
+ // Open Create new slideshow link in new page
130
+ window.open(getOsCreateButtonClickUrl, '_blank').focus();
131
+ };
132
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  // Checking for Opinion Stage connection
134
  if(osGutenData.isOsConnected == ''){
135
+ // Not Connected to opinionstage
 
 
 
 
 
136
  return (
137
  <div className={ props.className }>
138
  <div className="os-slideshow-wrapper components-placeholder">
139
  <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
140
  <p className="components-heading">Please connect WordPress to Opinion Stage to start adding slideshows</p>
141
  <button className="components-button is-button is-default is-block is-primary" onClick={onConnectOSWPButtonClick}>Connect</button>
142
+ </div>
143
+ <div></div>
144
  </div>
145
  );
146
+ }else{
147
+ // Connected to opinionstage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  $(document).ready(function () {
149
+ // Content Popup Launch Working
150
  $('span#oswpLauncherContentPopupslideshow').live('click', function(e) {
151
  e.preventDefault();
152
  setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
153
  var text = $(this).attr('data-os-block');
154
  $("button#dropbtn span").text(text);
155
+ var inputs = $(".filter__itm");
156
  for(var i = 0; i < inputs.length; i++){
157
+ if($(inputs[i]).text() == text){
 
158
  setTimeout(function(){
159
+ $(inputs[i]).trigger('click');
160
+ },1000);
161
+ setTimeout(function(){
162
+ $('.progress_message').css('display', 'none');
163
+ $('.content__list').css('display', 'block');
164
+ },2500);
165
  $('button.content__links-itm').live('click', function(e) {
166
  $('.tingle-modal.opinionstage-content-popup').hide();
167
  $('.tingle-modal.opinionstage-content-popup.tingle-modal--visible').hide();
171
  else {
172
  $('.progress_message').css('display', 'block');
173
  $('.content__list').css('display', 'none');
 
174
  }
175
  }
176
  });
177
  });
178
 
179
+ // Fetching Ajax Call Result
180
+ if(dropdownOptions != false){
181
+ for (var i = 0; i < dropdownOptions.length; i++) {
182
+ var getLandingPageUrlOs = function(href) {
183
+ var locationUrlOS = document.createElement("a");
184
+ locationUrlOS.href = href;
185
+ return locationUrlOS;
186
+ };
187
+ var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
188
+ var matchValue = locationUrlOS.pathname;
189
+ if(embedUrl == matchValue){
190
+ props.setAttributes({lockEmbed: true, buttonText: "Change" });
191
+ props.setAttributes({ insertItemImage : dropdownOptions[i].attributes['image-url'] });
192
+ props.setAttributes({ insertItemOsTitle : dropdownOptions[i].attributes['title'] });
193
+ props.setAttributes({ insertItemOsView : dropdownOptions[i].attributes['landing-page-url'] });
194
+ props.setAttributes({ insertItemOsEdit : dropdownOptions[i].attributes['edit-url'] });
195
+ props.setAttributes({ insertItemOsStatistics : dropdownOptions[i].attributes['stats-url'] });
196
+ break;
197
+ }
198
+ }
199
+ }
200
+
201
+ // Content On Editor
202
+ var contentViewEditStatOs = (
203
+ <div className="os-slideshow-wrapper components-placeholder">
204
+ <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
205
+ <span id="oswpLauncherContentPopupslideshow" className="components-button is-button is-default is-block is-primary" data-opinionstage-content-launch data-os-block="slideshow" onClick={onSelectButtonClick} >Select a Slideshow</span>
206
+ <input type="button" value="Create a New Slideshow" className="components-button is-button is-default is-block is-primary" onClick={onCreateButtonClick} />
207
+ <span></span>
208
+ </div>
209
+ );
210
+
211
+ if(embedUrl != '' && embedUrl){
212
  if(buttonText == 'Embed'){
213
  contentViewEditStatOs
214
+ }else if(buttonText == 'Change'){
215
  contentViewEditStatOs = (
216
+ <div className="os-slideshow-wrapper components-placeholder">
217
+ <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
218
+ <div className="components-preview__block" >
219
+ <div className="components-preview__leftBlockImage">
220
+ <img src={insertItemImage} alt={insertItemOsTitle} className="image" />
221
+ <div className="overlay">
222
+ <div className="text">
223
+ <a href={insertItemOsView} target="_blank"> View </a>
224
+ <a href={insertItemOsEdit} target="_blank"> Edit </a>
225
+ <a href={insertItemOsStatistics} target="_blank"> Statistics </a>
226
+ <input type="button" value={buttonText} className="components-button is-button is-default is-large left-align" onClick={onChangeButtonClick}/>
227
+ </div>
228
+ </div>
229
+ </div>
230
+ <div className="components-preview__rightBlockContent">
231
+ <div className="components-placeholder__label">Slideshow: {insertItemOsTitle}</div>
232
  </div>
233
+ </div>
234
+ <span></span>
235
+ </div>
236
+ );
 
 
 
 
237
  }
238
+ }else if(embedUrl == '' || jQuery.type(embedUrl) === "undefined"){
239
  contentViewEditStatOs
240
  }else{
241
  props.setAttributes({ buttonText: 'Embed'});
242
  contentViewEditStatOs
243
  }
244
+ return (
 
 
245
  <div className={ props.className }>
246
+ {contentViewEditStatOs}
247
+ <span></span>
248
  </div>
249
  );
250
  }
251
  },
252
+ save: function( {attributes: {embedUrl, lockEmbed, buttonText, insertItemImage, insertItemOsTitle, insertItemOsView, insertItemOsEdit, insertItemOsStatistics }} ) {
253
  return (
254
+ <div class="os-slideshow-wrapper" data-type="slideshow" data-image-url={insertItemImage} data-title-url={insertItemOsTitle} data-view-url={insertItemOsView} data-statistics-url={insertItemOsStatistics} data-edit-url={insertItemOsEdit} data-test-url={embedUrl} data-lock-embed={lockEmbed} data-button-text={buttonText}>
255
+ [os-widget path="{embedUrl}"]
256
+ <span></span>
257
  </div>
258
  );
259
  },
gutenberg/survey/dist/blocks.build.js CHANGED
@@ -1 +1 @@
1
- !function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});n(1)},function(e,t,n){"use strict";function r(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){function r(o,a){try{var i=t[o](a),s=i.value}catch(e){return void n(e)}if(!i.done)return Promise.resolve(s).then(function(e){r("next",e)},function(e){r("throw",e)});e(s)}return r("next")})}}var o,a,i,s,c,l,u=n(2),p=n.n(u),m=n(5),f=(n.n(m),n(6)),d=(n.n(f),wp.i18n.__),h=wp.blocks.registerBlockType,v=wp.components,g=v.SelectControl,b=(v.TextControl,wp.editor.RichText,!1);h("opinion-stage/block-os-survey",{title:d("Survey"),icon:"list-view",category:"opinion-stage",keywords:[d("Opinion Stage Survey"),d("Opinion Stage Survey")],attributes:{embedUrl:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},oswpUrlShortcode:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},lockEmbed:{source:"attribute",attribute:"data-lock-embed",selector:"div[data-lock-embed]"},buttonText:{source:"attribute",attribute:"data-button-text",selector:"div[data-button-text]"}},edit:function(e){function t(){var t=this,n=osGutenData.OswpPluginVersion,o=osGutenData.OswpClientToken,a=osGutenData.OswpFetchDataUrl+"?type=survey&page=1&per_page=99";fetch(a,{method:"GET",headers:{Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json","OSWP-Plugin-Version":n,"OSWP-Client-Token":o}}).then(function(){var n=r(p.a.mark(function n(r){var o;return p.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.json();case 2:o=t.sent,o=o.data,b=o,e.setAttributes({buttonText:"Embed"}),e.setAttributes({buttonText:m}),"Change"==m&&"Select"!=u?e.setAttributes({embedUrl:u}):e.setAttributes({embedUrl:"Select"});case 8:case"end":return t.stop()}},n,t)}));return function(e){return n.apply(this,arguments)}}()).catch(function(e){console.log("ERROR: "+e.message)})}var n=e.attributes,u=n.embedUrl,m=(n.oswpUrlShortcode,n.lockEmbed,n.buttonText),f=(e.setAttributes,function(t){if(""==t)e.setAttributes({embedUrl:""});else if(""!=t){e.setAttributes({embedUrl:t});for(var n=0;n<b.length;n++){var r=function(e){var t=document.createElement("a");return t.href=e,t}(b[n].attributes["landing-page-url"]),l=r.pathname;if(t==l){o=b[n].attributes.title,a=b[n].attributes["image-url"],i=b[n].attributes["landing-page-url"],s=b[n].attributes["edit-url"],c=b[n].attributes["stats-url"];break}}}}),d=function(t){"Embed"==t.target.value?""==u||"Select"==u||"createNew"==u||"refresh"==u?e.setAttributes({lockEmbed:!1,buttonText:"Embed"}):(e.setAttributes({lockEmbed:!0,buttonText:"Change"}),L=wp.element.createElement(g,{id:"selectID",options:l,value:u,onChange:f,className:"components-select-control__input"})):e.setAttributes({lockEmbed:!1,buttonText:"Embed"})};window.verifyOSInsert=function(t){e.setAttributes({oswpUrlShortcode:t});for(var n=document.getElementById("selectID").options,r=0;r<n.length;r++)if(n[r].value==t){n[r].defaultSelected=!0,e.setAttributes({lockEmbed:!0,buttonText:"Change",embedUrl:t});break}};var h=osGutenData.onCreateButtonClickOs+"?w_type=survey&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8",v=function(e){window.open(h,"_blank").focus()};m||e.setAttributes({buttonText:"Embed"});var y=osGutenData.callbackUrlOs,w=y,E=(osGutenData.getActionUrlOS,osGutenData.getLogoImageLink),k=function(e){window.location.replace(w)};if(""==osGutenData.isOsConnected)return $(document).ready(function(){$("span#oswpLauncherContentPopupsurvey , #owspLaunchInputCreate").live("click",function(e){e.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500)})}),wp.element.createElement("div",{className:e.className},wp.element.createElement("div",{className:"os-survey-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:E,alt:""})),wp.element.createElement("p",{className:"components-heading"},"Please connect WordPress to Opinion Stage to start adding surveys"),wp.element.createElement("button",{className:"components-button is-button is-default is-block is-primary",onClick:k},"Connect")));if(0==b)l=[{value:"Select",label:"Select a survey"},{value:"refresh",label:"Refresh"}],t();else{l=[{value:"Select",label:"Select a survey"},{value:"refresh",label:"Refresh"},{value:"",label:"-----------------"}];for(var x=0;x<b.length;x++){l[l.length]={value:b[x].attributes["landing-page-url"].replace("https://www.opinionstage.com",""),label:b[x].attributes.title};var _=function(e){var t=document.createElement("a");return t.href=e,t}(b[x].attributes["landing-page-url"]),N=_.pathname;if(u==N){o=b[x].attributes.title,a=b[x].attributes["image-url"],i=b[x].attributes["landing-page-url"],s=b[x].attributes["edit-url"],c=b[x].attributes["stats-url"];var S=b[x].id}}}"refresh"==u&&t();var L=wp.element.createElement(g,{id:"selectID",options:l,value:u,onChange:f,className:"components-select-control__input"});$(document).ready(function(){$("span#oswpLauncherContentPopupsurvey").live("click",function(e){e.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500);var t=$(this).attr("data-os-block");$("button#dropbtn span").text(t);for(var n=$(".filter__itm"),r=0;r<n.length;r++){if($(n[r]).text()==t){setTimeout(function(){$(n[r]).trigger("click")},1e3),setTimeout(function(){$(".progress_message").css("display","none"),$(".content__list").css("display","block")},2500),$("button.content__links-itm").live("click",function(e){$(".tingle-modal.opinionstage-content-popup").hide(),$(".tingle-modal.opinionstage-content-popup.tingle-modal--visible").hide()});break}$(".progress_message").css("display","block"),$(".content__list").css("display","none"),console.log("test")}})});var O=wp.element.createElement("div",{className:"os-survey-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:E,alt:""})),wp.element.createElement("span",{id:"oswpLauncherContentPopupsurvey",className:"components-button is-button is-default is-block is-primary","data-opinionstage-content-launch":!0,"data-os-block":"survey"},"Select a Survey"),wp.element.createElement("input",{type:"button",value:"Create a New Survey",className:"components-button is-button is-default is-block is-primary",onClick:v}),wp.element.createElement("div",{className:"components-placeholder__fieldset"},L,wp.element.createElement("input",{type:"button",value:m,className:"components-button is-button is-default is-large",id:"clickMe",onClick:d})));return function(e,t,n){var r,o=e.getElementsByTagName(t)[0],a=Math.floor((new Date).getTime()/1e6);e.getElementById(n)||(r=e.createElement(t),r.id=n,r.async=1,r.src="https://www.opinionstage.com/assets/loader.js?"+a,o.parentNode.insertBefore(r,o))}(document,"script","os-widget-jssdk"),S="os-widget-"+S,""!=u&&"Select"!=u&&u?"Embed"==m||"Change"==m&&(O=wp.element.createElement("div",{className:"os-survey-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:E,alt:""})),wp.element.createElement("div",{className:"components-preview__block"},wp.element.createElement("div",{className:"components-preview__leftBlockImage"},wp.element.createElement("img",{src:a,alt:o,className:"image"}),wp.element.createElement("div",{className:"overlay"},wp.element.createElement("div",{className:"text"},wp.element.createElement("a",{href:i,target:"_blank"}," View "),wp.element.createElement("a",{href:s,target:"_blank"}," Edit "),wp.element.createElement("a",{href:c,target:"_blank"}," Statistics "),wp.element.createElement("input",{type:"button",value:m,className:"components-button is-button is-default is-large left-align",onClick:d})))),wp.element.createElement("div",{className:"components-preview__rightBlockContent"},wp.element.createElement("div",{className:"components-placeholder__label"},"Survey: ",o)))),L=wp.element.createElement(g,{id:"selectID",options:l,value:u,disabled:!0,onChange:f,className:"components-select-control__input"})):"Select"==u||""==u||"refresh"==u||e.setAttributes({buttonText:"Embed"}),wp.element.createElement("div",{className:e.className},O)},save:function(e){var t=e.attributes,n=(t.embedUrl,t.oswpUrlShortcode),r=t.lockEmbed,o=t.buttonText;return wp.element.createElement("div",{class:"os-survey-wrapper","data-type":"survey","data-test-url":n,"data-lock-embed":r,"data-button-text":o},'[os-widget path="',n,'"]')}})},function(e,t,n){e.exports=n(3)},function(e,t,n){var r=function(){return this}()||Function("return this")(),o=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,a=o&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,e.exports=n(4),o)r.regeneratorRuntime=a;else try{delete r.regeneratorRuntime}catch(e){r.regeneratorRuntime=void 0}},function(e,t){!function(t){"use strict";function n(e,t,n,r){var a=t&&t.prototype instanceof o?t:o,i=Object.create(a.prototype),s=new f(r||[]);return i._invoke=l(e,n,s),i}function r(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}function o(){}function a(){}function i(){}function s(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function c(e){function t(n,o,a,i){var s=r(e[n],e,o);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"===typeof l&&b.call(l,"__await")?Promise.resolve(l.__await).then(function(e){t("next",e,a,i)},function(e){t("throw",e,a,i)}):Promise.resolve(l).then(function(e){c.value=e,a(c)},i)}i(s.arg)}function n(e,n){function r(){return new Promise(function(r,o){t(e,n,r,o)})}return o=o?o.then(r,r):r()}var o;this._invoke=n}function l(e,t,n){var o=N;return function(a,i){if(o===L)throw new Error("Generator is already running");if(o===O){if("throw"===a)throw i;return h()}for(n.method=a,n.arg=i;;){var s=n.delegate;if(s){var c=u(s,n);if(c){if(c===T)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===N)throw o=O,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=L;var l=r(e,t,n);if("normal"===l.type){if(o=n.done?O:S,l.arg===T)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=O,n.method="throw",n.arg=l.arg)}}}function u(e,t){var n=e.iterator[t.method];if(n===v){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=v,u(e,t),"throw"===t.method))return T;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return T}var o=r(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,T;var a=o.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=v),t.delegate=null,T):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,T)}function p(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function m(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function f(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(p,this),this.reset(!0)}function d(e){if(e){var t=e[w];if(t)return t.call(e);if("function"===typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(b.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=v,t.done=!0,t};return r.next=r}}return{next:h}}function h(){return{value:v,done:!0}}var v,g=Object.prototype,b=g.hasOwnProperty,y="function"===typeof Symbol?Symbol:{},w=y.iterator||"@@iterator",E=y.asyncIterator||"@@asyncIterator",k=y.toStringTag||"@@toStringTag",x="object"===typeof e,_=t.regeneratorRuntime;if(_)return void(x&&(e.exports=_));_=t.regeneratorRuntime=x?e.exports:{},_.wrap=n;var N="suspendedStart",S="suspendedYield",L="executing",O="completed",T={},C={};C[w]=function(){return this};var P=Object.getPrototypeOf,j=P&&P(P(d([])));j&&j!==g&&b.call(j,w)&&(C=j);var A=i.prototype=o.prototype=Object.create(C);a.prototype=A.constructor=i,i.constructor=a,i[k]=a.displayName="GeneratorFunction",_.isGeneratorFunction=function(e){var t="function"===typeof e&&e.constructor;return!!t&&(t===a||"GeneratorFunction"===(t.displayName||t.name))},_.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,i):(e.__proto__=i,k in e||(e[k]="GeneratorFunction")),e.prototype=Object.create(A),e},_.awrap=function(e){return{__await:e}},s(c.prototype),c.prototype[E]=function(){return this},_.AsyncIterator=c,_.async=function(e,t,r,o){var a=new c(n(e,t,r,o));return _.isGeneratorFunction(t)?a:a.next().then(function(e){return e.done?e.value:a.next()})},s(A),A[k]="Generator",A[w]=function(){return this},A.toString=function(){return"[object Generator]"},_.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},_.values=d,f.prototype={constructor:f,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=v,this.done=!1,this.delegate=null,this.method="next",this.arg=v,this.tryEntries.forEach(m),!e)for(var t in this)"t"===t.charAt(0)&&b.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=v)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){function t(t,r){return a.type="throw",a.arg=e,n.next=t,r&&(n.method="next",n.arg=v),!!r}if(this.done)throw e;for(var n=this,r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var i=b.call(o,"catchLoc"),s=b.call(o,"finallyLoc");if(i&&s){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(i){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&b.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,T):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),T},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),m(n),T}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;m(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:d(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=v),T}}}(function(){return this}()||Function("return this")())},function(e,t){},function(e,t){}]);
1
+ !function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});n(1)},function(t,e,n){"use strict";function r(t){return function(){var e=t.apply(this,arguments);return new Promise(function(t,n){function r(i,o){try{var a=e[i](o),s=a.value}catch(t){return void n(t)}if(!a.done)return Promise.resolve(s).then(function(t){r("next",t)},function(t){r("throw",t)});t(s)}return r("next")})}}var i=n(2),o=n.n(i),a=n(5),s=(n.n(a),n(6)),c=(n.n(s),wp.i18n.__),u=wp.blocks.registerBlockType,l=wp.components,p=(l.SelectControl,l.TextControl,wp.editor.RichText,!1);u("opinion-stage/block-os-survey",{title:c("Survey"),icon:"list-view",category:"opinion-stage",keywords:[c("Opinion Stage Survey"),c("Opinion Stage Survey")],attributes:{embedUrl:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},lockEmbed:{source:"attribute",attribute:"data-lock-embed",selector:"div[data-lock-embed]"},buttonText:{source:"attribute",attribute:"data-button-text",selector:"div[data-button-text]"},insertItemImage:{source:"attribute",attribute:"data-image-url",selector:"div[data-image-url]"},insertItemOsTitle:{source:"attribute",attribute:"data-title-url",selector:"div[data-title-url]"},insertItemOsView:{source:"attribute",attribute:"data-view-url",selector:"div[data-view-url]"},insertItemOsEdit:{source:"attribute",attribute:"data-edit-url",selector:"div[data-edit-url]"},insertItemOsStatistics:{source:"attribute",attribute:"data-statistics-url",selector:"div[data-statistics-url]"}},edit:function(t){var e=t.attributes,n=e.embedUrl,i=(e.lockEmbed,e.buttonText),a=e.insertItemImage,s=e.insertItemOsTitle,c=e.insertItemOsView,u=e.insertItemOsEdit,l=e.insertItemOsStatistics,m=(t.setAttributes,osGutenData.callbackUrlOs),d=m,f=(osGutenData.getActionUrlOS,osGutenData.getLogoImageLink),h=function(e){window.verifyOSInsert=function(e){var n=this;t.setAttributes({embedUrl:e,buttonText:"Change"});var a=osGutenData.OswpPluginVersion,s=osGutenData.OswpClientToken,c=osGutenData.OswpFetchDataUrl+"?type=survey&page=1&per_page=99";fetch(c,{method:"GET",headers:{Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json","OSWP-Plugin-Version":a,"OSWP-Client-Token":s}}).then(function(){var e=r(o.a.mark(function e(r){var a;return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.json();case 2:a=e.sent,a=a.data,p=a,t.setAttributes({buttonText:i});case 6:case"end":return e.stop()}},e,n)}));return function(t){return e.apply(this,arguments)}}()).catch(function(t){console.log("ERROR: "+t.message)})}},v=function(e){t.setAttributes({embedUrl:"",buttonText:"Embed",lockEmbed:!1,insertItemImage:!1,insertItemOsTitle:!1,insertItemOsView:!1,insertItemOsEdit:!1,insertItemOsStatistics:!1})},g=function(t){window.location.replace(d)},y=osGutenData.onCreateButtonClickOs+"?w_type=survey&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8",b=function(t){window.open(y,"_blank").focus()};if(""==osGutenData.isOsConnected)return wp.element.createElement("div",{className:t.className},wp.element.createElement("div",{className:"os-survey-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:f,alt:""})),wp.element.createElement("p",{className:"components-heading"},"Please connect WordPress to Opinion Stage to start adding surveys"),wp.element.createElement("button",{className:"components-button is-button is-default is-block is-primary",onClick:g},"Connect")),wp.element.createElement("div",null));if($(document).ready(function(){$("span#oswpLauncherContentPopupsurvey").live("click",function(t){t.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500);var e=$(this).attr("data-os-block");$("button#dropbtn span").text(e);for(var n=$(".filter__itm"),r=0;r<n.length;r++){if($(n[r]).text()==e){setTimeout(function(){$(n[r]).trigger("click")},1e3),setTimeout(function(){$(".progress_message").css("display","none"),$(".content__list").css("display","block")},2500),$("button.content__links-itm").live("click",function(t){$(".tingle-modal.opinionstage-content-popup").hide(),$(".tingle-modal.opinionstage-content-popup.tingle-modal--visible").hide()});break}$(".progress_message").css("display","block"),$(".content__list").css("display","none")}})}),0!=p)for(var w=0;w<p.length;w++){var E=function(t){var e=document.createElement("a");return e.href=t,e}(p[w].attributes["landing-page-url"]),x=E.pathname;if(n==x){t.setAttributes({lockEmbed:!0,buttonText:"Change"}),t.setAttributes({insertItemImage:p[w].attributes["image-url"]}),t.setAttributes({insertItemOsTitle:p[w].attributes.title}),t.setAttributes({insertItemOsView:p[w].attributes["landing-page-url"]}),t.setAttributes({insertItemOsEdit:p[w].attributes["edit-url"]}),t.setAttributes({insertItemOsStatistics:p[w].attributes["stats-url"]});break}}var k=wp.element.createElement("div",{className:"os-survey-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:f,alt:""})),wp.element.createElement("span",{id:"oswpLauncherContentPopupsurvey",className:"components-button is-button is-default is-block is-primary","data-opinionstage-content-launch":!0,"data-os-block":"survey",onClick:h},"Select a Survey"),wp.element.createElement("input",{type:"button",value:"Create a New survey",className:"components-button is-button is-default is-block is-primary",onClick:b}),wp.element.createElement("span",null));return""!=n&&n?"Embed"==i||"Change"==i&&(k=wp.element.createElement("div",{className:"os-survey-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:f,alt:""})),wp.element.createElement("div",{className:"components-preview__block"},wp.element.createElement("div",{className:"components-preview__leftBlockImage"},wp.element.createElement("img",{src:a,alt:s,className:"image"}),wp.element.createElement("div",{className:"overlay"},wp.element.createElement("div",{className:"text"},wp.element.createElement("a",{href:c,target:"_blank"}," View "),wp.element.createElement("a",{href:u,target:"_blank"}," Edit "),wp.element.createElement("a",{href:l,target:"_blank"}," Statistics "),wp.element.createElement("input",{type:"button",value:i,className:"components-button is-button is-default is-large left-align",onClick:v})))),wp.element.createElement("div",{className:"components-preview__rightBlockContent"},wp.element.createElement("div",{className:"components-placeholder__label"},"Survey: ",s))),wp.element.createElement("span",null))):""==n||"undefined"===jQuery.type(n)||t.setAttributes({buttonText:"Embed"}),wp.element.createElement("div",{className:t.className},k,wp.element.createElement("span",null))},save:function(t){var e=t.attributes,n=e.embedUrl,r=e.lockEmbed,i=e.buttonText,o=e.insertItemImage,a=e.insertItemOsTitle,s=e.insertItemOsView,c=e.insertItemOsEdit,u=e.insertItemOsStatistics;return wp.element.createElement("div",{class:"os-survey-wrapper","data-type":"survey","data-image-url":o,"data-title-url":a,"data-view-url":s,"data-statistics-url":u,"data-edit-url":c,"data-test-url":n,"data-lock-embed":r,"data-button-text":i},'[os-widget path="',n,'"]',wp.element.createElement("span",null))}})},function(t,e,n){t.exports=n(3)},function(t,e,n){var r=function(){return this}()||Function("return this")(),i=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,o=i&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,t.exports=n(4),i)r.regeneratorRuntime=o;else try{delete r.regeneratorRuntime}catch(t){r.regeneratorRuntime=void 0}},function(t,e){!function(e){"use strict";function n(t,e,n,r){var o=e&&e.prototype instanceof i?e:i,a=Object.create(o.prototype),s=new d(r||[]);return a._invoke=u(t,n,s),a}function r(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function i(){}function o(){}function a(){}function s(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function c(t){function e(n,i,o,a){var s=r(t[n],t,i);if("throw"!==s.type){var c=s.arg,u=c.value;return u&&"object"===typeof u&&y.call(u,"__await")?Promise.resolve(u.__await).then(function(t){e("next",t,o,a)},function(t){e("throw",t,o,a)}):Promise.resolve(u).then(function(t){c.value=t,o(c)},a)}a(s.arg)}function n(t,n){function r(){return new Promise(function(r,i){e(t,n,r,i)})}return i=i?i.then(r,r):r()}var i;this._invoke=n}function u(t,e,n){var i=_;return function(o,a){if(i===L)throw new Error("Generator is already running");if(i===N){if("throw"===o)throw a;return h()}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var c=l(s,n);if(c){if(c===T)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===_)throw i=N,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=L;var u=r(t,e,n);if("normal"===u.type){if(i=n.done?N:I,u.arg===T)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=N,n.method="throw",n.arg=u.arg)}}}function l(t,e){var n=t.iterator[e.method];if(n===v){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=v,l(t,e),"throw"===e.method))return T;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return T}var i=r(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,T;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=v),e.delegate=null,T):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,T)}function p(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function m(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function d(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(p,this),this.reset(!0)}function f(t){if(t){var e=t[w];if(e)return e.call(t);if("function"===typeof t.next)return t;if(!isNaN(t.length)){var n=-1,r=function e(){for(;++n<t.length;)if(y.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=v,e.done=!0,e};return r.next=r}}return{next:h}}function h(){return{value:v,done:!0}}var v,g=Object.prototype,y=g.hasOwnProperty,b="function"===typeof Symbol?Symbol:{},w=b.iterator||"@@iterator",E=b.asyncIterator||"@@asyncIterator",x=b.toStringTag||"@@toStringTag",k="object"===typeof t,O=e.regeneratorRuntime;if(O)return void(k&&(t.exports=O));O=e.regeneratorRuntime=k?t.exports:{},O.wrap=n;var _="suspendedStart",I="suspendedYield",L="executing",N="completed",T={},S={};S[w]=function(){return this};var P=Object.getPrototypeOf,C=P&&P(P(f([])));C&&C!==g&&y.call(C,w)&&(S=C);var j=a.prototype=i.prototype=Object.create(S);o.prototype=j.constructor=a,a.constructor=o,a[x]=o.displayName="GeneratorFunction",O.isGeneratorFunction=function(t){var e="function"===typeof t&&t.constructor;return!!e&&(e===o||"GeneratorFunction"===(e.displayName||e.name))},O.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,a):(t.__proto__=a,x in t||(t[x]="GeneratorFunction")),t.prototype=Object.create(j),t},O.awrap=function(t){return{__await:t}},s(c.prototype),c.prototype[E]=function(){return this},O.AsyncIterator=c,O.async=function(t,e,r,i){var o=new c(n(t,e,r,i));return O.isGeneratorFunction(e)?o:o.next().then(function(t){return t.done?t.value:o.next()})},s(j),j[x]="Generator",j[w]=function(){return this},j.toString=function(){return"[object Generator]"},O.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},O.values=f,d.prototype={constructor:d,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=v,this.done=!1,this.delegate=null,this.method="next",this.arg=v,this.tryEntries.forEach(m),!t)for(var e in this)"t"===e.charAt(0)&&y.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=v)},stop:function(){this.done=!0;var t=this.tryEntries[0],e=t.completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){function e(e,r){return o.type="throw",o.arg=t,n.next=e,r&&(n.method="next",n.arg=v),!!r}if(this.done)throw t;for(var n=this,r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],o=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var a=y.call(i,"catchLoc"),s=y.call(i,"finallyLoc");if(a&&s){if(this.prev<i.catchLoc)return e(i.catchLoc,!0);if(this.prev<i.finallyLoc)return e(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return e(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return e(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&y.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,T):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),T},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),m(n),T}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;m(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:f(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=v),T}}}(function(){return this}()||Function("return this")())},function(t,e){},function(t,e){}]);
gutenberg/survey/src/.DS_Store CHANGED
Binary file
gutenberg/survey/src/block/block.js CHANGED
@@ -6,13 +6,12 @@ const { registerBlockType } = wp.blocks;
6
  const { SelectControl, TextControl } = wp.components;
7
  const { RichText } = wp.editor ;
8
 
9
- var dropdownOptions = false;
10
- var previewBlockOsTitle;
11
- var previewBlockOsImageUrl;
12
- var previewBlockOsView;
13
- var previewBlockOsEdit;
14
- var previewBlockOsStatistics;
15
- var options;
16
 
17
  registerBlockType( 'opinion-stage/block-os-survey', {
18
  title: __( 'Survey' ),
@@ -21,18 +20,13 @@ var options;
21
  keywords: [
22
  __( 'Opinion Stage Survey' ),
23
  __( 'Opinion Stage Survey' ),
24
- ],
25
  attributes: {
26
  embedUrl: {
27
  source: 'attribute',
28
  attribute: 'data-test-url',
29
  selector: 'div[data-test-url]'
30
- },
31
- oswpUrlShortcode: {
32
- source: 'attribute',
33
- attribute: 'data-test-url',
34
- selector: 'div[data-test-url]'
35
- },
36
  lockEmbed: {
37
  source: 'attribute',
38
  attribute: 'data-lock-embed',
@@ -42,173 +36,132 @@ var options;
42
  source: 'attribute',
43
  attribute: 'data-button-text',
44
  selector: 'div[data-button-text]'
45
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  },
47
  edit: function( props ) {
48
- let {attributes: {embedUrl, oswpUrlShortcode, lockEmbed, buttonText}, setAttributes} = props;
49
- const onDropdownChange = val => {
50
- if(val == ''){
51
- props.setAttributes({ embedUrl: '' });
52
- }else if(val != ''){
53
- props.setAttributes({ embedUrl: val });
54
- for (var i = 0; i < dropdownOptions.length; i++) {
55
- var getLandingPageUrlOs = function(href) {
56
- var locationUrlOS = document.createElement("a");
57
- locationUrlOS.href = href;
58
- return locationUrlOS;
59
- };
60
- var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
61
- var matchValue = locationUrlOS.pathname;
62
- if(val == matchValue){
63
- previewBlockOsTitle = dropdownOptions[i].attributes['title'];
64
- previewBlockOsImageUrl = dropdownOptions[i].attributes['image-url'];
65
- previewBlockOsView = dropdownOptions[i].attributes['landing-page-url'];
66
- previewBlockOsEdit = dropdownOptions[i].attributes['edit-url'];
67
- previewBlockOsStatistics = dropdownOptions[i].attributes['stats-url'];
68
- break;
69
- }
70
- }
71
- }else{
72
- }
73
- };
74
- const onEmbedButtonClick = event => {
75
- if( event.target.value == "Embed" ){
76
- if(embedUrl == '' || embedUrl == 'Select' || embedUrl == 'createNew' || embedUrl == 'refresh'){
77
- props.setAttributes({ lockEmbed: false, buttonText: "Embed" });
78
- }else{
79
- props.setAttributes({ lockEmbed: true, buttonText: "Change" });
80
- contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} onChange={onDropdownChange} className="components-select-control__input" />);
81
- }
82
- }else{
83
- props.setAttributes({ lockEmbed: false, buttonText: "Embed" });
84
- }
85
- };
86
-
87
- window.verifyOSInsert = function(widget){
88
- props.setAttributes({ oswpUrlShortcode: widget });
89
- var myOpts = document.getElementById('selectID').options;
90
- for(var i = 0; i < myOpts.length; i++){
91
- if(myOpts[i].value == widget){
92
- myOpts[i].defaultSelected = true;
93
- props.setAttributes({ lockEmbed: true, buttonText: "Change", embedUrl: widget });
94
- break;
95
- }
96
- }
97
- }
98
-
99
- var getOsCreateButtonClickUrl = osGutenData.onCreateButtonClickOs+'?w_type=survey&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8';
100
- const onCreateButtonClick = value => {
101
- // Open Create new survey link in new page
102
- window.open(getOsCreateButtonClickUrl, '_blank').focus();
103
- };
104
-
105
- if(!buttonText){
106
- props.setAttributes({ buttonText: 'Embed' });
107
- }
108
 
 
109
  var getCallBackUrlOs = osGutenData.callbackUrlOs;
110
  var callback_url = getCallBackUrlOs;
111
  var formActionUrlOS = osGutenData.getActionUrlOS;
112
  var getlogoImageLinkOs = osGutenData.getLogoImageLink;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  const onConnectOSWPButtonClick = value => {
114
- // Open Connect to opinionstage
115
  window.location.replace(callback_url);
116
  };
117
- // Populate list ajax function
118
- function OsPolulateList() {
119
- var opinionStageWidgetVersion = osGutenData.OswpPluginVersion;
120
- var opinionStageClientToken = osGutenData.OswpClientToken;
121
- var opinionstageFetchDataUrl = osGutenData.OswpFetchDataUrl+'?type=survey&page=1&per_page=99';
122
- fetch(opinionstageFetchDataUrl, {
123
- method: "GET",
124
- headers: {
125
- 'Accept':'application/vnd.api+json',
126
- 'Content-Type':'application/vnd.api+json',
127
- 'OSWP-Plugin-Version':opinionStageWidgetVersion,
128
- 'OSWP-Client-Token': opinionStageClientToken
129
- },
130
- })
131
- .then(async res => {
132
- var data = await res.json();
133
- data = data.data;
134
- dropdownOptions = data;
135
- // force reprinting instead!!
136
- props.setAttributes({ buttonText: 'Embed'});
137
- props.setAttributes({ buttonText: buttonText});
138
- if(buttonText == 'Change' && embedUrl !='Select'){
139
- props.setAttributes({ embedUrl: embedUrl });
140
- }else{
141
- props.setAttributes({ embedUrl: 'Select' });
142
- }
143
- })
144
- .catch(function(err) {
145
- console.log('ERROR: ' + err.message);
146
- });
147
- }
148
  // Checking for Opinion Stage connection
149
  if(osGutenData.isOsConnected == ''){
150
- $(document).ready(function () {
151
- $('span#oswpLauncherContentPopupsurvey , #owspLaunchInputCreate').live('click', function(e) {
152
- e.preventDefault();
153
- setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
154
- });
155
- });
156
  return (
157
  <div className={ props.className }>
158
  <div className="os-survey-wrapper components-placeholder">
159
  <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
160
  <p className="components-heading">Please connect WordPress to Opinion Stage to start adding surveys</p>
161
  <button className="components-button is-button is-default is-block is-primary" onClick={onConnectOSWPButtonClick}>Connect</button>
162
- </div>
 
163
  </div>
164
  );
165
- }else{
166
- if(dropdownOptions == false){
167
- options = [{value:'Select',label:'Select a survey'},{value:'refresh',label:'Refresh'}];
168
- OsPolulateList();
169
- }else{
170
- options = [{value:'Select',label:'Select a survey'},{value:'refresh',label:'Refresh'},{value:'',label:'-----------------'}];
171
- for (var i = 0; i < dropdownOptions.length; i++) {
172
- options[options.length] = {
173
- value: dropdownOptions[i].attributes['landing-page-url'].replace('https://www.opinionstage.com',''),
174
- label: dropdownOptions[i].attributes['title'],
175
- };
176
- var getLandingPageUrlOs = function(href) {
177
- var locationUrlOS = document.createElement("a");
178
- locationUrlOS.href = href;
179
- return locationUrlOS;
180
- };
181
- var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
182
- var matchValue = locationUrlOS.pathname;
183
- if(embedUrl == matchValue){
184
- previewBlockOsTitle = dropdownOptions[i].attributes['title'];
185
- previewBlockOsImageUrl = dropdownOptions[i].attributes['image-url'];
186
- previewBlockOsView = dropdownOptions[i].attributes['landing-page-url'];
187
- previewBlockOsEdit = dropdownOptions[i].attributes['edit-url'];
188
- previewBlockOsStatistics = dropdownOptions[i].attributes['stats-url'];
189
- var previewBlockOsWidgetID = dropdownOptions[i].id;
190
-
191
- }
192
- }
193
- }
194
- if(embedUrl == 'refresh'){
195
- OsPolulateList();
196
- }
197
- var contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} onChange={onDropdownChange} className="components-select-control__input" />);
198
  $(document).ready(function () {
 
199
  $('span#oswpLauncherContentPopupsurvey').live('click', function(e) {
200
  e.preventDefault();
201
  setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
202
  var text = $(this).attr('data-os-block');
203
  $("button#dropbtn span").text(text);
204
- var inputs = $(".filter__itm");
205
  for(var i = 0; i < inputs.length; i++){
206
- if($(inputs[i]).text() == text){
207
- setTimeout(function(){$(inputs[i]).trigger('click');},1000);
208
  setTimeout(function(){
209
- $('.progress_message').css('display', 'none');
210
- $('.content__list').css('display', 'block');
211
- },2500);
 
 
 
212
  $('button.content__links-itm').live('click', function(e) {
213
  $('.tingle-modal.opinionstage-content-popup').hide();
214
  $('.tingle-modal.opinionstage-content-popup.tingle-modal--visible').hide();
@@ -218,83 +171,89 @@ var options;
218
  else {
219
  $('.progress_message').css('display', 'block');
220
  $('.content__list').css('display', 'none');
221
- console.log('test');
222
  }
223
  }
224
  });
225
  });
226
 
227
- var contentViewEditStatOs = (
228
- <div className="os-survey-wrapper components-placeholder">
229
- <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
230
- <span id="oswpLauncherContentPopupsurvey" className="components-button is-button is-default is-block is-primary" data-opinionstage-content-launch data-os-block="survey">Select a Survey</span>
231
- <input type="button" value="Create a New Survey" className="components-button is-button is-default is-block is-primary" onClick={onCreateButtonClick} />
232
- <div className="components-placeholder__fieldset">
233
- {contentDropdown}
234
- <input type="button" value={buttonText} className="components-button is-button is-default is-large" id="clickMe" onClick={onEmbedButtonClick} />
235
- </div>
236
- </div>
237
- );
238
-
239
- var dataOpinionStageEmbedUrl = 'https://www.opinionstage.com/api/v1/widgets/'+embedUrl+'/code.json?comments=true&amp;sharing=true&amp;recommendations=false&amp;width=';
240
- var OpinionStageDataIframe = 'https://www.opinionstage.com/'+embedUrl+'?wid=0&amp;em=1&amp;comments=null&amp;referring_widget='+embedUrl+'&amp;autoswitch=1&amp;of=&amp;os_utm_source=null';
241
- (function(d, s, id){
242
- var js,
243
- fjs = d.getElementsByTagName(s)[0],
244
- r = Math.floor(new Date().getTime() / 1000000);
245
- if (d.getElementById(id)) {return;}
246
- js = d.createElement(s); js.id = id; js.async=1;
247
- js.src = "https://www.opinionstage.com/assets/loader.js?" + r;
248
- fjs.parentNode.insertBefore(js, fjs);
249
- }(document, 'script', 'os-widget-jssdk'));
250
- previewBlockOsWidgetID = 'os-widget-'+previewBlockOsWidgetID;
251
-
252
- if(embedUrl != '' && embedUrl != 'Select' && embedUrl){
 
 
 
 
 
 
 
253
  if(buttonText == 'Embed'){
254
  contentViewEditStatOs
255
- }else if(buttonText == 'Change'){
256
  contentViewEditStatOs = (
257
- <div className="os-survey-wrapper components-placeholder">
258
- <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
259
- <div className="components-preview__block" >
260
- <div className="components-preview__leftBlockImage">
261
- <img src={previewBlockOsImageUrl} alt={previewBlockOsTitle} className="image" />
262
- <div className="overlay">
263
- <div className="text">
264
- <a href={previewBlockOsView} target="_blank"> View </a>
265
- <a href={previewBlockOsEdit} target="_blank"> Edit </a>
266
- <a href={previewBlockOsStatistics} target="_blank"> Statistics </a>
267
- <input type="button" value={buttonText} className="components-button is-button is-default is-large left-align" onClick={onEmbedButtonClick} />
268
- </div>
 
 
 
 
269
  </div>
270
- </div>
271
- <div className="components-preview__rightBlockContent">
272
- <div className="components-placeholder__label">Survey: {previewBlockOsTitle}</div>
273
- </div>
274
- </div>
275
- </div>
276
- );
277
- contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} disabled onChange={onDropdownChange} className="components-select-control__input" />);
278
  }
279
- }else if(embedUrl == 'Select' || embedUrl == '' || embedUrl == 'refresh'){
280
  contentViewEditStatOs
281
  }else{
282
  props.setAttributes({ buttonText: 'Embed'});
283
  contentViewEditStatOs
284
  }
285
-
286
-
287
- return (
288
  <div className={ props.className }>
289
- {contentViewEditStatOs}
 
290
  </div>
291
  );
292
  }
293
  },
294
- save: function( {attributes: {embedUrl, oswpUrlShortcode, lockEmbed, buttonText}} ) {
295
  return (
296
- <div class="os-survey-wrapper" data-type="survey" data-test-url={oswpUrlShortcode} data-lock-embed={lockEmbed} data-button-text={buttonText}>
297
- [os-widget path="{oswpUrlShortcode}"]
 
298
  </div>
299
  );
300
  },
6
  const { SelectControl, TextControl } = wp.components;
7
  const { RichText } = wp.editor ;
8
 
9
+ var dropdownOptions = false;
10
+ var insertItemImage = false;
11
+ var insertItemOsTitle = false;
12
+ var insertItemOsView = false;
13
+ var insertItemOsEdit = false;
14
+ var insertItemOsStatistics = false;
 
15
 
16
  registerBlockType( 'opinion-stage/block-os-survey', {
17
  title: __( 'Survey' ),
20
  keywords: [
21
  __( 'Opinion Stage Survey' ),
22
  __( 'Opinion Stage Survey' ),
23
+ ],
24
  attributes: {
25
  embedUrl: {
26
  source: 'attribute',
27
  attribute: 'data-test-url',
28
  selector: 'div[data-test-url]'
29
+ },
 
 
 
 
 
30
  lockEmbed: {
31
  source: 'attribute',
32
  attribute: 'data-lock-embed',
36
  source: 'attribute',
37
  attribute: 'data-button-text',
38
  selector: 'div[data-button-text]'
39
+ },
40
+ insertItemImage: {
41
+ source: 'attribute',
42
+ attribute: 'data-image-url',
43
+ selector: 'div[data-image-url]'
44
+ },
45
+ insertItemOsTitle: {
46
+ source: 'attribute',
47
+ attribute: 'data-title-url',
48
+ selector: 'div[data-title-url]'
49
+ },
50
+ insertItemOsView: {
51
+ source: 'attribute',
52
+ attribute: 'data-view-url',
53
+ selector: 'div[data-view-url]'
54
+ },
55
+ insertItemOsEdit: {
56
+ source: 'attribute',
57
+ attribute: 'data-edit-url',
58
+ selector: 'div[data-edit-url]'
59
+ },
60
+ insertItemOsStatistics: {
61
+ source: 'attribute',
62
+ attribute: 'data-statistics-url',
63
+ selector: 'div[data-statistics-url]'
64
+ }
65
  },
66
  edit: function( props ) {
67
+ // Setting Attributes
68
+ let {attributes: {embedUrl, lockEmbed, buttonText, insertItemImage,insertItemOsTitle,insertItemOsView,insertItemOsEdit,insertItemOsStatistics}, setAttributes} = props;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ // Fetching Localized variables
71
  var getCallBackUrlOs = osGutenData.callbackUrlOs;
72
  var callback_url = getCallBackUrlOs;
73
  var formActionUrlOS = osGutenData.getActionUrlOS;
74
  var getlogoImageLinkOs = osGutenData.getLogoImageLink;
75
+
76
+ // Select Button Click functionality
77
+ const onSelectButtonClick = value => {
78
+ window.verifyOSInsert = function(widget){
79
+ props.setAttributes({ embedUrl: widget, buttonText:'Change' });
80
+
81
+ var opinionStageWidgetVersion = osGutenData.OswpPluginVersion;
82
+ var opinionStageClientToken = osGutenData.OswpClientToken;
83
+ var opinionstageFetchDataUrl = osGutenData.OswpFetchDataUrl+'?type=survey&page=1&per_page=99';
84
+ fetch(opinionstageFetchDataUrl, {
85
+ method: "GET",
86
+ headers: {
87
+ 'Accept':'application/vnd.api+json',
88
+ 'Content-Type':'application/vnd.api+json',
89
+ 'OSWP-Plugin-Version':opinionStageWidgetVersion,
90
+ 'OSWP-Client-Token': opinionStageClientToken
91
+ },
92
+ })
93
+ .then(async res => {
94
+ var data = await res.json();
95
+ data = data.data;
96
+ dropdownOptions = data;
97
+ // force reprinting instead!!
98
+ props.setAttributes({ buttonText: buttonText});
99
+
100
+ })
101
+ .catch(function(err) {
102
+ console.log('ERROR: ' + err.message);
103
+ });
104
+ }
105
+ }
106
+
107
+ // Change Button Click functionality
108
+ const onChangeButtonClick = value => {
109
+ props.setAttributes({
110
+ embedUrl: '',
111
+ buttonText:'Embed',
112
+ lockEmbed: false,
113
+ insertItemImage: false,
114
+ insertItemOsTitle: false,
115
+ insertItemOsView: false,
116
+ insertItemOsEdit: false,
117
+ insertItemOsStatistics: false
118
+ });
119
+ }
120
+
121
+ // Connect to Opinionstage Callback Url
122
  const onConnectOSWPButtonClick = value => {
 
123
  window.location.replace(callback_url);
124
  };
125
+
126
+ // Create New Item Url (survey)
127
+ var getOsCreateButtonClickUrl = osGutenData.onCreateButtonClickOs+'?w_type=survey&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8';
128
+ const onCreateButtonClick = value => {
129
+ // Open Create new survey link in new page
130
+ window.open(getOsCreateButtonClickUrl, '_blank').focus();
131
+ };
132
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  // Checking for Opinion Stage connection
134
  if(osGutenData.isOsConnected == ''){
135
+ // Not Connected to opinionstage
 
 
 
 
 
136
  return (
137
  <div className={ props.className }>
138
  <div className="os-survey-wrapper components-placeholder">
139
  <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
140
  <p className="components-heading">Please connect WordPress to Opinion Stage to start adding surveys</p>
141
  <button className="components-button is-button is-default is-block is-primary" onClick={onConnectOSWPButtonClick}>Connect</button>
142
+ </div>
143
+ <div></div>
144
  </div>
145
  );
146
+ }else{
147
+ // Connected to opinionstage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  $(document).ready(function () {
149
+ // Content Popup Launch Working
150
  $('span#oswpLauncherContentPopupsurvey').live('click', function(e) {
151
  e.preventDefault();
152
  setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
153
  var text = $(this).attr('data-os-block');
154
  $("button#dropbtn span").text(text);
155
+ var inputs = $(".filter__itm");
156
  for(var i = 0; i < inputs.length; i++){
157
+ if($(inputs[i]).text() == text){
 
158
  setTimeout(function(){
159
+ $(inputs[i]).trigger('click');
160
+ },1000);
161
+ setTimeout(function(){
162
+ $('.progress_message').css('display', 'none');
163
+ $('.content__list').css('display', 'block');
164
+ },2500);
165
  $('button.content__links-itm').live('click', function(e) {
166
  $('.tingle-modal.opinionstage-content-popup').hide();
167
  $('.tingle-modal.opinionstage-content-popup.tingle-modal--visible').hide();
171
  else {
172
  $('.progress_message').css('display', 'block');
173
  $('.content__list').css('display', 'none');
 
174
  }
175
  }
176
  });
177
  });
178
 
179
+ // Fetching Ajax Call Result
180
+ if(dropdownOptions != false){
181
+ for (var i = 0; i < dropdownOptions.length; i++) {
182
+ var getLandingPageUrlOs = function(href) {
183
+ var locationUrlOS = document.createElement("a");
184
+ locationUrlOS.href = href;
185
+ return locationUrlOS;
186
+ };
187
+ var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
188
+ var matchValue = locationUrlOS.pathname;
189
+ if(embedUrl == matchValue){
190
+ props.setAttributes({lockEmbed: true, buttonText: "Change" });
191
+ props.setAttributes({ insertItemImage : dropdownOptions[i].attributes['image-url'] });
192
+ props.setAttributes({ insertItemOsTitle : dropdownOptions[i].attributes['title'] });
193
+ props.setAttributes({ insertItemOsView : dropdownOptions[i].attributes['landing-page-url'] });
194
+ props.setAttributes({ insertItemOsEdit : dropdownOptions[i].attributes['edit-url'] });
195
+ props.setAttributes({ insertItemOsStatistics : dropdownOptions[i].attributes['stats-url'] });
196
+ break;
197
+ }
198
+ }
199
+ }
200
+
201
+ // Content On Editor
202
+ var contentViewEditStatOs = (
203
+ <div className="os-survey-wrapper components-placeholder">
204
+ <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
205
+ <span id="oswpLauncherContentPopupsurvey" className="components-button is-button is-default is-block is-primary" data-opinionstage-content-launch data-os-block="survey" onClick={onSelectButtonClick} >Select a Survey</span>
206
+ <input type="button" value="Create a New survey" className="components-button is-button is-default is-block is-primary" onClick={onCreateButtonClick} />
207
+ <span></span>
208
+ </div>
209
+ );
210
+
211
+ if(embedUrl != '' && embedUrl){
212
  if(buttonText == 'Embed'){
213
  contentViewEditStatOs
214
+ }else if(buttonText == 'Change'){
215
  contentViewEditStatOs = (
216
+ <div className="os-survey-wrapper components-placeholder">
217
+ <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
218
+ <div className="components-preview__block" >
219
+ <div className="components-preview__leftBlockImage">
220
+ <img src={insertItemImage} alt={insertItemOsTitle} className="image" />
221
+ <div className="overlay">
222
+ <div className="text">
223
+ <a href={insertItemOsView} target="_blank"> View </a>
224
+ <a href={insertItemOsEdit} target="_blank"> Edit </a>
225
+ <a href={insertItemOsStatistics} target="_blank"> Statistics </a>
226
+ <input type="button" value={buttonText} className="components-button is-button is-default is-large left-align" onClick={onChangeButtonClick}/>
227
+ </div>
228
+ </div>
229
+ </div>
230
+ <div className="components-preview__rightBlockContent">
231
+ <div className="components-placeholder__label">Survey: {insertItemOsTitle}</div>
232
  </div>
233
+ </div>
234
+ <span></span>
235
+ </div>
236
+ );
 
 
 
 
237
  }
238
+ }else if(embedUrl == '' || jQuery.type(embedUrl) === "undefined"){
239
  contentViewEditStatOs
240
  }else{
241
  props.setAttributes({ buttonText: 'Embed'});
242
  contentViewEditStatOs
243
  }
244
+ return (
 
 
245
  <div className={ props.className }>
246
+ {contentViewEditStatOs}
247
+ <span></span>
248
  </div>
249
  );
250
  }
251
  },
252
+ save: function( {attributes: {embedUrl, lockEmbed, buttonText, insertItemImage, insertItemOsTitle, insertItemOsView, insertItemOsEdit, insertItemOsStatistics }} ) {
253
  return (
254
+ <div class="os-survey-wrapper" data-type="survey" data-image-url={insertItemImage} data-title-url={insertItemOsTitle} data-view-url={insertItemOsView} data-statistics-url={insertItemOsStatistics} data-edit-url={insertItemOsEdit} data-test-url={embedUrl} data-lock-embed={lockEmbed} data-button-text={buttonText}>
255
+ [os-widget path="{embedUrl}"]
256
+ <span></span>
257
  </div>
258
  );
259
  },
gutenberg/trivia/dist/blocks.build.js CHANGED
@@ -1 +1 @@
1
- !function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});n(1)},function(e,t,n){"use strict";function r(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){function r(o,a){try{var i=t[o](a),s=i.value}catch(e){return void n(e)}if(!i.done)return Promise.resolve(s).then(function(e){r("next",e)},function(e){r("throw",e)});e(s)}return r("next")})}}var o,a,i,s,c,l,u=n(2),p=n.n(u),m=n(5),f=(n.n(m),n(6)),d=(n.n(f),wp.i18n.__),h=wp.blocks.registerBlockType,v=wp.components,g=v.SelectControl,b=(v.TextControl,wp.editor.RichText,!1);h("opinion-stage/block-os-trivia",{title:d("Trivia Quiz"),icon:"yes",category:"opinion-stage",keywords:[d("Opinion Stage Trivia Quiz"),d("Opinion Stage Trivia Quiz Insert")],attributes:{embedUrl:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},oswpUrlShortcode:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},lockEmbed:{source:"attribute",attribute:"data-lock-embed",selector:"div[data-lock-embed]"},buttonText:{source:"attribute",attribute:"data-button-text",selector:"div[data-button-text]"}},edit:function(e){function t(){var t=this,n=osGutenData.OswpPluginVersion,o=osGutenData.OswpClientToken,a=osGutenData.OswpFetchDataUrl+"?type=trivia&page=1&per_page=99";fetch(a,{method:"GET",headers:{Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json","OSWP-Plugin-Version":n,"OSWP-Client-Token":o}}).then(function(){var n=r(p.a.mark(function n(r){var o;return p.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.json();case 2:o=t.sent,o=o.data,b=o,e.setAttributes({buttonText:"Embed"}),e.setAttributes({buttonText:m}),"Change"==m&&"Select"!=u?e.setAttributes({embedUrl:u}):e.setAttributes({embedUrl:"Select"});case 8:case"end":return t.stop()}},n,t)}));return function(e){return n.apply(this,arguments)}}()).catch(function(e){console.log("ERROR: "+e.message)})}var n=e.attributes,u=n.embedUrl,m=(n.oswpUrlShortcode,n.lockEmbed,n.buttonText),f=(e.setAttributes,function(t){if(""==t)e.setAttributes({embedUrl:""});else if(""!=t){e.setAttributes({embedUrl:t});for(var n=0;n<b.length;n++){var r=function(e){var t=document.createElement("a");return t.href=e,t}(b[n].attributes["landing-page-url"]),l=r.pathname;if(t==l){o=b[n].attributes.title,a=b[n].attributes["image-url"],i=b[n].attributes["landing-page-url"],s=b[n].attributes["edit-url"],c=b[n].attributes["stats-url"];break}}}}),d=function(t){"Embed"==t.target.value?""==u||"Select"==u||"createNew"==u||"refresh"==u?e.setAttributes({lockEmbed:!1,buttonText:"Embed"}):(e.setAttributes({lockEmbed:!0,buttonText:"Change"}),L=wp.element.createElement(g,{id:"selectID",options:l,value:u,onChange:f,className:"components-select-control__input"})):e.setAttributes({lockEmbed:!1,buttonText:"Embed"})};window.verifyOSInsert=function(t){e.setAttributes({oswpUrlShortcode:t});for(var n=document.getElementById("selectID").options,r=0;r<n.length;r++)if(n[r].value==t){n[r].defaultSelected=!0,e.setAttributes({lockEmbed:!0,buttonText:"Change",embedUrl:t});break}};var h=osGutenData.onCreateButtonClickOs+"?w_type=quiz&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8",v=function(e){window.open(h,"_blank").focus()};m||e.setAttributes({buttonText:"Embed"});var w=osGutenData.callbackUrlOs,y=w,E=(osGutenData.getActionUrlOS,osGutenData.getLogoImageLink),k=function(e){window.location.replace(y)};if(""==osGutenData.isOsConnected)return $(document).ready(function(){$("span#oswpLauncherContentPopuptrivia , #owspLaunchInputCreate").live("click",function(e){e.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500)})}),wp.element.createElement("div",{className:e.className},wp.element.createElement("div",{className:"os-trivia-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"}," ",wp.element.createElement("img",{src:E,alt:""})," "),wp.element.createElement("p",{className:"components-heading"},"Please connect Wordpress to Opinion Stage to start adding trivia"),wp.element.createElement("button",{className:"components-button is-button is-default is-block is-primary",onClick:k},"Connect")));if(0==b)l=[{value:"Select",label:"Select a trivia"},{value:"refresh",label:"Refresh"}],t();else{l=[{value:"Select",label:"Select a trivia"},{value:"refresh",label:"Refresh"},{value:"",label:"-----------------"}];for(var x=0;x<b.length;x++){l[l.length]={value:b[x].attributes["landing-page-url"].replace("https://www.opinionstage.com",""),label:b[x].attributes.title};var _=function(e){var t=document.createElement("a");return t.href=e,t}(b[x].attributes["landing-page-url"]),N=_.pathname;if(u==N){o=b[x].attributes.title,a=b[x].attributes["image-url"],i=b[x].attributes["landing-page-url"],s=b[x].attributes["edit-url"],c=b[x].attributes["stats-url"];var T=b[x].id}}}"refresh"==u&&t();var L=wp.element.createElement(g,{id:"selectID",options:l,value:u,onChange:f,className:"components-select-control__input"});$(document).ready(function(){$("span#oswpLauncherContentPopuptrivia").live("click",function(e){e.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500);var t=$(this).attr("data-os-block");$("button#dropbtn span").text(t);for(var n=$(".filter__itm"),r=0;r<n.length;r++){if($(n[r]).text()==t){setTimeout(function(){$(n[r]).trigger("click")},1e3),setTimeout(function(){$(".progress_message").css("display","none"),$(".content__list").css("display","block")},2500),$("button.content__links-itm").live("click",function(e){$(".tingle-modal.opinionstage-content-popup").hide(),$(".tingle-modal.opinionstage-content-popup.tingle-modal--visible").hide()});break}$(".progress_message").css("display","block"),$(".content__list").css("display","none"),console.log("test")}})});var O=wp.element.createElement("div",{className:"os-trivia-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:E,alt:""})),wp.element.createElement("span",{id:"oswpLauncherContentPopuptrivia",className:"components-button is-button is-default is-block is-primary","data-opinionstage-content-launch":!0,"data-os-block":"trivia quiz"},"Select a Trivia Quiz"),wp.element.createElement("input",{type:"button",value:"Create a New Trivia Quiz",className:"components-button is-button is-default is-block is-primary",onClick:v}),wp.element.createElement("div",{className:"components-placeholder__fieldset"},L,wp.element.createElement("input",{type:"button",value:m,className:"components-button is-button is-default is-large",id:"clickMe",onClick:d})));return function(e,t,n){var r,o=e.getElementsByTagName(t)[0],a=Math.floor((new Date).getTime()/1e6);e.getElementById(n)||(r=e.createElement(t),r.id=n,r.async=1,r.src="https://www.opinionstage.com/assets/loader.js?"+a,o.parentNode.insertBefore(r,o))}(document,"script","os-widget-jssdk"),T="os-widget-"+T,""!=u&&"Select"!=u&&u?"Embed"==m||"Change"==m&&(O=wp.element.createElement("div",{className:"os-trivia-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:E,alt:""})),wp.element.createElement("div",{className:"components-preview__block"},wp.element.createElement("div",{className:"components-preview__leftBlockImage"},wp.element.createElement("img",{src:a,alt:o,className:"image"}),wp.element.createElement("div",{className:"overlay"},wp.element.createElement("div",{className:"text"},wp.element.createElement("a",{href:i,target:"_blank"}," View "),wp.element.createElement("a",{href:s,target:"_blank"}," Edit "),wp.element.createElement("a",{href:c,target:"_blank"}," Statistics "),wp.element.createElement("input",{type:"button",value:m,className:"components-button is-button is-default is-large left-align",onClick:d})))),wp.element.createElement("div",{className:"components-preview__rightBlockContent"},wp.element.createElement("div",{className:"components-placeholder__label"},"Trivia Quiz: ",o)))),L=wp.element.createElement(g,{id:"selectID",options:l,value:u,disabled:!0,onChange:f,className:"components-select-control__input"})):"Select"==u||""==u||"refresh"==u||e.setAttributes({buttonText:"Embed"}),wp.element.createElement("div",{className:e.className},O)},save:function(e){var t=e.attributes,n=(t.embedUrl,t.oswpUrlShortcode),r=t.lockEmbed,o=t.buttonText;return wp.element.createElement("div",{class:"os-trivia-wrapper","data-type":"trivia","data-test-url":n,"data-lock-embed":r,"data-button-text":o},'[os-widget path="',n,'"]')}})},function(e,t,n){e.exports=n(3)},function(e,t,n){var r=function(){return this}()||Function("return this")(),o=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,a=o&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,e.exports=n(4),o)r.regeneratorRuntime=a;else try{delete r.regeneratorRuntime}catch(e){r.regeneratorRuntime=void 0}},function(e,t){!function(t){"use strict";function n(e,t,n,r){var a=t&&t.prototype instanceof o?t:o,i=Object.create(a.prototype),s=new f(r||[]);return i._invoke=l(e,n,s),i}function r(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}function o(){}function a(){}function i(){}function s(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function c(e){function t(n,o,a,i){var s=r(e[n],e,o);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"===typeof l&&b.call(l,"__await")?Promise.resolve(l.__await).then(function(e){t("next",e,a,i)},function(e){t("throw",e,a,i)}):Promise.resolve(l).then(function(e){c.value=e,a(c)},i)}i(s.arg)}function n(e,n){function r(){return new Promise(function(r,o){t(e,n,r,o)})}return o=o?o.then(r,r):r()}var o;this._invoke=n}function l(e,t,n){var o=N;return function(a,i){if(o===L)throw new Error("Generator is already running");if(o===O){if("throw"===a)throw i;return h()}for(n.method=a,n.arg=i;;){var s=n.delegate;if(s){var c=u(s,n);if(c){if(c===S)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===N)throw o=O,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=L;var l=r(e,t,n);if("normal"===l.type){if(o=n.done?O:T,l.arg===S)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=O,n.method="throw",n.arg=l.arg)}}}function u(e,t){var n=e.iterator[t.method];if(n===v){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=v,u(e,t),"throw"===t.method))return S;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return S}var o=r(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,S;var a=o.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=v),t.delegate=null,S):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,S)}function p(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function m(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function f(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(p,this),this.reset(!0)}function d(e){if(e){var t=e[y];if(t)return t.call(e);if("function"===typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(b.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=v,t.done=!0,t};return r.next=r}}return{next:h}}function h(){return{value:v,done:!0}}var v,g=Object.prototype,b=g.hasOwnProperty,w="function"===typeof Symbol?Symbol:{},y=w.iterator||"@@iterator",E=w.asyncIterator||"@@asyncIterator",k=w.toStringTag||"@@toStringTag",x="object"===typeof e,_=t.regeneratorRuntime;if(_)return void(x&&(e.exports=_));_=t.regeneratorRuntime=x?e.exports:{},_.wrap=n;var N="suspendedStart",T="suspendedYield",L="executing",O="completed",S={},C={};C[y]=function(){return this};var P=Object.getPrototypeOf,j=P&&P(P(d([])));j&&j!==g&&b.call(j,y)&&(C=j);var A=i.prototype=o.prototype=Object.create(C);a.prototype=A.constructor=i,i.constructor=a,i[k]=a.displayName="GeneratorFunction",_.isGeneratorFunction=function(e){var t="function"===typeof e&&e.constructor;return!!t&&(t===a||"GeneratorFunction"===(t.displayName||t.name))},_.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,i):(e.__proto__=i,k in e||(e[k]="GeneratorFunction")),e.prototype=Object.create(A),e},_.awrap=function(e){return{__await:e}},s(c.prototype),c.prototype[E]=function(){return this},_.AsyncIterator=c,_.async=function(e,t,r,o){var a=new c(n(e,t,r,o));return _.isGeneratorFunction(t)?a:a.next().then(function(e){return e.done?e.value:a.next()})},s(A),A[k]="Generator",A[y]=function(){return this},A.toString=function(){return"[object Generator]"},_.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},_.values=d,f.prototype={constructor:f,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=v,this.done=!1,this.delegate=null,this.method="next",this.arg=v,this.tryEntries.forEach(m),!e)for(var t in this)"t"===t.charAt(0)&&b.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=v)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){function t(t,r){return a.type="throw",a.arg=e,n.next=t,r&&(n.method="next",n.arg=v),!!r}if(this.done)throw e;for(var n=this,r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var i=b.call(o,"catchLoc"),s=b.call(o,"finallyLoc");if(i&&s){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(i){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&b.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,S):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),S},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),m(n),S}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;m(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:d(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=v),S}}}(function(){return this}()||Function("return this")())},function(e,t){},function(e,t){}]);
1
+ !function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});n(1)},function(t,e,n){"use strict";function r(t){return function(){var e=t.apply(this,arguments);return new Promise(function(t,n){function r(i,a){try{var o=e[i](a),s=o.value}catch(t){return void n(t)}if(!o.done)return Promise.resolve(s).then(function(t){r("next",t)},function(t){r("throw",t)});t(s)}return r("next")})}}var i=n(2),a=n.n(i),o=n(5),s=(n.n(o),n(6)),c=(n.n(s),wp.i18n.__),l=wp.blocks.registerBlockType,u=wp.components,p=(u.SelectControl,u.TextControl,wp.editor.RichText,!1);l("opinion-stage/block-os-trivia",{title:c("Trivia Quiz"),icon:"yes",category:"opinion-stage",keywords:[c("Opinion Stage Trivia Quiz"),c("Opinion Stage Trivia Quiz Insert")],attributes:{embedUrl:{source:"attribute",attribute:"data-test-url",selector:"div[data-test-url]"},lockEmbed:{source:"attribute",attribute:"data-lock-embed",selector:"div[data-lock-embed]"},buttonText:{source:"attribute",attribute:"data-button-text",selector:"div[data-button-text]"},insertItemImage:{source:"attribute",attribute:"data-image-url",selector:"div[data-image-url]"},insertItemOsTitle:{source:"attribute",attribute:"data-title-url",selector:"div[data-title-url]"},insertItemOsView:{source:"attribute",attribute:"data-view-url",selector:"div[data-view-url]"},insertItemOsEdit:{source:"attribute",attribute:"data-edit-url",selector:"div[data-edit-url]"},insertItemOsStatistics:{source:"attribute",attribute:"data-statistics-url",selector:"div[data-statistics-url]"}},edit:function(t){var e=t.attributes,n=e.embedUrl,i=(e.lockEmbed,e.buttonText),o=e.insertItemImage,s=e.insertItemOsTitle,c=e.insertItemOsView,l=e.insertItemOsEdit,u=e.insertItemOsStatistics,m=(t.setAttributes,osGutenData.callbackUrlOs),d=m,f=(osGutenData.getActionUrlOS,osGutenData.getLogoImageLink),h=function(e){window.verifyOSInsert=function(e){var n=this;t.setAttributes({embedUrl:e,buttonText:"Change"});var o=osGutenData.OswpPluginVersion,s=osGutenData.OswpClientToken,c=osGutenData.OswpFetchDataUrl+"?type=trivia&page=1&per_page=99";fetch(c,{method:"GET",headers:{Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json","OSWP-Plugin-Version":o,"OSWP-Client-Token":s}}).then(function(){var e=r(a.a.mark(function e(r){var o;return a.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.json();case 2:o=e.sent,o=o.data,p=o,t.setAttributes({buttonText:i});case 6:case"end":return e.stop()}},e,n)}));return function(t){return e.apply(this,arguments)}}()).catch(function(t){console.log("ERROR: "+t.message)})}},v=function(e){t.setAttributes({embedUrl:"",buttonText:"Embed",lockEmbed:!1,insertItemImage:!1,insertItemOsTitle:!1,insertItemOsView:!1,insertItemOsEdit:!1,insertItemOsStatistics:!1})},g=function(t){window.location.replace(d)},b=osGutenData.onCreateButtonClickOs+"?w_type=quiz&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8",w=function(t){window.open(b,"_blank").focus()};if(""==osGutenData.isOsConnected)return wp.element.createElement("div",{className:t.className},wp.element.createElement("div",{className:"os-trivia-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:f,alt:""})),wp.element.createElement("p",{className:"components-heading"},"Please connect WordPress to Opinion Stage to start adding trivia"),wp.element.createElement("button",{className:"components-button is-button is-default is-block is-primary",onClick:g},"Connect")),wp.element.createElement("div",null));if($(document).ready(function(){$("span#oswpLauncherContentPopuptrivia").live("click",function(t){t.preventDefault(),setTimeout(function(){$(".editor-post-save-draft").trigger("click")},500);var e=$(this).attr("data-os-block");$("button#dropbtn span").text(e);for(var n=$(".filter__itm"),r=0;r<n.length;r++){if($(n[r]).text()==e){setTimeout(function(){$(n[r]).trigger("click")},1e3),setTimeout(function(){$(".progress_message").css("display","none"),$(".content__list").css("display","block")},2500),$("button.content__links-itm").live("click",function(t){$(".tingle-modal.opinionstage-content-popup").hide(),$(".tingle-modal.opinionstage-content-popup.tingle-modal--visible").hide()});break}$(".progress_message").css("display","block"),$(".content__list").css("display","none")}})}),0!=p)for(var y=0;y<p.length;y++){var E=function(t){var e=document.createElement("a");return e.href=t,e}(p[y].attributes["landing-page-url"]),x=E.pathname;if(n==x){t.setAttributes({lockEmbed:!0,buttonText:"Change"}),t.setAttributes({insertItemImage:p[y].attributes["image-url"]}),t.setAttributes({insertItemOsTitle:p[y].attributes.title}),t.setAttributes({insertItemOsView:p[y].attributes["landing-page-url"]}),t.setAttributes({insertItemOsEdit:p[y].attributes["edit-url"]}),t.setAttributes({insertItemOsStatistics:p[y].attributes["stats-url"]});break}}var k=wp.element.createElement("div",{className:"os-trivia-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:f,alt:""})),wp.element.createElement("span",{id:"oswpLauncherContentPopuptrivia",className:"components-button is-button is-default is-block is-primary","data-opinionstage-content-launch":!0,"data-os-block":"trivia quiz",onClick:h},"Select a Trivia Quiz"),wp.element.createElement("input",{type:"button",value:"Create a New Trivia Quiz",className:"components-button is-button is-default is-block is-primary",onClick:w}),wp.element.createElement("span",null));return""!=n&&n?"Embed"==i||"Change"==i&&(k=wp.element.createElement("div",{className:"os-trivia-wrapper components-placeholder"},wp.element.createElement("p",{className:"components-heading"},wp.element.createElement("img",{src:f,alt:""})),wp.element.createElement("div",{className:"components-preview__block"},wp.element.createElement("div",{className:"components-preview__leftBlockImage"},wp.element.createElement("img",{src:o,alt:s,className:"image"}),wp.element.createElement("div",{className:"overlay"},wp.element.createElement("div",{className:"text"},wp.element.createElement("a",{href:c,target:"_blank"}," View "),wp.element.createElement("a",{href:l,target:"_blank"}," Edit "),wp.element.createElement("a",{href:u,target:"_blank"}," Statistics "),wp.element.createElement("input",{type:"button",value:i,className:"components-button is-button is-default is-large left-align",onClick:v})))),wp.element.createElement("div",{className:"components-preview__rightBlockContent"},wp.element.createElement("div",{className:"components-placeholder__label"},"Trivia Quiz: ",s))),wp.element.createElement("span",null))):""==n||"undefined"===jQuery.type(n)||t.setAttributes({buttonText:"Embed"}),wp.element.createElement("div",{className:t.className},k,wp.element.createElement("span",null))},save:function(t){var e=t.attributes,n=e.embedUrl,r=e.lockEmbed,i=e.buttonText,a=e.insertItemImage,o=e.insertItemOsTitle,s=e.insertItemOsView,c=e.insertItemOsEdit,l=e.insertItemOsStatistics;return wp.element.createElement("div",{class:"os-trivia-wrapper","data-type":"trivia","data-image-url":a,"data-title-url":o,"data-view-url":s,"data-statistics-url":l,"data-edit-url":c,"data-test-url":n,"data-lock-embed":r,"data-button-text":i},'[os-widget path="',n,'"]',wp.element.createElement("span",null))}})},function(t,e,n){t.exports=n(3)},function(t,e,n){var r=function(){return this}()||Function("return this")(),i=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,a=i&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,t.exports=n(4),i)r.regeneratorRuntime=a;else try{delete r.regeneratorRuntime}catch(t){r.regeneratorRuntime=void 0}},function(t,e){!function(e){"use strict";function n(t,e,n,r){var a=e&&e.prototype instanceof i?e:i,o=Object.create(a.prototype),s=new d(r||[]);return o._invoke=l(t,n,s),o}function r(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function i(){}function a(){}function o(){}function s(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function c(t){function e(n,i,a,o){var s=r(t[n],t,i);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"===typeof l&&b.call(l,"__await")?Promise.resolve(l.__await).then(function(t){e("next",t,a,o)},function(t){e("throw",t,a,o)}):Promise.resolve(l).then(function(t){c.value=t,a(c)},o)}o(s.arg)}function n(t,n){function r(){return new Promise(function(r,i){e(t,n,r,i)})}return i=i?i.then(r,r):r()}var i;this._invoke=n}function l(t,e,n){var i=_;return function(a,o){if(i===T)throw new Error("Generator is already running");if(i===L){if("throw"===a)throw o;return h()}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=u(s,n);if(c){if(c===N)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===_)throw i=L,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=T;var l=r(t,e,n);if("normal"===l.type){if(i=n.done?L:I,l.arg===N)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(i=L,n.method="throw",n.arg=l.arg)}}}function u(t,e){var n=t.iterator[e.method];if(n===v){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=v,u(t,e),"throw"===e.method))return N;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return N}var i=r(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,N;var a=i.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=v),e.delegate=null,N):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,N)}function p(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function m(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function d(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(p,this),this.reset(!0)}function f(t){if(t){var e=t[y];if(e)return e.call(t);if("function"===typeof t.next)return t;if(!isNaN(t.length)){var n=-1,r=function e(){for(;++n<t.length;)if(b.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=v,e.done=!0,e};return r.next=r}}return{next:h}}function h(){return{value:v,done:!0}}var v,g=Object.prototype,b=g.hasOwnProperty,w="function"===typeof Symbol?Symbol:{},y=w.iterator||"@@iterator",E=w.asyncIterator||"@@asyncIterator",x=w.toStringTag||"@@toStringTag",k="object"===typeof t,O=e.regeneratorRuntime;if(O)return void(k&&(t.exports=O));O=e.regeneratorRuntime=k?t.exports:{},O.wrap=n;var _="suspendedStart",I="suspendedYield",T="executing",L="completed",N={},P={};P[y]=function(){return this};var S=Object.getPrototypeOf,C=S&&S(S(f([])));C&&C!==g&&b.call(C,y)&&(P=C);var j=o.prototype=i.prototype=Object.create(P);a.prototype=j.constructor=o,o.constructor=a,o[x]=a.displayName="GeneratorFunction",O.isGeneratorFunction=function(t){var e="function"===typeof t&&t.constructor;return!!e&&(e===a||"GeneratorFunction"===(e.displayName||e.name))},O.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,o):(t.__proto__=o,x in t||(t[x]="GeneratorFunction")),t.prototype=Object.create(j),t},O.awrap=function(t){return{__await:t}},s(c.prototype),c.prototype[E]=function(){return this},O.AsyncIterator=c,O.async=function(t,e,r,i){var a=new c(n(t,e,r,i));return O.isGeneratorFunction(e)?a:a.next().then(function(t){return t.done?t.value:a.next()})},s(j),j[x]="Generator",j[y]=function(){return this},j.toString=function(){return"[object Generator]"},O.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},O.values=f,d.prototype={constructor:d,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=v,this.done=!1,this.delegate=null,this.method="next",this.arg=v,this.tryEntries.forEach(m),!t)for(var e in this)"t"===e.charAt(0)&&b.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=v)},stop:function(){this.done=!0;var t=this.tryEntries[0],e=t.completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){function e(e,r){return a.type="throw",a.arg=t,n.next=e,r&&(n.method="next",n.arg=v),!!r}if(this.done)throw t;for(var n=this,r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],a=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var o=b.call(i,"catchLoc"),s=b.call(i,"finallyLoc");if(o&&s){if(this.prev<i.catchLoc)return e(i.catchLoc,!0);if(this.prev<i.finallyLoc)return e(i.finallyLoc)}else if(o){if(this.prev<i.catchLoc)return e(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return e(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&b.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,N):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),N},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),m(n),N}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;m(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:f(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=v),N}}}(function(){return this}()||Function("return this")())},function(t,e){},function(t,e){}]);
gutenberg/trivia/src/.DS_Store CHANGED
Binary file
gutenberg/trivia/src/block/block.js CHANGED
@@ -6,13 +6,12 @@ const { registerBlockType } = wp.blocks;
6
  const { SelectControl, TextControl } = wp.components;
7
  const { RichText } = wp.editor ;
8
 
9
- var dropdownOptions = false;
10
- var previewBlockOsTitle;
11
- var previewBlockOsImageUrl;
12
- var previewBlockOsView;
13
- var previewBlockOsEdit;
14
- var previewBlockOsStatistics;
15
- var options;
16
 
17
  registerBlockType( 'opinion-stage/block-os-trivia', {
18
  title: __( 'Trivia Quiz' ),
@@ -21,18 +20,13 @@ var options;
21
  keywords: [
22
  __( 'Opinion Stage Trivia Quiz' ),
23
  __( 'Opinion Stage Trivia Quiz Insert' ),
24
- ],
25
  attributes: {
26
  embedUrl: {
27
  source: 'attribute',
28
  attribute: 'data-test-url',
29
  selector: 'div[data-test-url]'
30
- },
31
- oswpUrlShortcode: {
32
- source: 'attribute',
33
- attribute: 'data-test-url',
34
- selector: 'div[data-test-url]'
35
- },
36
  lockEmbed: {
37
  source: 'attribute',
38
  attribute: 'data-lock-embed',
@@ -42,173 +36,132 @@ var options;
42
  source: 'attribute',
43
  attribute: 'data-button-text',
44
  selector: 'div[data-button-text]'
45
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  },
47
  edit: function( props ) {
48
- let {attributes: {embedUrl, oswpUrlShortcode, lockEmbed, buttonText}, setAttributes} = props;
49
- const onDropdownChange = val => {
50
- if(val == ''){
51
- props.setAttributes({ embedUrl: '' });
52
- }else if(val != ''){
53
- props.setAttributes({ embedUrl: val });
54
- for (var i = 0; i < dropdownOptions.length; i++) {
55
- var getLandingPageUrlOs = function(href) {
56
- var locationUrlOS = document.createElement("a");
57
- locationUrlOS.href = href;
58
- return locationUrlOS;
59
- };
60
- var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
61
- var matchValue = locationUrlOS.pathname;
62
- if(val == matchValue){
63
- previewBlockOsTitle = dropdownOptions[i].attributes['title'];
64
- previewBlockOsImageUrl = dropdownOptions[i].attributes['image-url'];
65
- previewBlockOsView = dropdownOptions[i].attributes['landing-page-url'];
66
- previewBlockOsEdit = dropdownOptions[i].attributes['edit-url'];
67
- previewBlockOsStatistics = dropdownOptions[i].attributes['stats-url'];
68
- break;
69
- }
70
- }
71
- }else{
72
- }
73
- };
74
- const onEmbedButtonClick = event => {
75
- if( event.target.value == "Embed" ){
76
- if(embedUrl == '' || embedUrl == 'Select' || embedUrl == 'createNew' || embedUrl == 'refresh'){
77
- props.setAttributes({ lockEmbed: false, buttonText: "Embed" });
78
- }else{
79
- props.setAttributes({ lockEmbed: true, buttonText: "Change" });
80
- contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} onChange={onDropdownChange} className="components-select-control__input" />);
81
- }
82
- }else{
83
- props.setAttributes({ lockEmbed: false, buttonText: "Embed" });
84
- }
85
- };
86
-
87
- window.verifyOSInsert = function(widget){
88
- props.setAttributes({ oswpUrlShortcode: widget });
89
- var myOpts = document.getElementById('selectID').options;
90
- for(var i = 0; i < myOpts.length; i++){
91
- if(myOpts[i].value == widget){
92
- myOpts[i].defaultSelected = true;
93
- props.setAttributes({ lockEmbed: true, buttonText: "Change", embedUrl: widget });
94
- break;
95
- }
96
- }
97
- }
98
-
99
- var getOsCreateButtonClickUrl = osGutenData.onCreateButtonClickOs+'?w_type=quiz&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8';
100
- const onCreateButtonClick = value => {
101
- // Open Create new trivia link in new page
102
- window.open(getOsCreateButtonClickUrl, '_blank').focus();
103
- };
104
-
105
- if(!buttonText){
106
- props.setAttributes({ buttonText: 'Embed' });
107
- }
108
 
 
109
  var getCallBackUrlOs = osGutenData.callbackUrlOs;
110
  var callback_url = getCallBackUrlOs;
111
  var formActionUrlOS = osGutenData.getActionUrlOS;
112
  var getlogoImageLinkOs = osGutenData.getLogoImageLink;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  const onConnectOSWPButtonClick = value => {
114
- // Open Connect to opinionstage
115
  window.location.replace(callback_url);
116
  };
117
- // Populate list ajax function
118
- function OsPolulateList() {
119
- var opinionStageWidgetVersion = osGutenData.OswpPluginVersion;
120
- var opinionStageClientToken = osGutenData.OswpClientToken;
121
- var opinionstageFetchDataUrl = osGutenData.OswpFetchDataUrl+'?type=trivia&page=1&per_page=99';
122
- fetch(opinionstageFetchDataUrl, {
123
- method: "GET",
124
- headers: {
125
- 'Accept':'application/vnd.api+json',
126
- 'Content-Type':'application/vnd.api+json',
127
- 'OSWP-Plugin-Version':opinionStageWidgetVersion,
128
- 'OSWP-Client-Token': opinionStageClientToken
129
- },
130
- })
131
- .then(async res => {
132
- var data = await res.json();
133
- data = data.data;
134
- dropdownOptions = data;
135
- // force reprinting instead!!
136
- props.setAttributes({ buttonText: 'Embed'});
137
- props.setAttributes({ buttonText: buttonText});
138
- if(buttonText == 'Change' && embedUrl !='Select'){
139
- props.setAttributes({ embedUrl: embedUrl });
140
- }else{
141
- props.setAttributes({ embedUrl: 'Select' });
142
- }
143
- })
144
- .catch(function(err) {
145
- console.log('ERROR: ' + err.message);
146
- });
147
- }
148
  // Checking for Opinion Stage connection
149
  if(osGutenData.isOsConnected == ''){
150
- $(document).ready(function () {
151
- $('span#oswpLauncherContentPopuptrivia , #owspLaunchInputCreate').live('click', function(e) {
152
- e.preventDefault();
153
- setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
154
- });
155
- });
156
  return (
157
  <div className={ props.className }>
158
  <div className="os-trivia-wrapper components-placeholder">
159
- <p className="components-heading"> <img src={getlogoImageLinkOs} alt=""/> </p>
160
- <p className="components-heading">Please connect Wordpress to Opinion Stage to start adding trivia</p>
161
  <button className="components-button is-button is-default is-block is-primary" onClick={onConnectOSWPButtonClick}>Connect</button>
162
- </div>
 
163
  </div>
164
  );
165
- }else{
166
- if(dropdownOptions == false){
167
- options = [{value:'Select',label:'Select a trivia'},{value:'refresh',label:'Refresh'}];
168
- OsPolulateList();
169
- }else{
170
- options = [{value:'Select',label:'Select a trivia'},{value:'refresh',label:'Refresh'},{value:'',label:'-----------------'}];
171
- for (var i = 0; i < dropdownOptions.length; i++) {
172
- options[options.length] = {
173
- value: dropdownOptions[i].attributes['landing-page-url'].replace('https://www.opinionstage.com',''),
174
- label: dropdownOptions[i].attributes['title'],
175
- };
176
- var getLandingPageUrlOs = function(href) {
177
- var locationUrlOS = document.createElement("a");
178
- locationUrlOS.href = href;
179
- return locationUrlOS;
180
- };
181
- var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
182
- var matchValue = locationUrlOS.pathname;
183
- if(embedUrl == matchValue){
184
- previewBlockOsTitle = dropdownOptions[i].attributes['title'];
185
- previewBlockOsImageUrl = dropdownOptions[i].attributes['image-url'];
186
- previewBlockOsView = dropdownOptions[i].attributes['landing-page-url'];
187
- previewBlockOsEdit = dropdownOptions[i].attributes['edit-url'];
188
- previewBlockOsStatistics = dropdownOptions[i].attributes['stats-url'];
189
- var previewBlockOsWidgetID = dropdownOptions[i].id;
190
-
191
- }
192
- }
193
- }
194
- if(embedUrl == 'refresh'){
195
- OsPolulateList();
196
- }
197
- var contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} onChange={onDropdownChange} className="components-select-control__input" />);
198
  $(document).ready(function () {
 
199
  $('span#oswpLauncherContentPopuptrivia').live('click', function(e) {
200
  e.preventDefault();
201
  setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
202
  var text = $(this).attr('data-os-block');
203
  $("button#dropbtn span").text(text);
204
- var inputs = $(".filter__itm");
205
  for(var i = 0; i < inputs.length; i++){
206
- if($(inputs[i]).text() == text){
207
- setTimeout(function(){$(inputs[i]).trigger('click');},1000);
208
  setTimeout(function(){
209
- $('.progress_message').css('display', 'none');
210
- $('.content__list').css('display', 'block');
211
- },2500);
 
 
 
212
  $('button.content__links-itm').live('click', function(e) {
213
  $('.tingle-modal.opinionstage-content-popup').hide();
214
  $('.tingle-modal.opinionstage-content-popup.tingle-modal--visible').hide();
@@ -218,83 +171,89 @@ var options;
218
  else {
219
  $('.progress_message').css('display', 'block');
220
  $('.content__list').css('display', 'none');
221
- console.log('test');
222
  }
223
  }
224
  });
225
  });
226
 
227
- var contentViewEditStatOs = (
228
- <div className="os-trivia-wrapper components-placeholder">
229
- <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
230
- <span id="oswpLauncherContentPopuptrivia" className="components-button is-button is-default is-block is-primary" data-opinionstage-content-launch data-os-block="trivia quiz">Select a Trivia Quiz</span>
231
- <input type="button" value="Create a New Trivia Quiz" className="components-button is-button is-default is-block is-primary" onClick={onCreateButtonClick} />
232
- <div className="components-placeholder__fieldset">
233
- {contentDropdown}
234
- <input type="button" value={buttonText} className="components-button is-button is-default is-large" id="clickMe" onClick={onEmbedButtonClick} />
235
- </div>
236
- </div>
237
- );
238
-
239
- var dataOpinionStageEmbedUrl = 'https://www.opinionstage.com/api/v1/widgets/'+embedUrl+'/code.json?comments=true&amp;sharing=true&amp;recommendations=false&amp;width=';
240
- var OpinionStageDataIframe = 'https://www.opinionstage.com/'+embedUrl+'?wid=0&amp;em=1&amp;comments=null&amp;referring_widget='+embedUrl+'&amp;autoswitch=1&amp;of=&amp;os_utm_source=null';
241
- (function(d, s, id){
242
- var js,
243
- fjs = d.getElementsByTagName(s)[0],
244
- r = Math.floor(new Date().getTime() / 1000000);
245
- if (d.getElementById(id)) {return;}
246
- js = d.createElement(s); js.id = id; js.async=1;
247
- js.src = "https://www.opinionstage.com/assets/loader.js?" + r;
248
- fjs.parentNode.insertBefore(js, fjs);
249
- }(document, 'script', 'os-widget-jssdk'));
250
- previewBlockOsWidgetID = 'os-widget-'+previewBlockOsWidgetID;
251
-
252
- if(embedUrl != '' && embedUrl != 'Select' && embedUrl){
 
 
 
 
 
 
 
253
  if(buttonText == 'Embed'){
254
  contentViewEditStatOs
255
- }else if(buttonText == 'Change'){
256
  contentViewEditStatOs = (
257
- <div className="os-trivia-wrapper components-placeholder">
258
- <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
259
- <div className="components-preview__block" >
260
- <div className="components-preview__leftBlockImage">
261
- <img src={previewBlockOsImageUrl} alt={previewBlockOsTitle} className="image" />
262
- <div className="overlay">
263
- <div className="text">
264
- <a href={previewBlockOsView} target="_blank"> View </a>
265
- <a href={previewBlockOsEdit} target="_blank"> Edit </a>
266
- <a href={previewBlockOsStatistics} target="_blank"> Statistics </a>
267
- <input type="button" value={buttonText} className="components-button is-button is-default is-large left-align" onClick={onEmbedButtonClick} />
268
- </div>
 
 
 
 
269
  </div>
270
- </div>
271
- <div className="components-preview__rightBlockContent">
272
- <div className="components-placeholder__label">Trivia Quiz: {previewBlockOsTitle}</div>
273
- </div>
274
- </div>
275
- </div>
276
- );
277
- contentDropdown = (<SelectControl id="selectID" options={options} value={embedUrl} disabled onChange={onDropdownChange} className="components-select-control__input" />);
278
  }
279
- }else if(embedUrl == 'Select' || embedUrl == '' || embedUrl == 'refresh'){
280
  contentViewEditStatOs
281
  }else{
282
  props.setAttributes({ buttonText: 'Embed'});
283
  contentViewEditStatOs
284
  }
285
-
286
-
287
- return (
288
  <div className={ props.className }>
289
- {contentViewEditStatOs}
 
290
  </div>
291
  );
292
  }
293
  },
294
- save: function( {attributes: {embedUrl, oswpUrlShortcode, lockEmbed, buttonText}} ) {
295
  return (
296
- <div class="os-trivia-wrapper" data-type="trivia" data-test-url={oswpUrlShortcode} data-lock-embed={lockEmbed} data-button-text={buttonText}>
297
- [os-widget path="{oswpUrlShortcode}"]
 
298
  </div>
299
  );
300
  },
6
  const { SelectControl, TextControl } = wp.components;
7
  const { RichText } = wp.editor ;
8
 
9
+ var dropdownOptions = false;
10
+ var insertItemImage = false;
11
+ var insertItemOsTitle = false;
12
+ var insertItemOsView = false;
13
+ var insertItemOsEdit = false;
14
+ var insertItemOsStatistics = false;
 
15
 
16
  registerBlockType( 'opinion-stage/block-os-trivia', {
17
  title: __( 'Trivia Quiz' ),
20
  keywords: [
21
  __( 'Opinion Stage Trivia Quiz' ),
22
  __( 'Opinion Stage Trivia Quiz Insert' ),
23
+ ],
24
  attributes: {
25
  embedUrl: {
26
  source: 'attribute',
27
  attribute: 'data-test-url',
28
  selector: 'div[data-test-url]'
29
+ },
 
 
 
 
 
30
  lockEmbed: {
31
  source: 'attribute',
32
  attribute: 'data-lock-embed',
36
  source: 'attribute',
37
  attribute: 'data-button-text',
38
  selector: 'div[data-button-text]'
39
+ },
40
+ insertItemImage: {
41
+ source: 'attribute',
42
+ attribute: 'data-image-url',
43
+ selector: 'div[data-image-url]'
44
+ },
45
+ insertItemOsTitle: {
46
+ source: 'attribute',
47
+ attribute: 'data-title-url',
48
+ selector: 'div[data-title-url]'
49
+ },
50
+ insertItemOsView: {
51
+ source: 'attribute',
52
+ attribute: 'data-view-url',
53
+ selector: 'div[data-view-url]'
54
+ },
55
+ insertItemOsEdit: {
56
+ source: 'attribute',
57
+ attribute: 'data-edit-url',
58
+ selector: 'div[data-edit-url]'
59
+ },
60
+ insertItemOsStatistics: {
61
+ source: 'attribute',
62
+ attribute: 'data-statistics-url',
63
+ selector: 'div[data-statistics-url]'
64
+ }
65
  },
66
  edit: function( props ) {
67
+ // Setting Attributes
68
+ let {attributes: {embedUrl, lockEmbed, buttonText, insertItemImage,insertItemOsTitle,insertItemOsView,insertItemOsEdit,insertItemOsStatistics}, setAttributes} = props;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ // Fetching Localized variables
71
  var getCallBackUrlOs = osGutenData.callbackUrlOs;
72
  var callback_url = getCallBackUrlOs;
73
  var formActionUrlOS = osGutenData.getActionUrlOS;
74
  var getlogoImageLinkOs = osGutenData.getLogoImageLink;
75
+
76
+ // Select Button Click functionality
77
+ const onSelectButtonClick = value => {
78
+ window.verifyOSInsert = function(widget){
79
+ props.setAttributes({ embedUrl: widget, buttonText:'Change' });
80
+
81
+ var opinionStageWidgetVersion = osGutenData.OswpPluginVersion;
82
+ var opinionStageClientToken = osGutenData.OswpClientToken;
83
+ var opinionstageFetchDataUrl = osGutenData.OswpFetchDataUrl+'?type=trivia&page=1&per_page=99';
84
+ fetch(opinionstageFetchDataUrl, {
85
+ method: "GET",
86
+ headers: {
87
+ 'Accept':'application/vnd.api+json',
88
+ 'Content-Type':'application/vnd.api+json',
89
+ 'OSWP-Plugin-Version':opinionStageWidgetVersion,
90
+ 'OSWP-Client-Token': opinionStageClientToken
91
+ },
92
+ })
93
+ .then(async res => {
94
+ var data = await res.json();
95
+ data = data.data;
96
+ dropdownOptions = data;
97
+ // force reprinting instead!!
98
+ props.setAttributes({ buttonText: buttonText});
99
+
100
+ })
101
+ .catch(function(err) {
102
+ console.log('ERROR: ' + err.message);
103
+ });
104
+ }
105
+ }
106
+
107
+ // Change Button Click functionality
108
+ const onChangeButtonClick = value => {
109
+ props.setAttributes({
110
+ embedUrl: '',
111
+ buttonText:'Embed',
112
+ lockEmbed: false,
113
+ insertItemImage: false,
114
+ insertItemOsTitle: false,
115
+ insertItemOsView: false,
116
+ insertItemOsEdit: false,
117
+ insertItemOsStatistics: false
118
+ });
119
+ }
120
+
121
+ // Connect to Opinionstage Callback Url
122
  const onConnectOSWPButtonClick = value => {
 
123
  window.location.replace(callback_url);
124
  };
125
+
126
+ // Create New Item Url (trivia)
127
+ var getOsCreateButtonClickUrl = osGutenData.onCreateButtonClickOs+'?w_type=quiz&amp;utm_source=wordpress&amp;utm_campaign=WPMainPI&amp;utm_medium=link&amp;o=wp35e8';
128
+ const onCreateButtonClick = value => {
129
+ // Open Create new trivia link in new page
130
+ window.open(getOsCreateButtonClickUrl, '_blank').focus();
131
+ };
132
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  // Checking for Opinion Stage connection
134
  if(osGutenData.isOsConnected == ''){
135
+ // Not Connected to opinionstage
 
 
 
 
 
136
  return (
137
  <div className={ props.className }>
138
  <div className="os-trivia-wrapper components-placeholder">
139
+ <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
140
+ <p className="components-heading">Please connect WordPress to Opinion Stage to start adding trivia</p>
141
  <button className="components-button is-button is-default is-block is-primary" onClick={onConnectOSWPButtonClick}>Connect</button>
142
+ </div>
143
+ <div></div>
144
  </div>
145
  );
146
+ }else{
147
+ // Connected to opinionstage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  $(document).ready(function () {
149
+ // Content Popup Launch Working
150
  $('span#oswpLauncherContentPopuptrivia').live('click', function(e) {
151
  e.preventDefault();
152
  setTimeout(function(){$('.editor-post-save-draft').trigger('click');},500);
153
  var text = $(this).attr('data-os-block');
154
  $("button#dropbtn span").text(text);
155
+ var inputs = $(".filter__itm");
156
  for(var i = 0; i < inputs.length; i++){
157
+ if($(inputs[i]).text() == text){
 
158
  setTimeout(function(){
159
+ $(inputs[i]).trigger('click');
160
+ },1000);
161
+ setTimeout(function(){
162
+ $('.progress_message').css('display', 'none');
163
+ $('.content__list').css('display', 'block');
164
+ },2500);
165
  $('button.content__links-itm').live('click', function(e) {
166
  $('.tingle-modal.opinionstage-content-popup').hide();
167
  $('.tingle-modal.opinionstage-content-popup.tingle-modal--visible').hide();
171
  else {
172
  $('.progress_message').css('display', 'block');
173
  $('.content__list').css('display', 'none');
 
174
  }
175
  }
176
  });
177
  });
178
 
179
+ // Fetching Ajax Call Result
180
+ if(dropdownOptions != false){
181
+ for (var i = 0; i < dropdownOptions.length; i++) {
182
+ var getLandingPageUrlOs = function(href) {
183
+ var locationUrlOS = document.createElement("a");
184
+ locationUrlOS.href = href;
185
+ return locationUrlOS;
186
+ };
187
+ var locationUrlOS = getLandingPageUrlOs(dropdownOptions[i].attributes['landing-page-url']);
188
+ var matchValue = locationUrlOS.pathname;
189
+ if(embedUrl == matchValue){
190
+ props.setAttributes({lockEmbed: true, buttonText: "Change" });
191
+ props.setAttributes({ insertItemImage : dropdownOptions[i].attributes['image-url'] });
192
+ props.setAttributes({ insertItemOsTitle : dropdownOptions[i].attributes['title'] });
193
+ props.setAttributes({ insertItemOsView : dropdownOptions[i].attributes['landing-page-url'] });
194
+ props.setAttributes({ insertItemOsEdit : dropdownOptions[i].attributes['edit-url'] });
195
+ props.setAttributes({ insertItemOsStatistics : dropdownOptions[i].attributes['stats-url'] });
196
+ break;
197
+ }
198
+ }
199
+ }
200
+
201
+ // Content On Editor
202
+ var contentViewEditStatOs = (
203
+ <div className="os-trivia-wrapper components-placeholder">
204
+ <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
205
+ <span id="oswpLauncherContentPopuptrivia" className="components-button is-button is-default is-block is-primary" data-opinionstage-content-launch data-os-block="trivia quiz" onClick={onSelectButtonClick} >Select a Trivia Quiz</span>
206
+ <input type="button" value="Create a New Trivia Quiz" className="components-button is-button is-default is-block is-primary" onClick={onCreateButtonClick} />
207
+ <span></span>
208
+ </div>
209
+ );
210
+
211
+ if(embedUrl != '' && embedUrl){
212
  if(buttonText == 'Embed'){
213
  contentViewEditStatOs
214
+ }else if(buttonText == 'Change'){
215
  contentViewEditStatOs = (
216
+ <div className="os-trivia-wrapper components-placeholder">
217
+ <p className="components-heading"><img src={getlogoImageLinkOs} alt=""/></p>
218
+ <div className="components-preview__block" >
219
+ <div className="components-preview__leftBlockImage">
220
+ <img src={insertItemImage} alt={insertItemOsTitle} className="image" />
221
+ <div className="overlay">
222
+ <div className="text">
223
+ <a href={insertItemOsView} target="_blank"> View </a>
224
+ <a href={insertItemOsEdit} target="_blank"> Edit </a>
225
+ <a href={insertItemOsStatistics} target="_blank"> Statistics </a>
226
+ <input type="button" value={buttonText} className="components-button is-button is-default is-large left-align" onClick={onChangeButtonClick}/>
227
+ </div>
228
+ </div>
229
+ </div>
230
+ <div className="components-preview__rightBlockContent">
231
+ <div className="components-placeholder__label">Trivia Quiz: {insertItemOsTitle}</div>
232
  </div>
233
+ </div>
234
+ <span></span>
235
+ </div>
236
+ );
 
 
 
 
237
  }
238
+ }else if(embedUrl == '' || jQuery.type(embedUrl) === "undefined"){
239
  contentViewEditStatOs
240
  }else{
241
  props.setAttributes({ buttonText: 'Embed'});
242
  contentViewEditStatOs
243
  }
244
+ return (
 
 
245
  <div className={ props.className }>
246
+ {contentViewEditStatOs}
247
+ <span></span>
248
  </div>
249
  );
250
  }
251
  },
252
+ save: function( {attributes: {embedUrl, lockEmbed, buttonText, insertItemImage, insertItemOsTitle, insertItemOsView, insertItemOsEdit, insertItemOsStatistics }} ) {
253
  return (
254
+ <div class="os-trivia-wrapper" data-type="trivia" data-image-url={insertItemImage} data-title-url={insertItemOsTitle} data-view-url={insertItemOsView} data-statistics-url={insertItemOsStatistics} data-edit-url={insertItemOsEdit} data-test-url={embedUrl} data-lock-embed={lockEmbed} data-button-text={buttonText}>
255
+ [os-widget path="{embedUrl}"]
256
+ <span></span>
257
  </div>
258
  );
259
  },
includes/opinionstage-article-placement-functions.php CHANGED
@@ -1,37 +1,37 @@
1
- <?php
2
-
3
- // block direct access to plugin PHP files:
4
- defined( 'ABSPATH' ) or die();
5
-
6
- class OpinionStageArticlePlacement {
7
- static function initialize() {
8
- add_filter($hook = 'the_content', array(__CLASS__, $hook));
9
- }
10
- // Adds the article placement shortcode to each post
11
- static function the_content($content) {
12
- global $post;
13
- if( !(isset($post) && is_object($post)) ){
14
- return $content;
15
- }
16
- $type = $post->post_type;
17
- if (is_front_page() && is_home()) {
18
- return $content;
19
- }
20
- if($type == "post") {
21
- $os_options = (array) get_option(OPINIONSTAGE_OPTIONS_KEY);
22
- if (!empty($os_options['article_placement_id']) && $os_options['article_placement_active'] == 'true' && !is_admin() ) {
23
- $shortcode = do_shortcode(
24
- sprintf(
25
- '[osplacement id="%s"]',
26
- $os_options['article_placement_id']
27
- )
28
- );
29
- return $content . $shortcode;
30
- }
31
- }
32
- return $content;
33
- }
34
-
35
- }
36
- return OpinionStageArticlePlacement::initialize();
37
- ?>
1
+ <?php
2
+
3
+ // block direct access to plugin PHP files:
4
+ defined( 'ABSPATH' ) or die();
5
+
6
+ class OpinionStageArticlePlacement {
7
+ static function initialize() {
8
+ add_filter($hook = 'the_content', array(__CLASS__, $hook));
9
+ }
10
+ // Adds the article placement shortcode to each post
11
+ static function the_content($content) {
12
+ global $post;
13
+ if( !(isset($post) && is_object($post)) ){
14
+ return $content;
15
+ }
16
+ $type = $post->post_type;
17
+ if (is_front_page() && is_home()) {
18
+ return $content;
19
+ }
20
+ if($type == "post") {
21
+ $os_options = (array) get_option(OPINIONSTAGE_OPTIONS_KEY);
22
+ if (!empty($os_options['article_placement_id']) && $os_options['article_placement_active'] == 'true' && !is_admin() ) {
23
+ $shortcode = do_shortcode(
24
+ sprintf(
25
+ '[osplacement id="%s"]',
26
+ $os_options['article_placement_id']
27
+ )
28
+ );
29
+ return $content . $shortcode;
30
+ }
31
+ }
32
+ return $content;
33
+ }
34
+
35
+ }
36
+ return OpinionStageArticlePlacement::initialize();
37
+ ?>
includes/opinionstage-functions.php CHANGED
@@ -1,93 +1,93 @@
1
- <?php
2
-
3
- // block direct access to plugin PHP files:
4
- defined( 'ABSPATH' ) or die();
5
-
6
- /* --- Wordpress Hooks Implementations --- */
7
-
8
- /**
9
- * Initialize the plugin
10
- */
11
- function opinionstage_init() {
12
- $os_options = (array) get_option(OPINIONSTAGE_OPTIONS_KEY);
13
- $os_options['version'] = OPINIONSTAGE_WIDGET_VERSION;
14
-
15
- // For backward compatibility
16
- if ( !isset($os_options['sidebar_placement_active']) ) {
17
- $os_options['sidebar_placement_active'] = 'false';
18
- }
19
-
20
- update_option(OPINIONSTAGE_OPTIONS_KEY, $os_options);
21
- }
22
-
23
- /**
24
- * Remove the plugin data
25
- */
26
- function opinionstage_uninstall() {
27
- delete_option(OPINIONSTAGE_OPTIONS_KEY);
28
- }
29
-
30
- /**
31
- * Check if the requested plugin is already available
32
- */
33
- function opinionstage_check_plugin_available($plugin_key) {
34
- $other_widget = (array) get_option($plugin_key); // Check the key of the other plugin
35
-
36
- // Check if OpinionStage plugin already installed.
37
- return (isset($other_widget['uid']) ||
38
- isset($other_widget['email']));
39
- }
40
- /**
41
- * Notify about other OpinionStage plugin already available
42
- */
43
- function opinionstage_other_plugin_installed_warning() {
44
- echo "<div id='opinionstage-warning' class='error'><p><B>".__("Opinion Stage Plugin is already installed")."</B>".__(', please remove "<B>Popup for Interactive Content by Opinion Stage</B>" and use the available "<B>Poll & Quiz tools by Opinion Stage</B>" plugin')."</p></div>";
45
- }
46
-
47
- /**
48
- * Add the flyout embed code to the page header
49
- */
50
- function opinionstage_add_flyout() {
51
- $os_options = (array) get_option(OPINIONSTAGE_OPTIONS_KEY);
52
-
53
- if (!empty($os_options['fly_id']) && $os_options['fly_out_active'] == 'true' && !is_admin() ) {
54
- // Will be added to the head of the page
55
- ?>
56
- <script type="text/javascript">//<![CDATA[
57
- window.AutoEngageSettings = {
58
- id : '<?php echo $os_options['fly_id']; ?>'
59
- };
60
- (function(d, s, id){
61
- var js,
62
- fjs = d.getElementsByTagName(s)[0],
63
- r = Math.floor(new Date().getTime() / 1000000);
64
- if (d.getElementById(id)) {return;}
65
- js = d.createElement(s); js.id = id; js.async=1;
66
- js.src = '<?php echo OPINIONSTAGE_SERVER_BASE; ?>' + '/assets/autoengage.js?' + r;
67
- fjs.parentNode.insertBefore(js, fjs);
68
- }(document, 'script', 'os-jssdk'));
69
-
70
- //]]></script>
71
-
72
- <?php
73
- }
74
- }
75
- function opinionstage_is_guten_enabled(){
76
- $block_editor_oswp = version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' );
77
- if($block_editor_oswp == false){
78
- if( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ){
79
- return true;
80
- }else{
81
- return false;
82
- }
83
- }else{
84
- global $current_screen;
85
- $current_screen = get_current_screen();
86
- if( method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor() ){
87
- return true;
88
- }else{
89
- return false;
90
- }
91
- }
92
- }
93
- ?>
1
+ <?php
2
+
3
+ // block direct access to plugin PHP files:
4
+ defined( 'ABSPATH' ) or die();
5
+
6
+ /* --- Wordpress Hooks Implementations --- */
7
+
8
+ /**
9
+ * Initialize the plugin
10
+ */
11
+ function opinionstage_init() {
12
+ $os_options = (array) get_option(OPINIONSTAGE_OPTIONS_KEY);
13
+ $os_options['version'] = OPINIONSTAGE_WIDGET_VERSION;
14
+
15
+ // For backward compatibility
16
+ if ( !isset($os_options['sidebar_placement_active']) ) {
17
+ $os_options['sidebar_placement_active'] = 'false';
18
+ }
19
+
20
+ update_option(OPINIONSTAGE_OPTIONS_KEY, $os_options);
21
+ }
22
+
23
+ /**
24
+ * Remove the plugin data
25
+ */
26
+ function opinionstage_uninstall() {
27
+ delete_option(OPINIONSTAGE_OPTIONS_KEY);
28
+ }
29
+
30
+ /**
31
+ * Check if the requested plugin is already available
32
+ */
33
+ function opinionstage_check_plugin_available($plugin_key) {
34
+ $other_widget = (array) get_option($plugin_key); // Check the key of the other plugin
35
+
36
+ // Check if OpinionStage plugin already installed.
37
+ return (isset($other_widget['uid']) ||
38
+ isset($other_widget['email']));
39
+ }
40
+ /**
41
+ * Notify about other OpinionStage plugin already available
42
+ */
43
+ function opinionstage_other_plugin_installed_warning() {
44
+ echo "<div id='opinionstage-warning' class='error'><p><B>".__("Opinion Stage Plugin is already installed")."</B>".__(', please remove "<B>Popup for Interactive Content by Opinion Stage</B>" and use the available "<B>Poll & Quiz tools by Opinion Stage</B>" plugin')."</p></div>";
45
+ }
46
+
47
+ /**
48
+ * Add the flyout embed code to the page header
49
+ */
50
+ function opinionstage_add_flyout() {
51
+ $os_options = (array) get_option(OPINIONSTAGE_OPTIONS_KEY);
52
+
53
+ if (!empty($os_options['fly_id']) && $os_options['fly_out_active'] == 'true' && !is_admin() ) {
54
+ // Will be added to the head of the page
55
+ ?>
56
+ <script type="text/javascript">//<![CDATA[
57
+ window.AutoEngageSettings = {
58
+ id : '<?php echo $os_options['fly_id']; ?>'
59
+ };
60
+ (function(d, s, id){
61
+ var js,
62
+ fjs = d.getElementsByTagName(s)[0],
63
+ r = Math.floor(new Date().getTime() / 1000000);
64
+ if (d.getElementById(id)) {return;}
65
+ js = d.createElement(s); js.id = id; js.async=1;
66
+ js.src = '<?php echo OPINIONSTAGE_SERVER_BASE; ?>' + '/assets/autoengage.js?' + r;
67
+ fjs.parentNode.insertBefore(js, fjs);
68
+ }(document, 'script', 'os-jssdk'));
69
+
70
+ //]]></script>
71
+
72
+ <?php
73
+ }
74
+ }
75
+ function opinionstage_is_guten_enabled(){
76
+ $block_editor_oswp = version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' );
77
+ if($block_editor_oswp == false){
78
+ if( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ){
79
+ return true;
80
+ }else{
81
+ return false;
82
+ }
83
+ }else{
84
+ global $current_screen;
85
+ $current_screen = get_current_screen();
86
+ if( method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor() ){
87
+ return true;
88
+ }else{
89
+ return false;
90
+ }
91
+ }
92
+ }
93
+ ?>
includes/opinionstage-sidebar-widget.php CHANGED
@@ -114,7 +114,7 @@ require_once( plugin_dir_path( __FILE__ ).'opinionstage-client-session.php' );
114
  <label for="<?php echo $this->get_field_id('enabled'); ?>">Enabled</label>
115
  </div> -->
116
  <div class="opinionstage-sidebar-config">
117
- <a href="<?php echo opinionstage_sidebar_placement_edit_url('content'); ?>" target="_blank" class='opinionstage-blue-bordered-btn opinionstage-edit-content'>EDIT CONTENT</a>
118
  <a href="<?php echo opinionstage_sidebar_placement_edit_url('settings'); ?>" class='opinionstage-blue-bordered-btn opinionstage-edit-settings <?php echo( $os_client_logged_in ? '' : 'disabled' ) ?>' target="_blank">
119
  <div class="os-icon icon-os-common-settings"></div>
120
  </a>
114
  <label for="<?php echo $this->get_field_id('enabled'); ?>">Enabled</label>
115
  </div> -->
116
  <div class="opinionstage-sidebar-config">
117
+ <a href="<?php echo opinionstage_sidebar_placement_edit_url('content'); ?>" target="_blank" class='opinionstage-blue-bordered-btn opinionstage-edit-content'>SELECT ITEM</a>
118
  <a href="<?php echo opinionstage_sidebar_placement_edit_url('settings'); ?>" class='opinionstage-blue-bordered-btn opinionstage-edit-settings <?php echo( $os_client_logged_in ? '' : 'disabled' ) ?>' target="_blank">
119
  <div class="os-icon icon-os-common-settings"></div>
120
  </a>
opinionstage-polls.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Poll, Survey, Form & Quiz Maker by OpinionStage (Deprecated)
4
  Plugin URI: https://www.opinionstage.com
5
  Description: Add a highly engaging poll, survey, quiz or contact form builder to your site. You can add the poll, survey, quiz or form to any post/page or to the sidebar.
6
- Version: 19.6.17
7
  Author: OpinionStage.com
8
  Author URI: https://www.opinionstage.com
9
  Text Domain: social-polls-by-opinionstage
3
  Plugin Name: Poll, Survey, Form & Quiz Maker by OpinionStage (Deprecated)
4
  Plugin URI: https://www.opinionstage.com
5
  Description: Add a highly engaging poll, survey, quiz or contact form builder to your site. You can add the poll, survey, quiz or form to any post/page or to the sidebar.
6
+ Version: 19.6.18
7
  Author: OpinionStage.com
8
  Author URI: https://www.opinionstage.com
9
  Text Domain: social-polls-by-opinionstage
plugin.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Poll, Survey, Form & Quiz Maker by OpinionStage
4
  Plugin URI: https://www.opinionstage.com
5
  Description: Add a highly engaging poll, survey, quiz or contact form builder to your site. You can add the poll, survey, quiz or form to any post/page or to the sidebar.
6
- Version: 19.6.17
7
  Author: OpinionStage.com
8
  Author URI: https://www.opinionstage.com
9
  Text Domain: social-polls-by-opinionstage
@@ -24,7 +24,7 @@ if ( defined('WP_DEBUG') && true === WP_DEBUG ) {
24
  }
25
  }
26
 
27
- define('OPINIONSTAGE_WIDGET_VERSION', '19.6.17');
28
 
29
  define('OPINIONSTAGE_TEXT_DOMAIN', 'social-polls-by-opinionstage');
30
 
3
  Plugin Name: Poll, Survey, Form & Quiz Maker by OpinionStage
4
  Plugin URI: https://www.opinionstage.com
5
  Description: Add a highly engaging poll, survey, quiz or contact form builder to your site. You can add the poll, survey, quiz or form to any post/page or to the sidebar.
6
+ Version: 19.6.18
7
  Author: OpinionStage.com
8
  Author URI: https://www.opinionstage.com
9
  Text Domain: social-polls-by-opinionstage
24
  }
25
  }
26
 
27
+ define('OPINIONSTAGE_WIDGET_VERSION', '19.6.18');
28
 
29
  define('OPINIONSTAGE_TEXT_DOMAIN', 'social-polls-by-opinionstage');
30
 
readme.txt CHANGED
@@ -1,685 +1,687 @@
1
- === Poll, Survey, Form & Quiz Maker by OpinionStage ===
2
- Contributors: OpinionStage.com
3
- Donate link: https://www.opinionstage.com
4
- Tags: poll, quiz, survey, form, interactive content
5
- Requires at least: 2.8
6
- Tested up to: 5.1
7
- Stable tag: 19.6.17
8
-
9
- Add a beautiful & top performing Poll, Survey, Quiz or Form to your site. Create from scratch or use templates. Set it up in Minutes.
10
-
11
- == Description ==
12
-
13
- Looking for a Top-Notch Poll, Survey, Form & Quiz Wordpress Plugin?
14
-
15
- Check out:
16
-
17
- <a href="https://www.opinionstage.com/poll?o=wp35e8" target="_blank">Poll Maker</a> | <a href="https://www.opinionstage.com/templates?utf8=✓&types%5B%5D=poll&o=wp35e8" target="_blank">Poll Examples</a>
18
- <a href="https://www.opinionstage.com/quiz?o=wp35e8" target="_blank">Quiz Maker</a> | <a href="https://www.opinionstage.com/templates?utf8=%E2%9C%93&types%5B%5D=personality_quiz&o=wp35e8" target="_blank">Quiz Examples</a>
19
- <a href="https://www.opinionstage.com/survey?o=wp35e8" target="_blank">Survey Maker</a> | <a href="https://www.opinionstage.com/templates?utf8=%E2%9C%93&types%5B%5D=survey&o=wp35e8" target="_blank">Survey Examples</a>
20
- <a href="https://www.opinionstage.com/form?o=wp35e8" target="_blank">Form Maker</a> | <a href="https://www.opinionstage.com/templates?utf8=%E2%9C%93&types%5B%5D=form&o=wp35e8" target="_blank">Form Examples</a>
21
-
22
- = Why use Opinion Stage? =
23
-
24
- * Boost engagement & traffic - add a poll, survey or quiz to your posts/pages to increases participation, time-on-site & page views. Increase social sharing and viral distribution
25
- * Gather more qualified leads - integrate a lead form inside the poll, quiz or survey. This will not only produce more leads, but will also produce qualified leads, as the leads will be associated with the answers of the users.
26
- * Generate revenue - take advantage of the high engagement rates to increase revenue from ads inside and outside of the interactive content.
27
- * Extract insights - get more insights using interactive polls & surveys designed to maximize participation. Extract actionable insights with a intuitive analytics dashboard.
28
-
29
- = Main Poll WordPress Plugin Features: =
30
-
31
- * Create polls with 4 different layouts (standard, image, thumbnails & head-to-head)
32
- * Easily add images & videos into the polls either from your computer or by using an integrated search poll image function
33
- * Configure if user can select one or more options when voting on the poll
34
- * Allow users to add their own answers to the poll
35
- * Block repeat voting in the poll using different mechanisms (e.g. Cookie, IP, etc)
36
- * Permit user to vote on the poll once every configured time frame (e.g. every hour, day, etc)
37
- * Display a customized message to the user after he votes on the poll
38
- * Configure to close the poll at a specified time
39
- * Redirect users to different landing pages based on their poll vote
40
- * Configure the display order of the poll options (e.g. most votes on top, random)
41
- * Configure if the poll results are displayed before voting, after voting or only to the poll creator
42
- * Configure how results are displayed to the poll voters (only percentage, number of votes, both, etc)
43
- * Integrate ads inside the polls to increase ad-revenue from your site
44
- * Configure webhooks for sending the information gathered from your poll to any 3rd party application
45
- * Graphic presentations of the poll results including pie & chart bars
46
- * View a detailed result table of all poll votes (e.g. vote side, vote timestamp, etc)
47
- * Export the poll results to an xls or csv file
48
-
49
- = Main Quiz WordPress Plugin Features: =
50
-
51
- * Create a personality quiz, trivia quiz, score quiz, true/false quiz, assessment quiz, multiple-choice quiz or outcome quiz
52
- * Integrate images & videos in the quiz from your computer, from a link or using online search capabilities
53
- * Set the main image that is shared when users share the quiz on social networks
54
- * Configure to request users to like your facebook page before they view the quiz results
55
- * Configure the facebook & twitter sharing message that is displayed when users share the quiz
56
- * Configure webhooks for sending all the information gathered in the quiz to any 3rd party application
57
- * Integrate ads in the quiz interface to increase your sites ad-revenue potential
58
- * Add pixel tracking to the quiz to optimize your ad campaigns
59
- * View high level statistics of your quiz including quiz impressions, quiz starts, quiz completions, average time spend on quiz, # of engagements on the quiz & # of leads generated while users participated in the quiz
60
- * View the detailed results of each quiz question
61
- * View a drop-off report that shows the percentage of users that voted in each quiz question
62
- * View a detailed response report that includes all the details of each quiz submission (e.g. detailed answers, timestamp, etc)
63
- * Export the quiz results to a xls or csv file
64
- * Detailed logic of personality quizzes, including a scoring system for sides and formula for calculating the quiz outcome
65
- * Detailed logic for trivia quizzes, including setting the correct answers, displaying explanations after selecting answers, calculating the results and various quiz result display options
66
- * Support for randomizing answers in each quiz question to improve validity of results
67
- * Support for call-to-action buttons at the end of the quiz
68
- * Support sending to different landing pages based on the quiz outcome
69
-
70
- = Main Survey WordPress Plugin Features: =
71
-
72
- * Integrate images & videos to make the survey appealing & engaging. You can either upload images from your computer or use online search to locate free-to-use images
73
- * Support both single selection and multiple selection questions and supports allowing users to add their own answer
74
- * Support open ended questions of different types
75
- * Supports informative cards that can be displayed inside the survey
76
- * Supports a call-to-action action at the end of the survey
77
- * Supports branch logic that lets you determine which question is asked next based on the answer to the last question
78
- * Supports setting variables that can be set based on answers of users (for example saving their name to use in following questions)
79
- * Supports social integrations, such as adding a social sharing bar, integrations with facebook like box and facebook comments and twitter message customization
80
- * Supports sending submissions via email to the survey creator
81
- * Supports webhooks for sending all the gathered information to a 3rd party tool
82
- * Naive integrations with mailchimp & hubspot
83
- * Integration with pixels to optimize ad-campaigns focused on getting relevant audience to the survey
84
- * Overview statistics that include number of views, starts, completions, # of engagement, average time on survey and # of leads gathered
85
- * Detailed response table, each response with all the answers and meta data such as timestamp of submission
86
- * Graphic display (pie chart & bar chart) of answers to each one of the questions
87
- * Drop off report to help optimize the survey for maximum completion rates
88
-
89
- = Main Form WordPress Plugin Features: =
90
-
91
- * Supports Short & long text fields
92
- * Supports Email fields including 2 approval checkboxes
93
- * Support phone number field
94
- * Supports drop-down field
95
- * Configure to send an email to form creator on each submission
96
- * Support sending all the gathered information to a 3rd party application using webhooks
97
- * Supports native integrations with mailchimp and hubspot
98
- * View statistics on # of views vs. # of submissions
99
- * View all submissions including the all field entries and meta data such as timestamp of submission
100
-
101
- = Placements: =
102
-
103
- * Sidebar placement - add to the site sidebar using a dedicated Opinion Stage sidebar widget
104
- * Popup placement - popup when users enter or exit your site using a highly configurable popup component
105
- * Articles placement - display at the end of all your posts/pages
106
-
107
- = Language support =
108
-
109
- Opinion Stage supports over 42 languages, missing a language? Let us know!
110
-
111
- = About Opinion Stage: =
112
-
113
- Opinion Stage is a powerful & easy-to-use interactive content (e.g. poll, quiz, survey, forms, etc) creation service. Opinion Stages' highly engaging content formats are used to boost engagement, gather leads, generate revenue and to extract actionable insights. Opinion Stage works with 100,000+ publishers, brands & agenencies, including world-leading publishers, brands & agencies. For more details, visit <a href="https://www.opinionstage.com?o=wp35e8" target="_blank">the Opinion Stage site.</a>
114
-
115
- == Installation ==
116
-
117
- 1. Upload the "Poll, Survey, Form & Quiz Maker" plugin to your blog (or search for it) and then install the plugin on your plugins page
118
- 2. Active it and start creating polls, quizzes, surveys and forms
119
-
120
- == Frequently Asked Questions ==
121
-
122
- = Is Opinion Stage content responsive? =
123
-
124
- Yes, all content (e.g. poll, quiz, survey, form, etc) created with Opinion Stage is fully responsive, and designed to optimaly display on mobile, tablet and desktop
125
-
126
- = What interactive content formats does Opinion Stage support? =
127
-
128
- With Opinion Stage you can create the following content formats: Poll, Poll Sets, Personality Quiz, Trivia Quiz, Survey, Slideshow, Form, Story Article, List. We are constantly adding additional interactive content formats so stay tuned!
129
-
130
- = What is the difference between a Poll and a Survey =
131
-
132
- Polls include one question and are used for getting a quick answer on a question. Polls are often used for gathering opinions, getting feedback, running contents & competitions and generating engagement. Surveys include multiple questions of different types. Surveys are often used to gather feedback and insights. If you are still unsure whether to use a poll or a survey, contact our support team and we'll be happy to help.
133
-
134
- = What customization options do you offer? =
135
-
136
- Opinion Stage offers many built-in customization options such as selecting the color theme, font and sizes. You can also use a CSS override feature to fully match the items to your brand. You can also white label the items and add your own logo.
137
-
138
-
139
- == Other Notes ==
140
-
141
- == Screenshots ==
142
-
143
- 1. **Poll image layout** - example of integrating images in the poll answers to make it more appealing, which results with improved engagement rates.
144
- 2. **Poll standard layout** - the poll include a lot of features including, selecting if users can select one side or more in the poll, allowing users to add their own answer to the poll, different methods of organizing the poll side order, setting the poll color, setting the poll font, preventing repeat voting in the poll, voting with a social profile in the poll, setting the poll result display, setting an expiry date for the poll, alignment of the poll title, setting the poll width, setting poll sharing bar, and much more
145
- 3. **poll head to head layout** - example of a head-to-head layout poll
146
- 4. **Trivia quiz** - example of a Trivia quiz result. Set the correct answer in each of the quiz questions, and following users answers to the quiz, give them a quiz result with the number of correct quiz answers. Trivia quizzes are one of the most engaging type of content.
147
- 5. **Personality quiz** - example of a personality quiz. Using a personality quiz, you can ask you users different quiz questions, and based on their answers to the quiz questions, offer them different quiz results. Personality quizzes tend to be viral as they produce a lot of social shares.
148
- 6. **Content creation dashboard** - example of the Opinion Stage interactive content (e.g. poll, quiz, survey, form) creation dashboard
149
- 7. **Lead form** - example of gathering quality leads while users participate in the polls, quizzes & surveys
150
- 8. **Report** - example of a poll report screen that includes advanced analysis of results
151
- 9. **Templates** - dashboard that includes highly effective examples that can be duplicated to your account
152
- 10. **Popup placement** - display your content in an exit/enter, center/side screen popup
153
-
154
- == Upgrade Notice ==
155
-
156
- N/A
157
-
158
- == Changelog ==
159
- = 19.6.17 =
160
- * UI looks & feel revamp
161
- = 19.6.16 =
162
- * Support 5.1 and Readme updates
163
- = 19.6.15 =
164
- * Gutenberg fixes and improvements
165
- = 19.6.14 =
166
- * Gutenberg fix
167
- = 19.6.13 =
168
- * My Items page
169
- * updated Content Popup
170
- * Design update
171
- = 19.6.12 =
172
- * readme update
173
- = 19.6.11 =
174
- * readme update
175
- * analytics setup
176
- = 19.6.10 =
177
- * navigation links update
178
- = 19.6.9 =
179
- * add support for new editor Gutenberg
180
- = 19.6.8 =
181
- * readme changes
182
- * add admin loader
183
- = 19.6.7 =
184
- * new getting started experience
185
- = 19.6.6 =
186
- * WordPress 5.0 compatibility
187
- * Readme update
188
- = 19.6.5 =
189
- * Assets loading fix
190
- * Readme update
191
- = 19.6.4 =
192
- * Permission fix on sub pages
193
- = 19.6.3 =
194
- * Icon set fix
195
- = 19.6.2 =
196
- * Double page bug fix
197
- * Plugin renamed
198
- = 19.6.1 =
199
- * Plugin rename: improved fix
200
- = 19.6.0 =
201
- * Plugin filename fix
202
- * Backward Compatibility added
203
- = 19.5.0 =
204
- * New navigation added
205
- * Fixed placements issue
206
- = 19.4.2 =
207
- * better AJAX handling
208
- = 19.4.1 =
209
- * fix deactivation issue
210
- = 19.4.0 =
211
- * stability fixes
212
- * added deactivate screen
213
- = 19.3.5 =
214
- * more updates to readme.txt file
215
- = 19.3.4 =
216
- * rename plugin
217
- * update to readme.txt file
218
- * small text changes
219
- = 19.3.3 =
220
- * small text changes
221
- = 19.3.2 =
222
- * readme update
223
- = 19.3.1 =
224
- * readme update
225
- = 19.3.0 =
226
- * add Story support
227
- = 19.2.7 =
228
- * fix PHP installations older than 5.4
229
- = 19.2.6 =
230
- * fix links to content
231
- = 19.2.5 =
232
- * minor text updates
233
- = 19.2.4 =
234
- * tested up to 4.9 WordPress version
235
- * Minor textual changes
236
- = 19.2.3 =
237
- * fix content popup video placing issue
238
- = 19.2.2 =
239
- * adds video intro
240
- = 19.2.1 =
241
- * adds ability to sign in from content popup
242
- * various UI/UX issues fixes
243
- = 19.2.0 =
244
- * content popup UI/UX improvements
245
- * login/logout UI/UX
246
- = 19.1.0 =
247
- * content popup UI/UX improvements
248
- = 19.0.2 =
249
- * Minor textual changes
250
- = 19.0.1 =
251
- * Minor logging changes
252
- = 19.0.0 =
253
- * New feature: post editor integration
254
- = 18.2.1 =
255
- * Minor changes
256
- = 18.2.0 =
257
- * Support for 4.8 WP version
258
- = 18.1.0 =
259
- * Minor styling fixes
260
- * Widgets embedding refactor
261
- = 18.0.5 =
262
- * sidebar widget fix
263
- = 18.0.4 =
264
- * prevent internal font icon leak into site area
265
- = 18.0.3 =
266
- * Minor fixes
267
- = 18.0.2 =
268
- * Fix sidebar widget settings style
269
- * Add SlideShow
270
- * Fix ContactForm icon
271
- * Fix video tutorials help link
272
- = 18.0.1 =
273
- * Fix menu page styling
274
- = 18.0.0 =
275
- * Add a slider content format
276
- = 17.9.0 =
277
- * Additional survey features based on client requests
278
- = 17.8.0 =
279
- * Improvements of quiz/survey reporting
280
- * Various minor bug fixes
281
- = 17.7.0 =
282
- * Responses table improvements, language fixes, advanced editing in after vote notifications
283
- = 17.6.0 =
284
- * Various fixes & optimizations
285
- = 17.5.0 =
286
- * Display comment after user votes
287
- * Additional advanced reports
288
- = 17.4.0 =
289
- * Add new charts to the poll, quiz & survey reports
290
- = 17.3.0 =
291
- * Display an explanation after voting in polls
292
- * Fixed bug with IP blocking
293
- = 17.2.0 =
294
- * New drop-off report
295
- * Async sending of leads
296
- = 17.1.0 =
297
- * Add CSS override to all content types
298
- * Support GTM integrations
299
- = 17.0.0 =
300
- * Improved quiz/survey reporting capabilities
301
- = 16.9.0 =
302
- * Added support for pixel tracking
303
- = 16.8.0 =
304
- * Support for WordPress 4.7
305
- = 16.7.0 =
306
- * Improve support for high volume lead configurations
307
- = 16.6.0 =
308
- * Text changes and bug fixes
309
- = 16.5.0 =
310
- * Various minor fixes & optimizations
311
- = 16.4.0 =
312
- * Added ad refresh mechanism
313
- = 16.3.0 =
314
- * Added verification for the placements ids in the connection callback function
315
- = 16.2.0 =
316
- * Various minor improvements & bug fixes
317
- = 16.1.0 =
318
- * Added chatbot tool integration
319
- = 16.0.0 =
320
- * Updated help for new features
321
- = 15.9.0 =
322
- * Rebranded Quiz name to Outcome, removed the section entry
323
- = 15.8.0 =
324
- * Resolved an issue with the font
325
- = 15.7.0 =
326
- * Added support for creating Contact Form Builders, added to plugin name
327
- = 15.6.0 =
328
- * Added support for creating surveys, renamed plugin
329
- = 15.5.0 =
330
- * Support WP 4.5
331
- = 15.4.0 =
332
- * Added the option to add a content section
333
- = 15.3.0 =
334
- * Modified API path
335
- = 15.2.0 =
336
- * Various optimizations
337
- = 15.1.0 =
338
- * Security fix to limit accses to dashboard
339
- = 15.0.0 =
340
- * Various optimizations
341
- = 14.9.0 =
342
- * Added the option to embed using a fixed width
343
- = 14.8.0 =
344
- * Modified sidebar widget management UI
345
- * Replaced dashboard top navigation links with more prominent 'my content' link
346
- * Added 'list' to the plugin name
347
- = 14.7.0 =
348
- * Various small optimizations
349
- = 14.6.0 =
350
- * Various UI modifications - added top navigation links, dashboard UI is now more responsive.
351
- = 14.5.0 =
352
- * Renamed style to avoid css caching issues
353
- = 14.4.0 =
354
- * Complete ui revamp
355
- * Removed obsolete polls insertion popup and tinymce integration
356
- * Handling compatibility issues with other plugin
357
- = 14.3.0 =
358
- * Various Poll, Survey, Quiz, Slideshow, Form & Story Article improvements
359
- = 14.2.0 =
360
- * Not showing recommendations by default when embedding Trivia quiz and Personality quiz via the widget shortcode
361
- = 14.1.0 =
362
- * Added support for disabling FB comments, sharing buttons and recommendations for Trivia quiz and Personality quiz via the widget shortcode
363
- = 14.0.0 =
364
- * Improved polls & quizzes creation help file
365
- * Various small issues
366
- = 13.9.0 =
367
- * Added creation links for trivia quiz, personality quiz and lists
368
- * Added a link for content discovery
369
- = 13.8.0 =
370
- * Support creating a quiz draft
371
- * Added quiz tips and quiz best practices
372
- = 13.7.0 =
373
- * Better name for widget following feedback
374
- = 13.6.0 =
375
- * Added personality quizzes
376
- = 13.5.0 =
377
- * Renamed plugin to better reflect the Contact Form Builder
378
- = 13.4.0 =
379
- * Added shortcodes for trivia and personality quizzes
380
- = 13.3.0 =
381
- * Various Trivia Quiz enhancements & fixes
382
- * Support for iframe embeds
383
- = 13.2.0 =
384
- * Support for Basque & Vietnamese languages
385
- * Trivia Quiz beta
386
- = 13.1.0 =
387
- * Added support for quick addition of any language
388
- = 13.0.0 =
389
- * Added text domain
390
- = 12.9.0 =
391
- * Poll discovery mechanism improvements
392
- * Additional tracking capabilities
393
- = 12.8.0 =
394
- * Various bug fixes
395
- = 12.7.0 =
396
- * CSS modifications to better align with desired coding standards. Reverted css file name change.
397
- * Minor text changes
398
- * Not using PHP 4 Style Constructors any more
399
- = 12.6.0 =
400
- * Fixed broken links to dashboard
401
- * Renamed css file
402
- = 12.5.0 =
403
- * Modified css structure
404
- * Added an option to enable/disable sidebar widget directly via the widget box
405
- = 12.4.0 =
406
- * Added a control switch for the Sidebar placement
407
- = 12.3.0 =
408
- * Added Sidebar placement as a widget
409
- = 12.2.0 =
410
- * Added the option to connect the plugin to Opinion Stage account
411
- * Added plug & play integration for fly-out placement
412
- * Replaced the option of adding polls to all posts with plug & play article section placement
413
- = 12.1.0 =
414
- * Additional fix for supporting SSL
415
- = 12.0.0 =
416
- * Support for SSL when voting with social profiles
417
- * revamp of content recommendation mechanism
418
- = 11.9.0 =
419
- * Poll Placement improvements
420
- = 11.8.0 =
421
- * Plugin minor changes
422
- = 11.7.0 =
423
- * Image cropping
424
- = 11.6.0 =
425
- * New poll recommendation design
426
- = 11.5.0 =
427
- * resolve conflicts
428
- = 11.4.0 =
429
- * Fixed compatibility issues
430
- = 11.3.0 =
431
- * First Trivia poll Poll, Survey, Quiz, Slideshow, Form & Story Article Version
432
- = 11.2.0 =
433
- * Various functionality & usability improvements
434
- = 11.1.0 =
435
- * Head-to-Head Poll - new revamped UI (first Poll, Survey, Quiz, Slideshow, Form & Story Article Version)
436
- = 11.0.0 =
437
- * New look & feel settings
438
- = 10.9.0 =
439
- * Allow disabling global poll section for specific posts
440
- = 10.8.0 =
441
- * Texts changes
442
- = 10.7.0 =
443
- * New options for adding polls or sets to all posts
444
- = 10.6.0 =
445
- * Poll sets and poll placements - improved interface
446
- = 10.5.0 =
447
- * Ad integrations (optional) - revamped interface
448
- = 10.4.0 =
449
- * Added UI support for social logins
450
- = 10.3.0 =
451
- * New UI for Multiple Choice Polls
452
- = 10.2.0 =
453
- * Various stability fixes
454
- = 10.1.0 =
455
- * Post vote actions
456
- = 10.0.0 =
457
- * Contact Form Builder improvements
458
- = 9.9.0 =
459
- * Various fixes
460
- = 9.8.0 =
461
- * Poll discovery first Poll, Survey, Quiz, Slideshow, Form & Story Article Version
462
- = 9.7.0 =
463
- * Placements first Poll, Survey, Quiz, Slideshow, Form & Story Article Version
464
- = 9.6.0 =
465
- * Various fixes
466
- = 9.5.0 =
467
- * Smart containers first Poll, Survey, Quiz, Slideshow, Form & Story Article Version
468
- = 9.4.0 =
469
- * Allow users to add their own answers
470
- * Head2Head polls - mobile optimizations
471
- = 9.3.0 =
472
- * Support adding custom texts to the interface
473
- * Solve minor UI issues
474
- = 9.2.0 =
475
- * Support displaying ads before showing the results
476
- * Support reordering the sides of the poll
477
- = 9.1.0 =
478
- * Added the option to add Facebook comments to the polls
479
- * Improvements to poll creation flow
480
- = 9.0.0 =
481
- * New poll head-to-head themes
482
- * Poll UI optimizations
483
- = 8.9.0 =
484
- * Various additions and improvements to the poll style studio
485
- * Support for wide pages
486
- = 8.8.0 =
487
- * Improved poll built-in UI styles
488
- * New capabilities to poll style studio
489
- = 8.7.0 =
490
- * Improved poll reports
491
- * Various minor improvements
492
- = 8.6.0 =
493
- * Poll perContact Form Builderance improvements for peek scenarios
494
- * New banner type ad unit
495
- = 8.5.0 =
496
- * Improve process of adding polls to site
497
- * Improve returning traffic tracking mechanism
498
- = 8.4.0 =
499
- * Add first of poll discovery feature
500
- * Resolve issue with image addition
501
- = 8.3.0 =
502
- * Add the option to integrate advertisement into the polls for generating revenue
503
- * Optimizations for poll display in mobile environments
504
- = 8.2.0 =
505
- * Enhancements on contact generation feature
506
- * Mobile polls improvements
507
- * Additions to default poll settings
508
- = 8.1.0 =
509
- * Poll discovery - first Poll, Survey, Quiz, Slideshow, Form & Story Article Version
510
- * Poll sets improvements
511
- * Poll perContact Form Builderance improvements
512
- = 8.0.0 =
513
- * Added an account report dashboard
514
- = 7.9.0 =
515
- * Resolved paypal integration issues
516
- * Resolved facebook page integration issues
517
- = 7.8.0 =
518
- * Renamed plugin to better reflect the Contact Form Builder
519
- = 7.7.0 =
520
- * Fixed 2 poll display issues
521
- = 7.6.0 =
522
- * Added the ability to insert a shortcode of a set of polls
523
- * Added a widget for a container and for a set of polls
524
- = 7.5.0 =
525
- * Created a widget for easily adding polls to site
526
- = 7.4.0 =
527
- * Poll Contact Form Builder optimizations
528
- = 7.3.0 =
529
- * Resolved 2 issues with polls on mobile
530
- = 7.2.0 =
531
- * Add external integration with 3rd parties via API/XML mechanism
532
- = 7.1.0 =
533
- * Support collecting emails from poll voters
534
- = 7.0.0 =
535
- * Fixed potential collisions with other plugins
536
- = 6.9.0 =
537
- * First of Poll Sets
538
- * First of redirect after poll vote
539
- * Fix related to languages in poll display
540
- = 6.8.0 =
541
- * Fix issue with Mobile voting
542
- * Fix for iframe embed of poll
543
- * Fix for uploading images from computer
544
- = 6.7.0 =
545
- * Added Czech language & fix for Polish
546
- * Add poll images via URL
547
- = 6.6.0 =
548
- * Improve poll login screen in mobile
549
- * Fixes for poll container
550
- = 6.5.0 =
551
- * Fix issues with voting on iphone/ipad (iOS7)
552
- = 6.4.0 =
553
- * New poll container
554
- * Improvements to the poll optimization dashboard
555
- = 6.3.0 =
556
- * New graphs for the new reports page
557
- * New languages - Romanian, Polish, Indonesian, Danish
558
- = 6.2.0 =
559
- * New Poll navigation bar
560
- * New languages - Dutch, Albanian, Lithuanian
561
- = 6.1.0 =
562
- * New dashboard and site header
563
- * Poll was translated to the following languages - Swedish, Turkish, Chinese, Japanese, Korean
564
- = 6.0.0 =
565
- * Added the option to login to Opinion Stage with a email/user-name and password combination
566
- = 5.9.0 =
567
- * Added geographic location filter to poll results dashboard
568
- = 5.8.0 =
569
- * Added time filter to poll results dashboard
570
- * New design for on site poll page
571
- * Various improvements & fixes on poll results dashboard
572
- = 5.7.0 =
573
- * Added the option to block repeat voting in polls by IP
574
- = 5.6.0 =
575
- * Improvements & fixes on poll studio
576
- = 5.5.0 =
577
- * Improvements & fixes on poll reporting statistics
578
- * Improvements & fixes on poll core flows
579
- = 5.4.0 =
580
- * Added to the poll results screen the following poll stats: poll engagement stats, poll social stats & poll traffic stats
581
- = 5.3.0 =
582
- * Add a clone function that allows to easily create multiple polls from the same template
583
- * Add the option to schedule when the poll will be closed
584
- = 5.2.0 =
585
- * Revamp of the poll social sharing settings
586
- * revamp of add poll to website screen
587
- = 5.1.0 =
588
- * Add Facebook comments to polls added to Facebook pages
589
- * Add the option to preview the poll in different widths
590
- = 5.0.0 =
591
- * Improvements to poll style studio
592
- * Added option to configure head to head polls not to show results before voting
593
- * Added the option to configure all types of polls not to show results to voters
594
- * Extended width support of head to head polls to 250-740 pxls
595
- = 4.7.1 =
596
- * Additional social filters added to the poll interface & poll report
597
- * Optimize poll sharing scenarios
598
- = 4.7.0 =
599
- * Improvements on poll sharing scenarios
600
- = 4.6.0 =
601
- * Add polls to Facebook pages in 2-clicks feature added
602
- * Enhanced poll reporting that includes poll result filters
603
- * Brightcove video Contact Form Builderat now supported in the polls
604
- = 4.5.5 =
605
- * Added support for Google+ poll login
606
- * Fixed a presentation issue with polls and https sites
607
- * Fixed issue with poll display on Facebook pages
608
- = 4.5.0 =
609
- * Localize polls for Russian and French
610
- * New design for poll social login dialogue
611
- * Polls now auto-detect https environments
612
- * Various minor fixes and improvements to poll functionality
613
- = 4.4.0 =
614
- * Polls are now localized for Portuguese
615
- * Various minor bug fixes
616
- = 4.3.0 =
617
- * Multiple sided polls are supported for 150 widths and above
618
- * Head-to-head polls are supported for 300 widths and above
619
- * Poll style studio was improved to included many more poll style options
620
- * New improved poll dashboard
621
- * Poll showcase was improved to include more poll examples and detailed explanations
622
- = 4.2.0 =
623
- * Multi-sided polls support addition of multimedia (video and image)
624
- * Both head-to-head and multi-sided polls - Multimedia support auto-fit for different width (e.g mobile environment)
625
- = 4.1.0 =
626
- * Multi-sided polls support addition of multimedia (video and image)
627
- * Both head-to-head and multi-sided polls - Multimedia support auto-fit for different width (e.g mobile environment)
628
- = 4.0.0 =
629
- * UI improvements for the polls (filters, border etc)
630
- = 3.1.0 =
631
- * Poll creator can select number of allowed poll answers
632
- * FB poll sharing flow optimizations
633
- * Poll results can be shown from the Opinion-Stage poll dashboard
634
- = 3.0.0 =
635
- * New hybrid voting method added to the polls, allowing users to vote either via a social profile or completely anonymously
636
- = 2.9.0 =
637
- * Added support for anonymous poll voting
638
- = 2.8.0 =
639
- * Improved editing process of polls by adding a preview to the poll editing screen
640
- * Additional layout customizations for polls - hide top bars, add bottom padding
641
- * Polls can now be reset
642
- = 2.7.0 =
643
- * Additional poll languages support (German, Italian, Serbian)
644
- * Additional poll customizations for the vote sharing process
645
- = 2.6.0 =
646
- * Additional customizations options to the poll: Define which poll filters to show, poll social sharing bar removal
647
- * Hiding vote option can be enabled / disabled by poll creator
648
- = 2.5.0 =
649
- * Added support for multiple selection polls
650
- = 2.4.0 =
651
- * Better support for hiding user votes in the poll
652
- * Improved embed options to support both dynamic and constant width for the polls
653
- * Polls can now be closed from the Opinion-Stage dashboard
654
- = 2.3.0 =
655
- * Improved creation flow of polls
656
- * Added basic report per poll in the Opinion Stage polls dashboard
657
- * Added account report in Opinion-Stage poll dashboard
658
- = 2.2.0 =
659
- * Polls are now localized for Arabic
660
- * Better support for sidebar polls (300px)
661
- * Supporting longer side texts in polls
662
- = 2.1.0 =
663
- * Polls are now displayed properly in mobile environments
664
- * Additional built-in poll themes
665
- * When clicking on poll participants, the user is now redirected to their social network profile
666
- * Polls are now localized for Spanish
667
- * You can now set whether you would like to display the number of votes in the poll
668
- * Support for election polls (e.g. poll results displayed in points, add a minimum cliff, etc)
669
- = 2.0.0 =
670
- * Support for multiple sided polls
671
- * Added the option to configure the URL in which the poll will be hosted. This will allow to direct additional traffic from social network shares and emails back to the location where the poll is hosted
672
- * Added the option to set the order in which the poll results are displayed. You can either set it so that the poll sides are located in the order they were configured or set them so that the side with the most votes is displayed on top
673
- = 1.2.0 =
674
- * Poll width can now be set, supported poll widths are 400-620 pxl
675
- * Poll widget Contact Form Builder optimizations for high traffic polling deployments
676
- * Support customized color themes for the polls
677
- = 1.1.0 =
678
- * Added an optional gender filter to the poll, so that poll results can be viewed by gender
679
- * Added a central dashboard for managing all polls
680
- * Added the option to display a detailed text description of the poll question to the poll widget
681
- * Added the ability to configure which image is shared when sharing the poll or the poll vote on Facebook
682
- = 1.0.1 =
683
- * Improvements in the poll embed flow to ease insertion of polls
684
- = 1.0.0 =
685
- * First social poll version
 
 
1
+ === Poll, Survey, Form & Quiz Maker by OpinionStage ===
2
+ Contributors: OpinionStage.com
3
+ Donate link: https://www.opinionstage.com
4
+ Tags: poll, quiz, survey, form, interactive content
5
+ Requires at least: 2.8
6
+ Tested up to: 5.1
7
+ Stable tag: 19.6.18
8
+
9
+ Add a beautiful & top performing Poll, Survey, Quiz or Form to your site. Create from scratch or use templates. Set it up in Minutes.
10
+
11
+ == Description ==
12
+
13
+ Looking for a Top-Notch Poll, Survey, Form & Quiz Wordpress Plugin?
14
+
15
+ Check out:
16
+
17
+ <a href="https://www.opinionstage.com/poll?o=wp35e8" target="_blank">Poll Maker</a> | <a href="https://www.opinionstage.com/templates?utf8=✓&types%5B%5D=poll&o=wp35e8" target="_blank">Poll Examples</a>
18
+ <a href="https://www.opinionstage.com/quiz?o=wp35e8" target="_blank">Quiz Maker</a> | <a href="https://www.opinionstage.com/templates?utf8=%E2%9C%93&types%5B%5D=personality_quiz&o=wp35e8" target="_blank">Quiz Examples</a>
19
+ <a href="https://www.opinionstage.com/survey?o=wp35e8" target="_blank">Survey Maker</a> | <a href="https://www.opinionstage.com/templates?utf8=%E2%9C%93&types%5B%5D=survey&o=wp35e8" target="_blank">Survey Examples</a>
20
+ <a href="https://www.opinionstage.com/form?o=wp35e8" target="_blank">Form Maker</a> | <a href="https://www.opinionstage.com/templates?utf8=%E2%9C%93&types%5B%5D=form&o=wp35e8" target="_blank">Form Examples</a>
21
+
22
+ = Why use Opinion Stage? =
23
+
24
+ * Boost engagement & traffic - add a poll, survey or quiz to your posts/pages to increases participation, time-on-site & page views. Increase social sharing and viral distribution
25
+ * Gather more qualified leads - integrate a lead form inside the poll, quiz or survey. This will not only produce more leads, but will also produce qualified leads, as the leads will be associated with the answers of the users.
26
+ * Generate revenue - take advantage of the high engagement rates to increase revenue from ads inside and outside of the interactive content.
27
+ * Extract insights - get more insights using interactive polls & surveys designed to maximize participation. Extract actionable insights with a intuitive analytics dashboard.
28
+
29
+ = Main Poll WordPress Plugin Features: =
30
+
31
+ * Create polls with 4 different layouts (standard, image, thumbnails & head-to-head)
32
+ * Easily add images & videos into the polls either from your computer or by using an integrated search poll image function
33
+ * Configure if user can select one or more options when voting on the poll
34
+ * Allow users to add their own answers to the poll
35
+ * Block repeat voting in the poll using different mechanisms (e.g. Cookie, IP, etc)
36
+ * Permit user to vote on the poll once every configured time frame (e.g. every hour, day, etc)
37
+ * Display a customized message to the user after he votes on the poll
38
+ * Configure to close the poll at a specified time
39
+ * Redirect users to different landing pages based on their poll vote
40
+ * Configure the display order of the poll options (e.g. most votes on top, random)
41
+ * Configure if the poll results are displayed before voting, after voting or only to the poll creator
42
+ * Configure how results are displayed to the poll voters (only percentage, number of votes, both, etc)
43
+ * Integrate ads inside the polls to increase ad-revenue from your site
44
+ * Configure webhooks for sending the information gathered from your poll to any 3rd party application
45
+ * Graphic presentations of the poll results including pie & chart bars
46
+ * View a detailed result table of all poll votes (e.g. vote side, vote timestamp, etc)
47
+ * Export the poll results to an xls or csv file
48
+
49
+ = Main Quiz WordPress Plugin Features: =
50
+
51
+ * Create a personality quiz, trivia quiz, score quiz, true/false quiz, assessment quiz, multiple-choice quiz or outcome quiz
52
+ * Integrate images & videos in the quiz from your computer, from a link or using online search capabilities
53
+ * Set the main image that is shared when users share the quiz on social networks
54
+ * Configure to request users to like your facebook page before they view the quiz results
55
+ * Configure the facebook & twitter sharing message that is displayed when users share the quiz
56
+ * Configure webhooks for sending all the information gathered in the quiz to any 3rd party application
57
+ * Integrate ads in the quiz interface to increase your sites ad-revenue potential
58
+ * Add pixel tracking to the quiz to optimize your ad campaigns
59
+ * View high level statistics of your quiz including quiz impressions, quiz starts, quiz completions, average time spend on quiz, # of engagements on the quiz & # of leads generated while users participated in the quiz
60
+ * View the detailed results of each quiz question
61
+ * View a drop-off report that shows the percentage of users that voted in each quiz question
62
+ * View a detailed response report that includes all the details of each quiz submission (e.g. detailed answers, timestamp, etc)
63
+ * Export the quiz results to a xls or csv file
64
+ * Detailed logic of personality quizzes, including a scoring system for sides and formula for calculating the quiz outcome
65
+ * Detailed logic for trivia quizzes, including setting the correct answers, displaying explanations after selecting answers, calculating the results and various quiz result display options
66
+ * Support for randomizing answers in each quiz question to improve validity of results
67
+ * Support for call-to-action buttons at the end of the quiz
68
+ * Support sending to different landing pages based on the quiz outcome
69
+
70
+ = Main Survey WordPress Plugin Features: =
71
+
72
+ * Integrate images & videos to make the survey appealing & engaging. You can either upload images from your computer or use online search to locate free-to-use images
73
+ * Support both single selection and multiple selection questions and supports allowing users to add their own answer
74
+ * Support open ended questions of different types
75
+ * Supports informative cards that can be displayed inside the survey
76
+ * Supports a call-to-action action at the end of the survey
77
+ * Supports branch logic that lets you determine which question is asked next based on the answer to the last question
78
+ * Supports setting variables that can be set based on answers of users (for example saving their name to use in following questions)
79
+ * Supports social integrations, such as adding a social sharing bar, integrations with facebook like box and facebook comments and twitter message customization
80
+ * Supports sending submissions via email to the survey creator
81
+ * Supports webhooks for sending all the gathered information to a 3rd party tool
82
+ * Naive integrations with mailchimp & hubspot
83
+ * Integration with pixels to optimize ad-campaigns focused on getting relevant audience to the survey
84
+ * Overview statistics that include number of views, starts, completions, # of engagement, average time on survey and # of leads gathered
85
+ * Detailed response table, each response with all the answers and meta data such as timestamp of submission
86
+ * Graphic display (pie chart & bar chart) of answers to each one of the questions
87
+ * Drop off report to help optimize the survey for maximum completion rates
88
+
89
+ = Main Form WordPress Plugin Features: =
90
+
91
+ * Supports Short & long text fields
92
+ * Supports Email fields including 2 approval checkboxes
93
+ * Support phone number field
94
+ * Supports drop-down field
95
+ * Configure to send an email to form creator on each submission
96
+ * Support sending all the gathered information to a 3rd party application using webhooks
97
+ * Supports native integrations with mailchimp and hubspot
98
+ * View statistics on # of views vs. # of submissions
99
+ * View all submissions including the all field entries and meta data such as timestamp of submission
100
+
101
+ = Placements: =
102
+
103
+ * Sidebar placement - add to the site sidebar using a dedicated Opinion Stage sidebar widget
104
+ * Popup placement - popup when users enter or exit your site using a highly configurable popup component
105
+ * Articles placement - display at the end of all your posts/pages
106
+
107
+ = Language support =
108
+
109
+ Opinion Stage supports over 42 languages, missing a language? Let us know!
110
+
111
+ = About Opinion Stage: =
112
+
113
+ Opinion Stage is a powerful & easy-to-use interactive content (e.g. poll, quiz, survey, forms, etc) creation service. Opinion Stages' highly engaging content formats are used to boost engagement, gather leads, generate revenue and to extract actionable insights. Opinion Stage works with 100,000+ publishers, brands & agenencies, including world-leading publishers, brands & agencies. For more details, visit <a href="https://www.opinionstage.com?o=wp35e8" target="_blank">the Opinion Stage site.</a>
114
+
115
+ == Installation ==
116
+
117
+ 1. Upload the "Poll, Survey, Form & Quiz Maker" plugin to your blog (or search for it) and then install the plugin on your plugins page
118
+ 2. Active it and start creating polls, quizzes, surveys and forms
119
+
120
+ == Frequently Asked Questions ==
121
+
122
+ = Is Opinion Stage content responsive? =
123
+
124
+ Yes, all content (e.g. poll, quiz, survey, form, etc) created with Opinion Stage is fully responsive, and designed to optimaly display on mobile, tablet and desktop
125
+
126
+ = What interactive content formats does Opinion Stage support? =
127
+
128
+ With Opinion Stage you can create the following content formats: Poll, Poll Sets, Personality Quiz, Trivia Quiz, Survey, Slideshow, Form, Story Article, List. We are constantly adding additional interactive content formats so stay tuned!
129
+
130
+ = What is the difference between a Poll and a Survey =
131
+
132
+ Polls include one question and are used for getting a quick answer on a question. Polls are often used for gathering opinions, getting feedback, running contents & competitions and generating engagement. Surveys include multiple questions of different types. Surveys are often used to gather feedback and insights. If you are still unsure whether to use a poll or a survey, contact our support team and we'll be happy to help.
133
+
134
+ = What customization options do you offer? =
135
+
136
+ Opinion Stage offers many built-in customization options such as selecting the color theme, font and sizes. You can also use a CSS override feature to fully match the items to your brand. You can also white label the items and add your own logo.
137
+
138
+
139
+ == Other Notes ==
140
+
141
+ == Screenshots ==
142
+
143
+ 1. **Poll image layout** - example of integrating images in the poll answers to make it more appealing, which results with improved engagement rates.
144
+ 2. **Poll standard layout** - the poll include a lot of features including, selecting if users can select one side or more in the poll, allowing users to add their own answer to the poll, different methods of organizing the poll side order, setting the poll color, setting the poll font, preventing repeat voting in the poll, voting with a social profile in the poll, setting the poll result display, setting an expiry date for the poll, alignment of the poll title, setting the poll width, setting poll sharing bar, and much more
145
+ 3. **poll head to head layout** - example of a head-to-head layout poll
146
+ 4. **Trivia quiz** - example of a Trivia quiz result. Set the correct answer in each of the quiz questions, and following users answers to the quiz, give them a quiz result with the number of correct quiz answers. Trivia quizzes are one of the most engaging type of content.
147
+ 5. **Personality quiz** - example of a personality quiz. Using a personality quiz, you can ask you users different quiz questions, and based on their answers to the quiz questions, offer them different quiz results. Personality quizzes tend to be viral as they produce a lot of social shares.
148
+ 6. **Content creation dashboard** - example of the Opinion Stage interactive content (e.g. poll, quiz, survey, form) creation dashboard
149
+ 7. **Lead form** - example of gathering quality leads while users participate in the polls, quizzes & surveys
150
+ 8. **Report** - example of a poll report screen that includes advanced analysis of results
151
+ 9. **Templates** - dashboard that includes highly effective examples that can be duplicated to your account
152
+ 10. **Popup placement** - display your content in an exit/enter, center/side screen popup
153
+
154
+ == Upgrade Notice ==
155
+
156
+ N/A
157
+
158
+ == Changelog ==
159
+ = 19.6.18 =
160
+ * bugfixes
161
+ = 19.6.17 =
162
+ * UI looks & feel revamp
163
+ = 19.6.16 =
164
+ * Support 5.1 and Readme updates
165
+ = 19.6.15 =
166
+ * Gutenberg fixes and improvements
167
+ = 19.6.14 =
168
+ * Gutenberg fix
169
+ = 19.6.13 =
170
+ * My Items page
171
+ * updated Content Popup
172
+ * Design update
173
+ = 19.6.12 =
174
+ * readme update
175
+ = 19.6.11 =
176
+ * readme update
177
+ * analytics setup
178
+ = 19.6.10 =
179
+ * navigation links update
180
+ = 19.6.9 =
181
+ * add support for new editor Gutenberg
182
+ = 19.6.8 =
183
+ * readme changes
184
+ * add admin loader
185
+ = 19.6.7 =
186
+ * new getting started experience
187
+ = 19.6.6 =
188
+ * WordPress 5.0 compatibility
189
+ * Readme update
190
+ = 19.6.5 =
191
+ * Assets loading fix
192
+ * Readme update
193
+ = 19.6.4 =
194
+ * Permission fix on sub pages
195
+ = 19.6.3 =
196
+ * Icon set fix
197
+ = 19.6.2 =
198
+ * Double page bug fix
199
+ * Plugin renamed
200
+ = 19.6.1 =
201
+ * Plugin rename: improved fix
202
+ = 19.6.0 =
203
+ * Plugin filename fix
204
+ * Backward Compatibility added
205
+ = 19.5.0 =
206
+ * New navigation added
207
+ * Fixed placements issue
208
+ = 19.4.2 =
209
+ * better AJAX handling
210
+ = 19.4.1 =
211
+ * fix deactivation issue
212
+ = 19.4.0 =
213
+ * stability fixes
214
+ * added deactivate screen
215
+ = 19.3.5 =
216
+ * more updates to readme.txt file
217
+ = 19.3.4 =
218
+ * rename plugin
219
+ * update to readme.txt file
220
+ * small text changes
221
+ = 19.3.3 =
222
+ * small text changes
223
+ = 19.3.2 =
224
+ * readme update
225
+ = 19.3.1 =
226
+ * readme update
227
+ = 19.3.0 =
228
+ * add Story support
229
+ = 19.2.7 =
230
+ * fix PHP installations older than 5.4
231
+ = 19.2.6 =
232
+ * fix links to content
233
+ = 19.2.5 =
234
+ * minor text updates
235
+ = 19.2.4 =
236
+ * tested up to 4.9 WordPress version
237
+ * Minor textual changes
238
+ = 19.2.3 =
239
+ * fix content popup video placing issue
240
+ = 19.2.2 =
241
+ * adds video intro
242
+ = 19.2.1 =
243
+ * adds ability to sign in from content popup
244
+ * various UI/UX issues fixes
245
+ = 19.2.0 =
246
+ * content popup UI/UX improvements
247
+ * login/logout UI/UX
248
+ = 19.1.0 =
249
+ * content popup UI/UX improvements
250
+ = 19.0.2 =
251
+ * Minor textual changes
252
+ = 19.0.1 =
253
+ * Minor logging changes
254
+ = 19.0.0 =
255
+ * New feature: post editor integration
256
+ = 18.2.1 =
257
+ * Minor changes
258
+ = 18.2.0 =
259
+ * Support for 4.8 WP version
260
+ = 18.1.0 =
261
+ * Minor styling fixes
262
+ * Widgets embedding refactor
263
+ = 18.0.5 =
264
+ * sidebar widget fix
265
+ = 18.0.4 =
266
+ * prevent internal font icon leak into site area
267
+ = 18.0.3 =
268
+ * Minor fixes
269
+ = 18.0.2 =
270
+ * Fix sidebar widget settings style
271
+ * Add SlideShow
272
+ * Fix ContactForm icon
273
+ * Fix video tutorials help link
274
+ = 18.0.1 =
275
+ * Fix menu page styling
276
+ = 18.0.0 =
277
+ * Add a slider content format
278
+ = 17.9.0 =
279
+ * Additional survey features based on client requests
280
+ = 17.8.0 =
281
+ * Improvements of quiz/survey reporting
282
+ * Various minor bug fixes
283
+ = 17.7.0 =
284
+ * Responses table improvements, language fixes, advanced editing in after vote notifications
285
+ = 17.6.0 =
286
+ * Various fixes & optimizations
287
+ = 17.5.0 =
288
+ * Display comment after user votes
289
+ * Additional advanced reports
290
+ = 17.4.0 =
291
+ * Add new charts to the poll, quiz & survey reports
292
+ = 17.3.0 =
293
+ * Display an explanation after voting in polls
294
+ * Fixed bug with IP blocking
295
+ = 17.2.0 =
296
+ * New drop-off report
297
+ * Async sending of leads
298
+ = 17.1.0 =
299
+ * Add CSS override to all content types
300
+ * Support GTM integrations
301
+ = 17.0.0 =
302
+ * Improved quiz/survey reporting capabilities
303
+ = 16.9.0 =
304
+ * Added support for pixel tracking
305
+ = 16.8.0 =
306
+ * Support for WordPress 4.7
307
+ = 16.7.0 =
308
+ * Improve support for high volume lead configurations
309
+ = 16.6.0 =
310
+ * Text changes and bug fixes
311
+ = 16.5.0 =
312
+ * Various minor fixes & optimizations
313
+ = 16.4.0 =
314
+ * Added ad refresh mechanism
315
+ = 16.3.0 =
316
+ * Added verification for the placements ids in the connection callback function
317
+ = 16.2.0 =
318
+ * Various minor improvements & bug fixes
319
+ = 16.1.0 =
320
+ * Added chatbot tool integration
321
+ = 16.0.0 =
322
+ * Updated help for new features
323
+ = 15.9.0 =
324
+ * Rebranded Quiz name to Outcome, removed the section entry
325
+ = 15.8.0 =
326
+ * Resolved an issue with the font
327
+ = 15.7.0 =
328
+ * Added support for creating Contact Form Builders, added to plugin name
329
+ = 15.6.0 =
330
+ * Added support for creating surveys, renamed plugin
331
+ = 15.5.0 =
332
+ * Support WP 4.5
333
+ = 15.4.0 =
334
+ * Added the option to add a content section
335
+ = 15.3.0 =
336
+ * Modified API path
337
+ = 15.2.0 =
338
+ * Various optimizations
339
+ = 15.1.0 =
340
+ * Security fix to limit accses to dashboard
341
+ = 15.0.0 =
342
+ * Various optimizations
343
+ = 14.9.0 =
344
+ * Added the option to embed using a fixed width
345
+ = 14.8.0 =
346
+ * Modified sidebar widget management UI
347
+ * Replaced dashboard top navigation links with more prominent 'my content' link
348
+ * Added 'list' to the plugin name
349
+ = 14.7.0 =
350
+ * Various small optimizations
351
+ = 14.6.0 =
352
+ * Various UI modifications - added top navigation links, dashboard UI is now more responsive.
353
+ = 14.5.0 =
354
+ * Renamed style to avoid css caching issues
355
+ = 14.4.0 =
356
+ * Complete ui revamp
357
+ * Removed obsolete polls insertion popup and tinymce integration
358
+ * Handling compatibility issues with other plugin
359
+ = 14.3.0 =
360
+ * Various Poll, Survey, Quiz, Slideshow, Form & Story Article improvements
361
+ = 14.2.0 =
362
+ * Not showing recommendations by default when embedding Trivia quiz and Personality quiz via the widget shortcode
363
+ = 14.1.0 =
364
+ * Added support for disabling FB comments, sharing buttons and recommendations for Trivia quiz and Personality quiz via the widget shortcode
365
+ = 14.0.0 =
366
+ * Improved polls & quizzes creation help file
367
+ * Various small issues
368
+ = 13.9.0 =
369
+ * Added creation links for trivia quiz, personality quiz and lists
370
+ * Added a link for content discovery
371
+ = 13.8.0 =
372
+ * Support creating a quiz draft
373
+ * Added quiz tips and quiz best practices
374
+ = 13.7.0 =
375
+ * Better name for widget following feedback
376
+ = 13.6.0 =
377
+ * Added personality quizzes
378
+ = 13.5.0 =
379
+ * Renamed plugin to better reflect the Contact Form Builder
380
+ = 13.4.0 =
381
+ * Added shortcodes for trivia and personality quizzes
382
+ = 13.3.0 =
383
+ * Various Trivia Quiz enhancements & fixes
384
+ * Support for iframe embeds
385
+ = 13.2.0 =
386
+ * Support for Basque & Vietnamese languages
387
+ * Trivia Quiz beta
388
+ = 13.1.0 =
389
+ * Added support for quick addition of any language
390
+ = 13.0.0 =
391
+ * Added text domain
392
+ = 12.9.0 =
393
+ * Poll discovery mechanism improvements
394
+ * Additional tracking capabilities
395
+ = 12.8.0 =
396
+ * Various bug fixes
397
+ = 12.7.0 =
398
+ * CSS modifications to better align with desired coding standards. Reverted css file name change.
399
+ * Minor text changes
400
+ * Not using PHP 4 Style Constructors any more
401
+ = 12.6.0 =
402
+ * Fixed broken links to dashboard
403
+ * Renamed css file
404
+ = 12.5.0 =
405
+ * Modified css structure
406
+ * Added an option to enable/disable sidebar widget directly via the widget box
407
+ = 12.4.0 =
408
+ * Added a control switch for the Sidebar placement
409
+ = 12.3.0 =
410
+ * Added Sidebar placement as a widget
411
+ = 12.2.0 =
412
+ * Added the option to connect the plugin to Opinion Stage account
413
+ * Added plug & play integration for fly-out placement
414
+ * Replaced the option of adding polls to all posts with plug & play article section placement
415
+ = 12.1.0 =
416
+ * Additional fix for supporting SSL
417
+ = 12.0.0 =
418
+ * Support for SSL when voting with social profiles
419
+ * revamp of content recommendation mechanism
420
+ = 11.9.0 =
421
+ * Poll Placement improvements
422
+ = 11.8.0 =
423
+ * Plugin minor changes
424
+ = 11.7.0 =
425
+ * Image cropping
426
+ = 11.6.0 =
427
+ * New poll recommendation design
428
+ = 11.5.0 =
429
+ * resolve conflicts
430
+ = 11.4.0 =
431
+ * Fixed compatibility issues
432
+ = 11.3.0 =
433
+ * First Trivia poll Poll, Survey, Quiz, Slideshow, Form & Story Article Version
434
+ = 11.2.0 =
435
+ * Various functionality & usability improvements
436
+ = 11.1.0 =
437
+ * Head-to-Head Poll - new revamped UI (first Poll, Survey, Quiz, Slideshow, Form & Story Article Version)
438
+ = 11.0.0 =
439
+ * New look & feel settings
440
+ = 10.9.0 =
441
+ * Allow disabling global poll section for specific posts
442
+ = 10.8.0 =
443
+ * Texts changes
444
+ = 10.7.0 =
445
+ * New options for adding polls or sets to all posts
446
+ = 10.6.0 =
447
+ * Poll sets and poll placements - improved interface
448
+ = 10.5.0 =
449
+ * Ad integrations (optional) - revamped interface
450
+ = 10.4.0 =
451
+ * Added UI support for social logins
452
+ = 10.3.0 =
453
+ * New UI for Multiple Choice Polls
454
+ = 10.2.0 =
455
+ * Various stability fixes
456
+ = 10.1.0 =
457
+ * Post vote actions
458
+ = 10.0.0 =
459
+ * Contact Form Builder improvements
460
+ = 9.9.0 =
461
+ * Various fixes
462
+ = 9.8.0 =
463
+ * Poll discovery first Poll, Survey, Quiz, Slideshow, Form & Story Article Version
464
+ = 9.7.0 =
465
+ * Placements first Poll, Survey, Quiz, Slideshow, Form & Story Article Version
466
+ = 9.6.0 =
467
+ * Various fixes
468
+ = 9.5.0 =
469
+ * Smart containers first Poll, Survey, Quiz, Slideshow, Form & Story Article Version
470
+ = 9.4.0 =
471
+ * Allow users to add their own answers
472
+ * Head2Head polls - mobile optimizations
473
+ = 9.3.0 =
474
+ * Support adding custom texts to the interface
475
+ * Solve minor UI issues
476
+ = 9.2.0 =
477
+ * Support displaying ads before showing the results
478
+ * Support reordering the sides of the poll
479
+ = 9.1.0 =
480
+ * Added the option to add Facebook comments to the polls
481
+ * Improvements to poll creation flow
482
+ = 9.0.0 =
483
+ * New poll head-to-head themes
484
+ * Poll UI optimizations
485
+ = 8.9.0 =
486
+ * Various additions and improvements to the poll style studio
487
+ * Support for wide pages
488
+ = 8.8.0 =
489
+ * Improved poll built-in UI styles
490
+ * New capabilities to poll style studio
491
+ = 8.7.0 =
492
+ * Improved poll reports
493
+ * Various minor improvements
494
+ = 8.6.0 =
495
+ * Poll perContact Form Builderance improvements for peek scenarios
496
+ * New banner type ad unit
497
+ = 8.5.0 =
498
+ * Improve process of adding polls to site
499
+ * Improve returning traffic tracking mechanism
500
+ = 8.4.0 =
501
+ * Add first of poll discovery feature
502
+ * Resolve issue with image addition
503
+ = 8.3.0 =
504
+ * Add the option to integrate advertisement into the polls for generating revenue
505
+ * Optimizations for poll display in mobile environments
506
+ = 8.2.0 =
507
+ * Enhancements on contact generation feature
508
+ * Mobile polls improvements
509
+ * Additions to default poll settings
510
+ = 8.1.0 =
511
+ * Poll discovery - first Poll, Survey, Quiz, Slideshow, Form & Story Article Version
512
+ * Poll sets improvements
513
+ * Poll perContact Form Builderance improvements
514
+ = 8.0.0 =
515
+ * Added an account report dashboard
516
+ = 7.9.0 =
517
+ * Resolved paypal integration issues
518
+ * Resolved facebook page integration issues
519
+ = 7.8.0 =
520
+ * Renamed plugin to better reflect the Contact Form Builder
521
+ = 7.7.0 =
522
+ * Fixed 2 poll display issues
523
+ = 7.6.0 =
524
+ * Added the ability to insert a shortcode of a set of polls
525
+ * Added a widget for a container and for a set of polls
526
+ = 7.5.0 =
527
+ * Created a widget for easily adding polls to site
528
+ = 7.4.0 =
529
+ * Poll Contact Form Builder optimizations
530
+ = 7.3.0 =
531
+ * Resolved 2 issues with polls on mobile
532
+ = 7.2.0 =
533
+ * Add external integration with 3rd parties via API/XML mechanism
534
+ = 7.1.0 =
535
+ * Support collecting emails from poll voters
536
+ = 7.0.0 =
537
+ * Fixed potential collisions with other plugins
538
+ = 6.9.0 =
539
+ * First of Poll Sets
540
+ * First of redirect after poll vote
541
+ * Fix related to languages in poll display
542
+ = 6.8.0 =
543
+ * Fix issue with Mobile voting
544
+ * Fix for iframe embed of poll
545
+ * Fix for uploading images from computer
546
+ = 6.7.0 =
547
+ * Added Czech language & fix for Polish
548
+ * Add poll images via URL
549
+ = 6.6.0 =
550
+ * Improve poll login screen in mobile
551
+ * Fixes for poll container
552
+ = 6.5.0 =
553
+ * Fix issues with voting on iphone/ipad (iOS7)
554
+ = 6.4.0 =
555
+ * New poll container
556
+ * Improvements to the poll optimization dashboard
557
+ = 6.3.0 =
558
+ * New graphs for the new reports page
559
+ * New languages - Romanian, Polish, Indonesian, Danish
560
+ = 6.2.0 =
561
+ * New Poll navigation bar
562
+ * New languages - Dutch, Albanian, Lithuanian
563
+ = 6.1.0 =
564
+ * New dashboard and site header
565
+ * Poll was translated to the following languages - Swedish, Turkish, Chinese, Japanese, Korean
566
+ = 6.0.0 =
567
+ * Added the option to login to Opinion Stage with a email/user-name and password combination
568
+ = 5.9.0 =
569
+ * Added geographic location filter to poll results dashboard
570
+ = 5.8.0 =
571
+ * Added time filter to poll results dashboard
572
+ * New design for on site poll page
573
+ * Various improvements & fixes on poll results dashboard
574
+ = 5.7.0 =
575
+ * Added the option to block repeat voting in polls by IP
576
+ = 5.6.0 =
577
+ * Improvements & fixes on poll studio
578
+ = 5.5.0 =
579
+ * Improvements & fixes on poll reporting statistics
580
+ * Improvements & fixes on poll core flows
581
+ = 5.4.0 =
582
+ * Added to the poll results screen the following poll stats: poll engagement stats, poll social stats & poll traffic stats
583
+ = 5.3.0 =
584
+ * Add a clone function that allows to easily create multiple polls from the same template
585
+ * Add the option to schedule when the poll will be closed
586
+ = 5.2.0 =
587
+ * Revamp of the poll social sharing settings
588
+ * revamp of add poll to website screen
589
+ = 5.1.0 =
590
+ * Add Facebook comments to polls added to Facebook pages
591
+ * Add the option to preview the poll in different widths
592
+ = 5.0.0 =
593
+ * Improvements to poll style studio
594
+ * Added option to configure head to head polls not to show results before voting
595
+ * Added the option to configure all types of polls not to show results to voters
596
+ * Extended width support of head to head polls to 250-740 pxls
597
+ = 4.7.1 =
598
+ * Additional social filters added to the poll interface & poll report
599
+ * Optimize poll sharing scenarios
600
+ = 4.7.0 =
601
+ * Improvements on poll sharing scenarios
602
+ = 4.6.0 =
603
+ * Add polls to Facebook pages in 2-clicks feature added
604
+ * Enhanced poll reporting that includes poll result filters
605
+ * Brightcove video Contact Form Builderat now supported in the polls
606
+ = 4.5.5 =
607
+ * Added support for Google+ poll login
608
+ * Fixed a presentation issue with polls and https sites
609
+ * Fixed issue with poll display on Facebook pages
610
+ = 4.5.0 =
611
+ * Localize polls for Russian and French
612
+ * New design for poll social login dialogue
613
+ * Polls now auto-detect https environments
614
+ * Various minor fixes and improvements to poll functionality
615
+ = 4.4.0 =
616
+ * Polls are now localized for Portuguese
617
+ * Various minor bug fixes
618
+ = 4.3.0 =
619
+ * Multiple sided polls are supported for 150 widths and above
620
+ * Head-to-head polls are supported for 300 widths and above
621
+ * Poll style studio was improved to included many more poll style options
622
+ * New improved poll dashboard
623
+ * Poll showcase was improved to include more poll examples and detailed explanations
624
+ = 4.2.0 =
625
+ * Multi-sided polls support addition of multimedia (video and image)
626
+ * Both head-to-head and multi-sided polls - Multimedia support auto-fit for different width (e.g mobile environment)
627
+ = 4.1.0 =
628
+ * Multi-sided polls support addition of multimedia (video and image)
629
+ * Both head-to-head and multi-sided polls - Multimedia support auto-fit for different width (e.g mobile environment)
630
+ = 4.0.0 =
631
+ * UI improvements for the polls (filters, border etc)
632
+ = 3.1.0 =
633
+ * Poll creator can select number of allowed poll answers
634
+ * FB poll sharing flow optimizations
635
+ * Poll results can be shown from the Opinion-Stage poll dashboard
636
+ = 3.0.0 =
637
+ * New hybrid voting method added to the polls, allowing users to vote either via a social profile or completely anonymously
638
+ = 2.9.0 =
639
+ * Added support for anonymous poll voting
640
+ = 2.8.0 =
641
+ * Improved editing process of polls by adding a preview to the poll editing screen
642
+ * Additional layout customizations for polls - hide top bars, add bottom padding
643
+ * Polls can now be reset
644
+ = 2.7.0 =
645
+ * Additional poll languages support (German, Italian, Serbian)
646
+ * Additional poll customizations for the vote sharing process
647
+ = 2.6.0 =
648
+ * Additional customizations options to the poll: Define which poll filters to show, poll social sharing bar removal
649
+ * Hiding vote option can be enabled / disabled by poll creator
650
+ = 2.5.0 =
651
+ * Added support for multiple selection polls
652
+ = 2.4.0 =
653
+ * Better support for hiding user votes in the poll
654
+ * Improved embed options to support both dynamic and constant width for the polls
655
+ * Polls can now be closed from the Opinion-Stage dashboard
656
+ = 2.3.0 =
657
+ * Improved creation flow of polls
658
+ * Added basic report per poll in the Opinion Stage polls dashboard
659
+ * Added account report in Opinion-Stage poll dashboard
660
+ = 2.2.0 =
661
+ * Polls are now localized for Arabic
662
+ * Better support for sidebar polls (300px)
663
+ * Supporting longer side texts in polls
664
+ = 2.1.0 =
665
+ * Polls are now displayed properly in mobile environments
666
+ * Additional built-in poll themes
667
+ * When clicking on poll participants, the user is now redirected to their social network profile
668
+ * Polls are now localized for Spanish
669
+ * You can now set whether you would like to display the number of votes in the poll
670
+ * Support for election polls (e.g. poll results displayed in points, add a minimum cliff, etc)
671
+ = 2.0.0 =
672
+ * Support for multiple sided polls
673
+ * Added the option to configure the URL in which the poll will be hosted. This will allow to direct additional traffic from social network shares and emails back to the location where the poll is hosted
674
+ * Added the option to set the order in which the poll results are displayed. You can either set it so that the poll sides are located in the order they were configured or set them so that the side with the most votes is displayed on top
675
+ = 1.2.0 =
676
+ * Poll width can now be set, supported poll widths are 400-620 pxl
677
+ * Poll widget Contact Form Builder optimizations for high traffic polling deployments
678
+ * Support customized color themes for the polls
679
+ = 1.1.0 =
680
+ * Added an optional gender filter to the poll, so that poll results can be viewed by gender
681
+ * Added a central dashboard for managing all polls
682
+ * Added the option to display a detailed text description of the poll question to the poll widget
683
+ * Added the ability to configure which image is shared when sharing the poll or the poll vote on Facebook
684
+ = 1.0.1 =
685
+ * Improvements in the poll embed flow to ease insertion of polls
686
+ = 1.0.0 =
687
+ * First social poll version