Plugin Directory

Changeset 1700548


Ignore:
Timestamp:
07/21/2017 06:16:31 PM (9 years ago)
Author:
stackcommerce
Message:

Release 1.2.1

Location:
stackcommerce-connect/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • stackcommerce-connect/trunk/dist/scripts/stackcommerce-wp.min.js

    r1697716 r1700548  
    1 "use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,t){for(var c=0;c<t.length;c++){var a=t[c];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,c,a){return c&&e(t.prototype,c),a&&e(t,a),t}}();jQuery(document).ready(function(){var e=new StackCommerce_WP;e.updateForm(),e.categories(),e.tags(),document.querySelector("#stackcommerce-wp-form-submit").addEventListener("click",e.notify.bind(e)),jQuery("form.stackcommerce-wp-form").keypress(e.performKeycheck.bind(e)),jQuery('input[name="stackcommerce_wp_content_integration[]"]').change(e.updateForm.bind(e))});var StackCommerce_WP=function(){function e(){_classCallCheck(this,e),this.$endpoint=this.getValue("#stackcommerce_wp_cms_api_endpoint"),this.$form=document.querySelector("#stackcommerce-wp-form"),this.$submit_button=document.querySelector("#stackcommerce-wp-form-submit")}return _createClass(e,[{key:"notify",value:function(){var e=this,t=this.getValue("#stackcommerce_wp_account_id"),c=this.getValue("#stackcommerce_wp_secret");this.setConnectionStatus("connecting"),jQuery.ajax({method:"PUT",url:this.$endpoint+"/api/wordpress/?id="+t+"&secret="+c,processData:!1,contentType:"application/json",dataType:"json",data:JSON.stringify(this.generatePayload())}).done(function(){e.setConnectionStatus("connected"),e.$form.submit()}).fail(function(){e.setConnectionStatus("disconnected")})}},{key:"generatePayload",value:function(){return{data:{type:"partner_wordpress_settings",id:this.getValue("#stackcommerce_wp_account_id"),attributes:{installed:!0,wordpress_url:this.getValue("#stackcommerce_wp_endpoint"),author_id:this.getValue("#stackcommerce_wp_author"),post_status:this.getValue("#stackcommerce_wp_post_status"),categories:this.getSelect2Values("#stackcommerce_wp_categories",[]),tags:this.getSelect2Values("#stackcommerce_wp_tags",[]),featured_image:this.getValue("#stackcommerce_wp_featured_image")}}}}},{key:"setConnectionStatus",value:function(e){this.setValue("#stackcommerce_wp_connection_status",e),this.updateForm()}},{key:"updateForm",value:function(){var e=document.querySelector("#stackcommerce-wp-form"),t=document.querySelector("#stackcommerce-wp-form-submit"),c=this.getValue("#stackcommerce_wp_connection_status"),a=this.getValue('input[name="stackcommerce_wp_content_integration[]"]:checked');e.setAttribute("data-stackcommerce-wp-status",c),e.setAttribute("data-stackcommerce-wp-content-integration","true"==a),"connecting"===c?t.setAttribute("disabled","disabled"):t.removeAttribute("disabled")}},{key:"performKeycheck",value:function(e){if(13==e.which)return this.notify(),!1}},{key:"taxonomySearch",value:function(e){jQuery(e.selector).select2({ajax:{type:"POST",url:window.ajaxurl,dataType:"json",delay:250,data:function(t){return{action:"sc_api_search",taxonomy:e.taxonomy,q:t.term}},processResults:function(t){return{results:e.results.split(".").reduce(function(e,t){return e[t]},t)}},cache:!0},escapeMarkup:function(e){return e},minimumInputLength:3})}},{key:"categories",value:function(){var e={selector:"#stackcommerce_wp_categories",taxonomy:"categories",results:"data.categories"};this.taxonomySearch(e)}},{key:"tags",value:function(){var e={selector:"#stackcommerce_wp_tags",taxonomy:"tags",results:"data.tags"};this.taxonomySearch(e)}},{key:"getValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",c=document.querySelector(e).value;return c||t}},{key:"getSelect2Values",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],c=jQuery(e).select2("val");return c||t}},{key:"setValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";document.querySelector(e).value=t}}]),e}();
     1"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,t){for(var c=0;c<t.length;c++){var a=t[c];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,c,a){return c&&e(t.prototype,c),a&&e(t,a),t}}();jQuery(document).ready(function(){if(document.querySelector(".stackcommerce-wp-form")){var e=new StackCommerce_WP;e.updateForm(),e.categories(),e.tags(),document.querySelector("#stackcommerce-wp-form-submit").addEventListener("click",e.notify.bind(e)),jQuery("form.stackcommerce-wp-form").keypress(e.performKeycheck.bind(e)),jQuery('input[name="stackcommerce_wp_content_integration[]"]').change(e.updateForm.bind(e))}});var StackCommerce_WP=function(){function e(){_classCallCheck(this,e),this.$endpoint=this.getValue("#stackcommerce_wp_cms_api_endpoint"),this.$form=document.querySelector("#stackcommerce-wp-form"),this.$submit_button=document.querySelector("#stackcommerce-wp-form-submit")}return _createClass(e,[{key:"notify",value:function(){var e=this,t=this.getValue("#stackcommerce_wp_account_id"),c=this.getValue("#stackcommerce_wp_secret");this.setConnectionStatus("connecting"),jQuery.ajax({method:"PUT",url:this.$endpoint+"/api/wordpress/?id="+t+"&secret="+c,processData:!1,contentType:"application/json",dataType:"json",data:JSON.stringify(this.generatePayload())}).done(function(){e.setConnectionStatus("connected"),e.$form.submit()}).fail(function(){e.setConnectionStatus("disconnected")})}},{key:"generatePayload",value:function(){return{data:{type:"partner_wordpress_settings",id:this.getValue("#stackcommerce_wp_account_id"),attributes:{installed:!0,wordpress_url:this.getValue("#stackcommerce_wp_endpoint"),author_id:this.getValue("#stackcommerce_wp_author"),post_status:this.getValue("#stackcommerce_wp_post_status"),categories:this.getSelect2Values("#stackcommerce_wp_categories",[]),tags:this.getSelect2Values("#stackcommerce_wp_tags",[]),featured_image:this.getValue("#stackcommerce_wp_featured_image")}}}}},{key:"setConnectionStatus",value:function(e){this.setValue("#stackcommerce_wp_connection_status",e),this.updateForm()}},{key:"updateForm",value:function(){var e=document.querySelector("#stackcommerce-wp-form"),t=document.querySelector("#stackcommerce-wp-form-submit"),c=this.getValue("#stackcommerce_wp_connection_status"),a=this.getValue('input[name="stackcommerce_wp_content_integration[]"]:checked');e.setAttribute("data-stackcommerce-wp-status",c),e.setAttribute("data-stackcommerce-wp-content-integration","true"==a),"connecting"===c?t.setAttribute("disabled","disabled"):t.removeAttribute("disabled")}},{key:"performKeycheck",value:function(e){if(13==e.which)return this.notify(),!1}},{key:"taxonomySearch",value:function(e){jQuery(e.selector).select2({ajax:{type:"POST",url:window.ajaxurl,dataType:"json",delay:250,data:function(t){return{action:"sc_api_search",taxonomy:e.taxonomy,q:t.term}},processResults:function(t){return{results:e.results.split(".").reduce(function(e,t){return e[t]},t)}},cache:!0},escapeMarkup:function(e){return e},minimumInputLength:3})}},{key:"categories",value:function(){var e={selector:"#stackcommerce_wp_categories",taxonomy:"categories",results:"data.categories"};this.taxonomySearch(e)}},{key:"tags",value:function(){var e={selector:"#stackcommerce_wp_tags",taxonomy:"tags",results:"data.tags"};this.taxonomySearch(e)}},{key:"getValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",c=document.querySelector(e).value;return c||t}},{key:"getSelect2Values",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],c=jQuery(e).select2("val");return c||t}},{key:"setValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";document.querySelector(e).value=t}}]),e}();
    22//# sourceMappingURL=stackcommerce-wp.min.js.map
  • stackcommerce-connect/trunk/dist/scripts/stackcommerce-wp.min.js.map

    r1697716 r1700548  
    1 {"version":3,"sources":["stackcommerce-wp.js"],"names":["jQuery","document","ready","sc_connect","StackCommerce_WP","updateForm","categories","tags","querySelector","addEventListener","notify","bind","keypress","performKeycheck","change","_classCallCheck","this","$endpoint","getValue","$form","$submit_button","_createClass","key","value","_this","$account_id","$secret_key","setConnectionStatus","ajax","method","url","processData","contentType","dataType","data","JSON","stringify","generatePayload","done","submit","fail","type","id","attributes","installed","wordpress_url","author_id","post_status","getSelect2Values","featured_image","status","setValue","$connection_status","$content_integration","setAttribute","removeAttribute","e","which","options","selector","select2","window","ajaxurl","delay","params","action","taxonomy","q","term","processResults","results","split","reduce","_data","cache","escapeMarkup","markup","minimumInputLength","taxonomySearch","$selector","default_value","arguments","length","undefined"],"mappings":"6XAAAA,OAAOC,UAAUC,MAAM,WACrB,IAAIC,EAAa,IAAIC,iBAErBD,EAAWE,aACXF,EAAWG,aACXH,EAAWI,OAEUN,SAASO,cAAc,iCAE7BC,iBAAiB,QAASN,EAAWO,OAAOC,KAAKR,IAEhEH,OAAO,8BAA8BY,SAAST,EAAWU,gBAAgBF,KAAKR,IAC9EH,OAAO,wDAAwDc,OAAOX,EAAWE,WAAWM,KAAKR,MAZnG,IAeMC,iBAAAA,WACJ,SAAAA,IAAcW,gBAAAC,KAAAZ,GACZY,KAAKC,UAAiBD,KAAKE,SAAS,sCACpCF,KAAKG,MAAiBlB,SAASO,cAAc,0BAC7CQ,KAAKI,eAAiBnB,SAASO,cAAc,iCAwJ9C,OAvJAa,aAAAjB,IAAAkB,IAAA,SAAAC,MAAA,WAEQ,IAAAC,EAAAR,KACHS,EAAcT,KAAKE,SAAS,gCAC5BQ,EAAcV,KAAKE,SAAS,4BAEhCF,KAAKW,oBAAoB,cAEzB3B,OAAO4B,MACLC,OAAQ,MACRC,IAAKd,KAAKC,UAAY,sBAAwBQ,EAAc,WAAaC,EACzEK,aAAa,EACbC,YAAa,mBACbC,SAAU,OACVC,KAAMC,KAAKC,UAAUpB,KAAKqB,qBAE3BC,KAAK,WACJd,EAAKG,oBAAoB,aACzBH,EAAKL,MAAMoB,WAEZC,KAAK,WACJhB,EAAKG,oBAAoB,qBAE5BL,IAAA,kBAAAC,MAAA,WAWC,OACEW,MACEO,KAAM,6BACNC,GAXkB1B,KAAKE,SAAS,gCAYhCyB,YACEC,WAAW,EACXC,cAbgB7B,KAAKE,SAAS,8BAc9B4B,UAbgB9B,KAAKE,SAAS,4BAc9B6B,YAbgB/B,KAAKE,SAAS,iCAc9BZ,WAbgBU,KAAKgC,iBAAiB,mCActCzC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AA,GAAAA,UAAA,GAAJ,GAC9B1D,EAAQtB,SAASO,cAAcuE,GAAWxD,MAE9C,OAAGA,GAGMyD,KAEV1D,IAAA,mBAAAC,MAAA,SAEgBwD,GAA+B,IAApBC,EAAoBC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,MAC1C1D,EAAQvB,OAAO+E,GAAWnB,QAAQ,OAEtC,OAAGrC,GAGMyD,KAEV1D,IAAA,WAAAC,MAAA,SAEQwD,GAAuB,IAAZxD,EAAY0D,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAJ,GAC1BhF,SAASO,cAAcuE,GAAWxD,MAAQA,MAC3CnB,EA5JGA","file":"stackcommerce-wp.min.js","sourcesContent":["jQuery(document).ready(function() {\n  let sc_connect = new StackCommerce_WP();\n\n  sc_connect.updateForm();\n  sc_connect.categories();\n  sc_connect.tags();\n\n  let $submit_button = document.querySelector('#stackcommerce-wp-form-submit');\n\n  $submit_button.addEventListener('click', sc_connect.notify.bind(sc_connect));\n\n  jQuery('form.stackcommerce-wp-form').keypress(sc_connect.performKeycheck.bind(sc_connect));\n  jQuery('input[name=\"stackcommerce_wp_content_integration[]\"]').change(sc_connect.updateForm.bind(sc_connect));\n});\n\nclass StackCommerce_WP {\n  constructor() {\n    this.$endpoint      = this.getValue('#stackcommerce_wp_cms_api_endpoint');\n    this.$form          = document.querySelector('#stackcommerce-wp-form');\n    this.$submit_button = document.querySelector('#stackcommerce-wp-form-submit');\n  }\n\n  notify() {\n    let $account_id = this.getValue('#stackcommerce_wp_account_id'),\n        $secret_key = this.getValue('#stackcommerce_wp_secret');\n\n    this.setConnectionStatus('connecting');\n\n    jQuery.ajax({\n      method: 'PUT',\n      url: this.$endpoint + '/api/wordpress/?id=' + $account_id + '&secret=' + $secret_key,\n      processData: false,\n      contentType: 'application/json',\n      dataType: 'json',\n      data: JSON.stringify(this.generatePayload())\n    })\n    .done(() => {\n      this.setConnectionStatus('connected');\n      this.$form.submit();\n    })\n    .fail(() => {\n      this.setConnectionStatus('disconnected');\n    });\n  }\n\n  generatePayload() {\n    let $account_id     = this.getValue('#stackcommerce_wp_account_id'),\n        $wordpress_url  = this.getValue('#stackcommerce_wp_endpoint'),\n        $author_id      = this.getValue('#stackcommerce_wp_author'),\n        $post_status    = this.getValue('#stackcommerce_wp_post_status'),\n        $categories     = this.getSelect2Values('#stackcommerce_wp_categories', []),\n        $tags           = this.getSelect2Values('#stackcommerce_wp_tags', []),\n        $featured_image = this.getValue('#stackcommerce_wp_featured_image');\n\n    return {\n      data: {\n        type: 'partner_wordpress_settings',\n        id: $account_id,\n        attributes: {\n          installed: true,\n          wordpress_url: $wordpress_url,\n          author_id: $author_id,\n          post_status: $post_status,\n          categories: $categories,\n          tags: $tags,\n          featured_image: $featured_image\n        }\n      }\n    };\n  }\n\n  setConnectionStatus(status) {\n    this.setValue('#stackcommerce_wp_connection_status', status);\n    this.updateForm();\n  }\n\n  updateForm() {\n    let $form                = document.querySelector('#stackcommerce-wp-form'),\n        $submit_button       = document.querySelector('#stackcommerce-wp-form-submit'),\n        $connection_status   = this.getValue('#stackcommerce_wp_connection_status'),\n        $content_integration = this.getValue('input[name=\"stackcommerce_wp_content_integration[]\"]:checked');\n\n    $form.setAttribute('data-stackcommerce-wp-status', $connection_status);\n    $form.setAttribute('data-stackcommerce-wp-content-integration', ($content_integration == 'true' ? true : false));\n\n    if($connection_status === 'connecting') {\n      $submit_button.setAttribute('disabled', 'disabled');\n    } else {\n      $submit_button.removeAttribute('disabled');\n    }\n  }\n\n  performKeycheck(e) {\n    if(e.which == 13) {\n      this.notify();\n      return false;\n    }\n  }\n\n  taxonomySearch(options) {\n    jQuery(options.selector).select2({\n      ajax: {\n        type: 'POST',\n        url: window.ajaxurl,\n        dataType: 'json',\n        delay: 250,\n        data: function(params) {\n          return {\n            action: 'sc_api_search',\n            taxonomy: options.taxonomy,\n            q: params.term\n          }\n        },\n        processResults: function(data) {\n          var results = options.results.split('.').reduce(function(_data, key) {\n            return _data[key];\n          }, data);\n\n          return {\n            results: results\n          }\n        },\n        cache: true\n      },\n      escapeMarkup: function(markup) { return markup; },\n      minimumInputLength: 3\n    });\n  }\n\n  categories() {\n    var options = {\n      selector: '#stackcommerce_wp_categories',\n      taxonomy: 'categories',\n      results:  'data.categories'\n    }\n\n    this.taxonomySearch(options);\n  }\n\n  tags() {\n    var options = {\n      selector: '#stackcommerce_wp_tags',\n      taxonomy: 'tags',\n      results:  'data.tags'\n    }\n\n    this.taxonomySearch(options);\n  }\n\n  getValue($selector, default_value = '') {\n    let value = document.querySelector($selector).value;\n\n    if(value) {\n      return value;\n    } else {\n      return default_value;\n    }\n  }\n\n  getSelect2Values($selector, default_value = []) {\n    let value = jQuery($selector).select2('val');\n\n    if(value) {\n      return value;\n    } else {\n      return default_value;\n    }\n  }\n\n  setValue($selector, value = '') {\n    document.querySelector($selector).value = value;\n  }\n}\n"]}
     1{"version":3,"sources":["stackcommerce-wp.js"],"names":["jQuery","document","ready","querySelector","sc_connect","StackCommerce_WP","updateForm","categories","tags","addEventListener","notify","bind","keypress","performKeycheck","change","_classCallCheck","this","$endpoint","getValue","$form","$submit_button","_createClass","key","value","_this","$account_id","$secret_key","setConnectionStatus","ajax","method","url","processData","contentType","dataType","data","JSON","stringify","generatePayload","done","submit","fail","type","id","attributes","installed","wordpress_url","author_id","post_status","getSelect2Values","featured_image","status","setValue","$connection_status","$content_integration","setAttribute","removeAttribute","e","which","options","selector","select2","window","ajaxurl","delay","params","action","taxonomy","q","term","processResults","results","split","reduce","_data","cache","escapeMarkup","markup","minimumInputLength","taxonomySearch","$selector","default_value","arguments","length","undefined"],"mappings":"6XAAAA,OAAOC,UAAUC,MAAM,WAGrB,GAFmCD,SAASE,cAAc,0BAE3B,CAC7B,IAAIC,EAAa,IAAIC,iBAErBD,EAAWE,aACXF,EAAWG,aACXH,EAAWI,OAEUP,SAASE,cAAc,iCAE7BM,iBAAiB,QAASL,EAAWM,OAAOC,KAAKP,IAEhEJ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wD,GAAuB,IAAZxD,EAAY0D,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAJ,GAC1BhF,SAASE,cAAc4E,GAAWxD,MAAQA,MAC3ClB,EA5JGA","file":"stackcommerce-wp.min.js","sourcesContent":["jQuery(document).ready(function() {\n  const isStackCommerceConnectPage = document.querySelector('.stackcommerce-wp-form');\n\n  if(isStackCommerceConnectPage) {\n    let sc_connect = new StackCommerce_WP();\n\n    sc_connect.updateForm();\n    sc_connect.categories();\n    sc_connect.tags();\n\n    let $submit_button = document.querySelector('#stackcommerce-wp-form-submit');\n\n    $submit_button.addEventListener('click', sc_connect.notify.bind(sc_connect));\n\n    jQuery('form.stackcommerce-wp-form').keypress(sc_connect.performKeycheck.bind(sc_connect));\n    jQuery('input[name=\"stackcommerce_wp_content_integration[]\"]').change(sc_connect.updateForm.bind(sc_connect));\n  }\n});\n\nclass StackCommerce_WP {\n  constructor() {\n    this.$endpoint      = this.getValue('#stackcommerce_wp_cms_api_endpoint');\n    this.$form          = document.querySelector('#stackcommerce-wp-form');\n    this.$submit_button = document.querySelector('#stackcommerce-wp-form-submit');\n  }\n\n  notify() {\n    let $account_id = this.getValue('#stackcommerce_wp_account_id'),\n        $secret_key = this.getValue('#stackcommerce_wp_secret');\n\n    this.setConnectionStatus('connecting');\n\n    jQuery.ajax({\n      method: 'PUT',\n      url: this.$endpoint + '/api/wordpress/?id=' + $account_id + '&secret=' + $secret_key,\n      processData: false,\n      contentType: 'application/json',\n      dataType: 'json',\n      data: JSON.stringify(this.generatePayload())\n    })\n    .done(() => {\n      this.setConnectionStatus('connected');\n      this.$form.submit();\n    })\n    .fail(() => {\n      this.setConnectionStatus('disconnected');\n    });\n  }\n\n  generatePayload() {\n    let $account_id     = this.getValue('#stackcommerce_wp_account_id'),\n        $wordpress_url  = this.getValue('#stackcommerce_wp_endpoint'),\n        $author_id      = this.getValue('#stackcommerce_wp_author'),\n        $post_status    = this.getValue('#stackcommerce_wp_post_status'),\n        $categories     = this.getSelect2Values('#stackcommerce_wp_categories', []),\n        $tags           = this.getSelect2Values('#stackcommerce_wp_tags', []),\n        $featured_image = this.getValue('#stackcommerce_wp_featured_image');\n\n    return {\n      data: {\n        type: 'partner_wordpress_settings',\n        id: $account_id,\n        attributes: {\n          installed: true,\n          wordpress_url: $wordpress_url,\n          author_id: $author_id,\n          post_status: $post_status,\n          categories: $categories,\n          tags: $tags,\n          featured_image: $featured_image\n        }\n      }\n    };\n  }\n\n  setConnectionStatus(status) {\n    this.setValue('#stackcommerce_wp_connection_status', status);\n    this.updateForm();\n  }\n\n  updateForm() {\n    let $form                = document.querySelector('#stackcommerce-wp-form'),\n        $submit_button       = document.querySelector('#stackcommerce-wp-form-submit'),\n        $connection_status   = this.getValue('#stackcommerce_wp_connection_status'),\n        $content_integration = this.getValue('input[name=\"stackcommerce_wp_content_integration[]\"]:checked');\n\n    $form.setAttribute('data-stackcommerce-wp-status', $connection_status);\n    $form.setAttribute('data-stackcommerce-wp-content-integration', ($content_integration == 'true' ? true : false));\n\n    if($connection_status === 'connecting') {\n      $submit_button.setAttribute('disabled', 'disabled');\n    } else {\n      $submit_button.removeAttribute('disabled');\n    }\n  }\n\n  performKeycheck(e) {\n    if(e.which == 13) {\n      this.notify();\n      return false;\n    }\n  }\n\n  taxonomySearch(options) {\n    jQuery(options.selector).select2({\n      ajax: {\n        type: 'POST',\n        url: window.ajaxurl,\n        dataType: 'json',\n        delay: 250,\n        data: function(params) {\n          return {\n            action: 'sc_api_search',\n            taxonomy: options.taxonomy,\n            q: params.term\n          }\n        },\n        processResults: function(data) {\n          var results = options.results.split('.').reduce(function(_data, key) {\n            return _data[key];\n          }, data);\n\n          return {\n            results: results\n          }\n        },\n        cache: true\n      },\n      escapeMarkup: function(markup) { return markup; },\n      minimumInputLength: 3\n    });\n  }\n\n  categories() {\n    var options = {\n      selector: '#stackcommerce_wp_categories',\n      taxonomy: 'categories',\n      results:  'data.categories'\n    }\n\n    this.taxonomySearch(options);\n  }\n\n  tags() {\n    var options = {\n      selector: '#stackcommerce_wp_tags',\n      taxonomy: 'tags',\n      results:  'data.tags'\n    }\n\n    this.taxonomySearch(options);\n  }\n\n  getValue($selector, default_value = '') {\n    let value = document.querySelector($selector).value;\n\n    if(value) {\n      return value;\n    } else {\n      return default_value;\n    }\n  }\n\n  getSelect2Values($selector, default_value = []) {\n    let value = jQuery($selector).select2('val');\n\n    if(value) {\n      return value;\n    } else {\n      return default_value;\n    }\n  }\n\n  setValue($selector, value = '') {\n    document.querySelector($selector).value = value;\n  }\n}\n"]}
  • stackcommerce-connect/trunk/includes/class-stackcommerce-wp.php

    r1697716 r1700548  
    114114    public function styles() {
    115115        wp_register_style( 'stackcommerce_wp_admin_style_select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css', array(), '', 'all' );
    116     wp_register_style( 'stackcommerce_wp_admin_style', plugin_dir_url( dirname(__FILE__) ) . 'dist/styles/stackcommerce-wp.css', array(), '1.2.0', 'all' );
     116    wp_register_style( 'stackcommerce_wp_admin_style', plugin_dir_url( dirname(__FILE__) ) . 'dist/styles/stackcommerce-wp.css', array(), '1.2.1', 'all' );
    117117
    118118    wp_enqueue_style( 'stackcommerce_wp_admin_style_select2' );
     
    127127    public function scripts() {
    128128    wp_register_script( 'stackcommerce_wp_admin_script_select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js', array(), '', 'all' );
    129     wp_register_script( 'stackcommerce_wp_admin_script', plugin_dir_url( dirname(__FILE__) ) . 'dist/scripts/stackcommerce-wp.min.js', array( 'jquery' ), '1.2.0', 'all' );
     129    wp_register_script( 'stackcommerce_wp_admin_script', plugin_dir_url( dirname(__FILE__) ) . 'dist/scripts/stackcommerce-wp.min.js', array( 'jquery' ), '1.2.1', 'all' );
    130130
    131131    wp_enqueue_script( 'stackcommerce_wp_admin_script_select2' );
  • stackcommerce-connect/trunk/index.php

    r1697716 r1700548  
    55 * Plugin URI: https://wordpress.org/plugins/stackcommerce-connect/
    66 * Description: The Connect plugin by StackCommerce connects your WordPress CMS to the StackCommerce Articles repository.
    7  * Version: 1.2.0
     7 * Version: 1.2.1
    88 * Author: StackCommerce, Inc
    99 * Author URI: https://www.stackcommerce.com
  • stackcommerce-connect/trunk/readme.txt

    r1697716 r1700548  
    44Requires at least: 4.4
    55Tested up to: 4.8
    6 Stable tag: 1.2.0
     6Stable tag: 1.2.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5353== Changelog ==
    5454
     55= 1.2.1 =
     56* Fix JavaScript load issue with Admin pages.
     57
    5558= 1.2.0 =
    5659* Article images are now downloaded and hosted in your Media Library.
  • stackcommerce-connect/trunk/version.txt

    r1697716 r1700548  
    1 1.2.0
     11.2.1
Note: See TracChangeset for help on using the changeset viewer.