From aa0ccd8f2240ca49a83867d0c26466959ff27d0d Mon Sep 17 00:00:00 2001 From: Rodrigo Ferreira de Souza Date: Thu, 26 Jan 2017 14:23:31 -0200 Subject: [PATCH] Add javascript --- buildout.cfg | 11 ++++ .../behavior/featuredimage/static/main.js | 2 +- .../behavior/featuredimage/static/main.js.map | 2 +- webpack/.babelrc | 3 ++ webpack/.gitignore | 1 + webpack/app/main.js | 8 +++ webpack/app/scripts/behaviorform.js | 54 +++++++++++++++++++ webpack/package.json | 4 ++ webpack/webpack.config.js | 3 ++ 9 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 webpack/.babelrc create mode 100644 webpack/app/scripts/behaviorform.js diff --git a/buildout.cfg b/buildout.cfg index 1156c4f..6a39439 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -16,6 +16,7 @@ parts += node rebuild_i18n-sh rebuild_npm + npm_dev npm_build npm_watch run_rebuild_npm @@ -72,6 +73,16 @@ input = inline: output = ${buildout:bin-directory}/rebuild_npm mode = 755 +[npm_dev] +recipe = collective.recipe.template +input = inline: + #!/bin/sh + PATH=${buildout:bin-directory}:$PATH + cd webpack + npm run dev +output = ${buildout:bin-directory}/npm_dev +mode = 755 + [npm_build] recipe = collective.recipe.template input = inline: diff --git a/src/collective/behavior/featuredimage/static/main.js b/src/collective/behavior/featuredimage/static/main.js index 4e83f7e..c4c91ed 100644 --- a/src/collective/behavior/featuredimage/static/main.js +++ b/src/collective/behavior/featuredimage/static/main.js @@ -1,2 +1,2 @@ -!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var t={};return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=2)}([function(e,n){},function(e,n,t){e.exports=t.p+"featuredimage-icon.png"},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(0),o=(t.n(r),t(1));t.n(o)}]); +!function(e){function t(i){if(r[i])return r[i].exports;var n=r[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,i){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=3)}([function(e,t,r){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var n=function(){function e(e,t){for(var r=0;r\n \n ';$("#fieldset-featured-image").append(e)}},{key:"iframeready",value:function(e){e.preventDefault();var t=void 0,r=void 0;this.$featuredimage=$("#featuredimage",this.$iframe[0].contentWindow.document.body),t=$("img",this.$featuredimage),r=new Image,r.src=t.attr("src"),r.onload=function(e){return function(){e.$el.width(this.width/2+10),e.$el.height(this.height/2+10),e.$iframe.width(this.width+10),e.$iframe.height(this.height+10),e.updateFeaturedImage()}}(this)}},{key:"updateFeaturedImage",value:function(e){void 0!==e&&e.preventDefault();var t=void 0,r=void 0;r=$(".quote .text",this.$featuredimage),t=$(".quote .author",this.$featuredimage),r.html(this.$quote.val()),t.html(this.$author.val())}}]),e}();e.exports=a},function(e,t){},function(e,t,r){e.exports=r.p+"featuredimage-icon.png"},function(e,t,r){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}r(1),r(2);var n=r(0),a=i(n);$(function(){$("#fieldset-featured-image").length>0&&new a.default})}]); //# sourceMappingURL=main.js.map \ No newline at end of file diff --git a/src/collective/behavior/featuredimage/static/main.js.map b/src/collective/behavior/featuredimage/static/main.js.map index d201fff..0d5b115 100644 --- a/src/collective/behavior/featuredimage/static/main.js.map +++ b/src/collective/behavior/featuredimage/static/main.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///main.js","webpack:///webpack/bootstrap 79aa01a1d588803dba04","webpack:///./app/images/featuredimage-icon.png"],"names":["modules","__webpack_require__","moduleId","installedModules","exports","module","i","l","call","m","c","value","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","__webpack_exports__","__WEBPACK_IMPORTED_MODULE_0__main_css__","__WEBPACK_IMPORTED_MODULE_1__images_featuredimage_icon_png__"],"mappings":"CAAS,SAAUA,GCInB,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAE,OAGA,IAAAC,GAAAF,EAAAD,IACAI,EAAAJ,EACAK,GAAA,EACAH,WAUA,OANAJ,GAAAE,GAAAM,KAAAH,EAAAD,QAAAC,IAAAD,QAAAH,GAGAI,EAAAE,GAAA,EAGAF,EAAAD,QAvBA,GAAAD,KA+DA,OAnCAF,GAAAQ,EAAAT,EAGAC,EAAAS,EAAAP,EAGAF,EAAAK,EAAA,SAAAK,GAA2C,MAAAA,IAG3CV,EAAAW,EAAA,SAAAR,EAAAS,EAAAC,GACAb,EAAAc,EAAAX,EAAAS,IACAG,OAAAC,eAAAb,EAAAS,GACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,KAMAb,EAAAoB,EAAA,SAAAhB,GACA,GAAAS,GAAAT,KAAAiB,WACA,WAA2B,MAAAjB,GAAA,SAC3B,WAAiC,MAAAA,GAEjC,OADAJ,GAAAW,EAAAE,EAAA,IAAAA,GACAA,GAIAb,EAAAc,EAAA,SAAAQ,EAAAC,GAAsD,MAAAR,QAAAS,UAAAC,eAAAlB,KAAAe,EAAAC,IAGtDvB,EAAA0B,EAAA,GAGA1B,IAAA2B,EAAA,KDMM,SAAUvB,EAAQD,KAMlB,SAAUC,EAAQD,EAASH,GE5EjCI,EAAAD,QAAAH,EAAA0B,EAAA,0BFkFM,SAAUtB,EAAQwB,EAAqB5B,GAE7C,YACAe,QAAOC,eAAeY,EAAqB,cAAgBlB,OAAO,GAC7C,IAAImB,GAA0C7B,EAAoB,GAE9D8B,GADkD9B,EAAoBoB,EAAES,GACT7B,EAAoB,GACZA,GAAoBoB,EAAEU","file":"main.js","sourcesContent":["/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 2);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\nmodule.exports = __webpack_require__.p + \"featuredimage-icon.png\";\n\n/***/ }),\n/* 2 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\nObject.defineProperty(__webpack_exports__, \"__esModule\", { value: true });\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__main_css__ = __webpack_require__(0);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__main_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__main_css__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__images_featuredimage_icon_png__ = __webpack_require__(1);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__images_featuredimage_icon_png___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__images_featuredimage_icon_png__);\n\n\n\n\n/***/ })\n/******/ ]);\n\n\n// WEBPACK FOOTER //\n// main.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 79aa01a1d588803dba04","module.exports = __webpack_public_path__ + \"featuredimage-icon.png\";\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./app/images/featuredimage-icon.png\n// module id = 1\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///main.js","webpack:///webpack/bootstrap 79f487a67a2bd887382d","webpack:///./app/scripts/behaviorform.js","webpack:///./app/images/featuredimage-icon.png","webpack:///./app/main.js"],"names":["modules","__webpack_require__","moduleId","installedModules","exports","module","i","l","call","m","c","value","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","_classCallCheck","instance","Constructor","TypeError","_createClass","defineProperties","target","props","length","descriptor","writable","key","protoProps","staticProps","BehaviorformView","this","render","$el","$","$iframe","$quote","$author","on","proxy","iframeready","updateFeaturedImage","template","portal_url","append","e","preventDefault","screenImage","theImage","$featuredimage","contentWindow","document","body","Image","src","attr","onload","that","width","height","undefined","$iframeAuthor","$iframeQuote","html","val","_interopRequireDefault","obj","default","_behaviorform","_behaviorform2"],"mappings":"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","file":"main.js","sourcesContent":["/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 3);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar BehaviorformView = function () {\n function BehaviorformView() {\n _classCallCheck(this, BehaviorformView);\n\n this.render();\n this.$el = $('#featuredimage-preview');\n this.$iframe = $('iframe');\n this.$quote = $('#form-widgets-IFeaturedImage-featuredimage_quote');\n this.$author = $('#form-widgets-IFeaturedImage-featuredimage_author');\n this.$iframe.on('load', $.proxy(this.iframeready, this));\n this.$quote.on('input', $.proxy(this.updateFeaturedImage, this));\n this.$author.on('input', $.proxy(this.updateFeaturedImage, this));\n }\n\n _createClass(BehaviorformView, [{\n key: 'render',\n value: function render() {\n var template = '\\n
\\n \\n
\\n ';\n $('#fieldset-featured-image').append(template);\n }\n }, {\n key: 'iframeready',\n value: function iframeready(e) {\n e.preventDefault();\n var screenImage = void 0,\n theImage = void 0;\n this.$featuredimage = $('#featuredimage', this.$iframe[0].contentWindow.document.body);\n screenImage = $('img', this.$featuredimage);\n theImage = new Image();\n theImage.src = screenImage.attr('src');\n theImage.onload = function (that) {\n return function () {\n that.$el.width(this.width / 2 + 10);\n that.$el.height(this.height / 2 + 10);\n that.$iframe.width(this.width + 10);\n that.$iframe.height(this.height + 10);\n that.updateFeaturedImage();\n };\n }(this);\n }\n }, {\n key: 'updateFeaturedImage',\n value: function updateFeaturedImage(e) {\n if (e !== undefined) {\n e.preventDefault();\n }\n var $iframeAuthor = void 0,\n $iframeQuote = void 0;\n $iframeQuote = $('.quote .text', this.$featuredimage);\n $iframeAuthor = $('.quote .author', this.$featuredimage);\n $iframeQuote.html(this.$quote.val());\n $iframeAuthor.html(this.$author.val());\n }\n }]);\n\n return BehaviorformView;\n}();\n\nmodule.exports = BehaviorformView;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\nmodule.exports = __webpack_require__.p + \"featuredimage-icon.png\";\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\n__webpack_require__(1);\n\n__webpack_require__(2);\n\nvar _behaviorform = __webpack_require__(0);\n\nvar _behaviorform2 = _interopRequireDefault(_behaviorform);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n$(function () {\n if ($('#fieldset-featured-image').length > 0) {\n new _behaviorform2.default();\n }\n});\n\n/***/ })\n/******/ ]);\n\n\n// WEBPACK FOOTER //\n// main.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 79f487a67a2bd887382d","class BehaviorformView {\n constructor() {\n this.render();\n this.$el = $('#featuredimage-preview');\n this.$iframe = $('iframe');\n this.$quote = $('#form-widgets-IFeaturedImage-featuredimage_quote');\n this.$author = $('#form-widgets-IFeaturedImage-featuredimage_author');\n this.$iframe.on('load', $.proxy(this.iframeready, this));\n this.$quote.on('input', $.proxy(this.updateFeaturedImage, this));\n this.$author.on('input', $.proxy(this.updateFeaturedImage, this));\n }\n\n render() {\n var template = `\n
\n \n
\n `\n $('#fieldset-featured-image').append(template);\n }\n\n iframeready(e) {\n e.preventDefault();\n let screenImage, theImage;\n this.$featuredimage = $('#featuredimage', this.$iframe[0].contentWindow.document.body);\n screenImage = $('img', this.$featuredimage);\n theImage = new Image();\n theImage.src = screenImage.attr('src');\n theImage.onload = function(that) {\n return function() {\n that.$el.width(this.width / 2 + 10);\n that.$el.height(this.height / 2 + 10);\n that.$iframe.width(this.width + 10);\n that.$iframe.height(this.height + 10);\n that.updateFeaturedImage();\n }\n }(this)\n }\n\n updateFeaturedImage(e) {\n if (e !== undefined) {\n e.preventDefault();\n }\n let $iframeAuthor, $iframeQuote;\n $iframeQuote = $('.quote .text', this.$featuredimage);\n $iframeAuthor = $('.quote .author', this.$featuredimage);\n $iframeQuote.html(this.$quote.val());\n $iframeAuthor.html(this.$author.val());\n }\n}\n\nmodule.exports = BehaviorformView;\n\n\n\n// WEBPACK FOOTER //\n// ./app/scripts/behaviorform.js","module.exports = __webpack_public_path__ + \"featuredimage-icon.png\";\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./app/images/featuredimage-icon.png\n// module id = 2\n// module chunks = 0","import './main.css';\nimport './images/featuredimage-icon.png';\n\nimport AppView from './scripts/behaviorform.js';\n\n$(() => {\n if ($('#fieldset-featured-image').length > 0) {\n new AppView();\n }\n});\n\n\n\n// WEBPACK FOOTER //\n// ./app/main.js"],"sourceRoot":""} \ No newline at end of file diff --git a/webpack/.babelrc b/webpack/.babelrc new file mode 100644 index 0000000..a0765e1 --- /dev/null +++ b/webpack/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015"] +} diff --git a/webpack/.gitignore b/webpack/.gitignore index 23d67fc..a3bb814 100644 --- a/webpack/.gitignore +++ b/webpack/.gitignore @@ -1,2 +1,3 @@ node_modules/ yarn.lock +npm-debug.log diff --git a/webpack/app/main.js b/webpack/app/main.js index 40c2b15..160655b 100644 --- a/webpack/app/main.js +++ b/webpack/app/main.js @@ -1,2 +1,10 @@ import './main.css'; import './images/featuredimage-icon.png'; + +import AppView from './scripts/behaviorform.js'; + +$(() => { + if ($('#fieldset-featured-image').length > 0) { + new AppView(); + } +}); diff --git a/webpack/app/scripts/behaviorform.js b/webpack/app/scripts/behaviorform.js new file mode 100644 index 0000000..7c9b4ac --- /dev/null +++ b/webpack/app/scripts/behaviorform.js @@ -0,0 +1,54 @@ +class BehaviorformView { + constructor() { + this.render(); + this.$el = $('#featuredimage-preview'); + this.$iframe = $('iframe'); + this.$quote = $('#form-widgets-IFeaturedImage-featuredimage_quote'); + this.$author = $('#form-widgets-IFeaturedImage-featuredimage_author'); + this.$iframe.on('load', $.proxy(this.iframeready, this)); + this.$quote.on('input', $.proxy(this.updateFeaturedImage, this)); + this.$author.on('input', $.proxy(this.updateFeaturedImage, this)); + } + + render() { + var template = ` +
+ +
+ ` + $('#fieldset-featured-image').append(template); + } + + iframeready(e) { + e.preventDefault(); + let screenImage, theImage; + this.$featuredimage = $('#featuredimage', this.$iframe[0].contentWindow.document.body); + screenImage = $('img', this.$featuredimage); + theImage = new Image(); + theImage.src = screenImage.attr('src'); + theImage.onload = function(that) { + return function() { + that.$el.width(this.width / 2 + 10); + that.$el.height(this.height / 2 + 10); + that.$iframe.width(this.width + 10); + that.$iframe.height(this.height + 10); + that.updateFeaturedImage(); + } + }(this) + } + + updateFeaturedImage(e) { + if (e !== undefined) { + e.preventDefault(); + } + let $iframeAuthor, $iframeQuote; + $iframeQuote = $('.quote .text', this.$featuredimage); + $iframeAuthor = $('.quote .author', this.$featuredimage); + $iframeQuote.html(this.$quote.val()); + $iframeAuthor.html(this.$author.val()); + } +} + +module.exports = BehaviorformView; diff --git a/webpack/package.json b/webpack/package.json index 62be011..1297458 100644 --- a/webpack/package.json +++ b/webpack/package.json @@ -3,12 +3,16 @@ "version": "0.0.1", "main": "app/main.js", "scripts": { + "dev": "./node_modules/.bin/webpack", "build": "./node_modules/.bin/webpack -p", "watch": "./node_modules/.bin/webpack --watch" }, "repository": {}, "license": "GPLv2", "devDependencies": { + "babel-core": "^6.22.1", + "babel-loader": "^6.2.10", + "babel-preset-es2015": "^6.22.0", "css-loader": "^0.26.1", "extract-text-webpack-plugin": "^2.0.0-beta", "file-loader": "^0.9.0", diff --git a/webpack/webpack.config.js b/webpack/webpack.config.js index 76c3633..da28154 100644 --- a/webpack/webpack.config.js +++ b/webpack/webpack.config.js @@ -7,6 +7,9 @@ module.exports = { }, module: { rules: [{ + test: /\.js$/, + loader: 'babel-loader', + }, { test: /\.css$/, exclude: /node_modules/, loader: ExtractTextPlugin.extract({