parent
cb45ce94e2
commit
778282ea7f
10 changed files with 433 additions and 323 deletions
@ -0,0 +1,111 @@ |
|||||||
|
/******/ (function(modules) { // webpackBootstrap
|
||||||
|
/******/ // The module cache
|
||||||
|
/******/ var installedModules = {}; |
||||||
|
|
||||||
|
/******/ // The require function
|
||||||
|
/******/ function __webpack_require__(moduleId) { |
||||||
|
|
||||||
|
/******/ // Check if module is in cache
|
||||||
|
/******/ if(installedModules[moduleId]) |
||||||
|
/******/ return installedModules[moduleId].exports; |
||||||
|
|
||||||
|
/******/ // Create a new module (and put it into the cache)
|
||||||
|
/******/ var module = installedModules[moduleId] = { |
||||||
|
/******/ exports: {}, |
||||||
|
/******/ id: moduleId, |
||||||
|
/******/ loaded: false |
||||||
|
/******/ }; |
||||||
|
|
||||||
|
/******/ // Execute the module function
|
||||||
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
||||||
|
|
||||||
|
/******/ // Flag the module as loaded
|
||||||
|
/******/ module.loaded = true; |
||||||
|
|
||||||
|
/******/ // Return the exports of the module
|
||||||
|
/******/ return module.exports; |
||||||
|
/******/ } |
||||||
|
|
||||||
|
|
||||||
|
/******/ // expose the modules object (__webpack_modules__)
|
||||||
|
/******/ __webpack_require__.m = modules; |
||||||
|
|
||||||
|
/******/ // expose the module cache
|
||||||
|
/******/ __webpack_require__.c = installedModules; |
||||||
|
|
||||||
|
/******/ // __webpack_public_path__
|
||||||
|
/******/ __webpack_require__.p = ""; |
||||||
|
|
||||||
|
/******/ // Load entry module and return exports
|
||||||
|
/******/ return __webpack_require__(0); |
||||||
|
/******/ }) |
||||||
|
/************************************************************************/ |
||||||
|
/******/ ({ |
||||||
|
|
||||||
|
/***/ 0: |
||||||
|
/***/ function(module, exports, __webpack_require__) { |
||||||
|
|
||||||
|
'use strict'; |
||||||
|
|
||||||
|
var _avatar_upload = __webpack_require__(27); |
||||||
|
|
||||||
|
$(function () { |
||||||
|
(0, _avatar_upload.avatarUploadInit)(); |
||||||
|
}); |
||||||
|
|
||||||
|
/***/ }, |
||||||
|
|
||||||
|
/***/ 27: |
||||||
|
/***/ function(module, exports) { |
||||||
|
|
||||||
|
'use strict'; |
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", { |
||||||
|
value: true |
||||||
|
}); |
||||||
|
// Live image avatar (single) upload ---------------------------------
|
||||||
|
var LIVE_IMAGE_UPLOAD_URL = '/common/live-image-upload/create/'; |
||||||
|
|
||||||
|
function avatarUploadInit() { |
||||||
|
var $container = $('.-live-image-avatar-upload-container').first(); |
||||||
|
|
||||||
|
var $avatarImage = $container.find('.-avatar-image').first(); |
||||||
|
var $liveImageUpload = $container.find('.-live-image-upload').first(); |
||||||
|
var $liveImageId = $container.find('.-live-image-id').first(); |
||||||
|
var $liveImageDelete = $container.find('.-live-image-delete').first(); |
||||||
|
|
||||||
|
$avatarImage.attr('orig-src', $avatarImage.attr('src')); |
||||||
|
|
||||||
|
$liveImageUpload.fileupload({ |
||||||
|
url: LIVE_IMAGE_UPLOAD_URL, |
||||||
|
dataType: 'json', |
||||||
|
|
||||||
|
done: function done($evt, data) { |
||||||
|
var image = data.result; |
||||||
|
|
||||||
|
$avatarImage.attr('src', image.thumbnailUrl); |
||||||
|
$liveImageId.val(image.id); |
||||||
|
|
||||||
|
$liveImageDelete.data('url', image.deleteUrl); |
||||||
|
$liveImageDelete.css('display', 'block'); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
$liveImageDelete.on('click', function ($evt) { |
||||||
|
var $that = $(this); |
||||||
|
|
||||||
|
$.post($that.data('url')).then(function (res) { |
||||||
|
if (res.status == 'success') { |
||||||
|
$avatarImage.attr('src', $avatarImage.attr('orig-src') || STUB_IMAGE_URL); |
||||||
|
$liveImageId.val(''); |
||||||
|
$that.css('display', 'none'); |
||||||
|
} |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
exports.avatarUploadInit = avatarUploadInit; |
||||||
|
|
||||||
|
/***/ } |
||||||
|
|
||||||
|
/******/ }); |
||||||
@ -0,0 +1,42 @@ |
|||||||
|
// Live image avatar (single) upload ---------------------------------
|
||||||
|
var LIVE_IMAGE_UPLOAD_URL = '/common/live-image-upload/create/'; |
||||||
|
|
||||||
|
function avatarUploadInit() { |
||||||
|
var $container = $('.-live-image-avatar-upload-container').first(); |
||||||
|
|
||||||
|
var $avatarImage = $container.find('.-avatar-image').first(); |
||||||
|
var $liveImageUpload = $container.find('.-live-image-upload').first(); |
||||||
|
var $liveImageId = $container.find('.-live-image-id').first(); |
||||||
|
var $liveImageDelete = $container.find('.-live-image-delete').first(); |
||||||
|
|
||||||
|
$avatarImage.attr('orig-src', $avatarImage.attr('src')); |
||||||
|
|
||||||
|
$liveImageUpload.fileupload({ |
||||||
|
url: LIVE_IMAGE_UPLOAD_URL, |
||||||
|
dataType: 'json', |
||||||
|
|
||||||
|
done: function($evt, data) { |
||||||
|
var image = data.result; |
||||||
|
|
||||||
|
$avatarImage.attr('src', image.thumbnailUrl); |
||||||
|
$liveImageId.val(image.id); |
||||||
|
|
||||||
|
$liveImageDelete.data('url', image.deleteUrl); |
||||||
|
$liveImageDelete.css('display', 'block') |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
$liveImageDelete.on('click', function($evt) { |
||||||
|
var $that = $(this); |
||||||
|
|
||||||
|
$.post($that.data('url')).then(function(res) { |
||||||
|
if (res.status == 'success') { |
||||||
|
$avatarImage.attr('src', $avatarImage.attr('orig-src') || STUB_IMAGE_URL); |
||||||
|
$liveImageId.val(''); |
||||||
|
$that.css('display', 'none') |
||||||
|
} |
||||||
|
}) |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
export {avatarUploadInit} |
||||||
@ -1,56 +0,0 @@ |
|||||||
|
|
||||||
function onBind(target, name, descriptor) { |
|
||||||
const method = descriptor.value; |
|
||||||
|
|
||||||
descriptor.value = function (...args) { |
|
||||||
let binds = []; |
|
||||||
args = Array.from(args); |
|
||||||
for (let arg of args.slice()) { |
|
||||||
if (typeof arg === 'object') { |
|
||||||
binds.push(arg); |
|
||||||
args.splice(args.indexOf(arg), 1); |
|
||||||
} |
|
||||||
} |
|
||||||
method.apply(this, args); |
|
||||||
for (let bind of binds) { |
|
||||||
bind.func.bind(this)(); |
|
||||||
} |
|
||||||
return this; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
class Base { |
|
||||||
constructor() { |
|
||||||
this.attr1 = 'attr1'; |
|
||||||
console.log("Constructor") |
|
||||||
} |
|
||||||
|
|
||||||
@onBind |
|
||||||
method1(a = 1, b = 2) { |
|
||||||
console.log("this.attr1 = ", this.attr1); |
|
||||||
console.log("a = ", a, "b = ", b); |
|
||||||
} |
|
||||||
|
|
||||||
on(methodName, func) { |
|
||||||
this[methodName] = this[methodName].bind(this, {func}); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
let b = new Base(); |
|
||||||
|
|
||||||
b.on("method1", () => console.log("Another message...")); |
|
||||||
b.on("method1", function () { |
|
||||||
console.log("bind this.attr1 =", this.attr1); |
|
||||||
}); |
|
||||||
|
|
||||||
b.method1("one", 2); |
|
||||||
b.method1("bbb"); |
|
||||||
|
|
||||||
if (NODE_ENV == 'dev') { |
|
||||||
console.log("Dev mode message") |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
function a({a=2, b=a+4}) { |
|
||||||
|
|
||||||
} |
|
||||||
@ -0,0 +1,5 @@ |
|||||||
|
import {avatarUploadInit} from './seeds/avatar_upload' |
||||||
|
|
||||||
|
$(function () { |
||||||
|
avatarUploadInit(); |
||||||
|
}); |
||||||
Loading…
Reference in new issue