Skip to content

Commit

Permalink
New improvements for j-PictureUpload and j-Preview.
Browse files Browse the repository at this point in the history
  • Loading branch information
petersirka committed Mar 12, 2020
1 parent 4ec9bec commit 1269799
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 16 deletions.
6 changes: 3 additions & 3 deletions j-PictureUpload/component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
COMPONENT('pictureupload', 'extension:false;singlefile:true;type:png', function(self, config) {
COMPONENT('pictureupload', 'extension:false;singlefile:true;type:png', function(self, config, cls) {

var empty, img, canvas, content = null;

Expand Down Expand Up @@ -43,7 +43,7 @@ COMPONENT('pictureupload', 'extension:false;singlefile:true;type:png', function(

self.redraw = function() {
var label = config.label || content;
self.html((label ? '<div class="ui-pictureupload-label">{0}{1}:</div>'.format(config.icon ? '<i class="fa fa-{0}"></i>'.format(config.icon) : '', label) : '') + '<input type="file" accept="image/*" class="hidden" /><img src="{0}" class="img-responsive" alt="" />'.format(empty, config.width, config.height));
self.html((label ? ('<div class="' + cls + '-label">{0}{1}:</div>'.format(config.icon ? '<i class="fa fa-{0}"></i>'.format(config.icon) : '', label)) : '') + '<input type="file" accept="image/*" class="hidden" /><img src="{0}" class="img-responsive" alt="" />'.format(empty, config.width, config.height));
img = self.find('img');
img.on('click', function() {
self.find('input').trigger('click');
Expand All @@ -53,7 +53,7 @@ COMPONENT('pictureupload', 'extension:false;singlefile:true;type:png', function(
self.make = function() {

content = self.html();
self.aclass('ui-pictureupload');
self.aclass(cls);
self.reinit();
self.redraw();

Expand Down
5 changes: 3 additions & 2 deletions j-PictureUpload/component.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"datecreated": "2016-09-01T23:55:00.000Z",
"dateupdated": "2019-02-14T15:00:00.000Z",
"dateupdated": "2020-03-12T09:21:00.000Z",
"name": "j-PictureUpload",
"tags": [
"jcomponent"
"picture",
"upload"
],
"color": "transparent",
"version": 1,
Expand Down
4 changes: 2 additions & 2 deletions j-PictureUpload/dependencies.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<link href="https://cdn.componentator.com/spa.min@17.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.componentator.com/spa.min@17.js"></script>
<link href="https://cdn.componentator.com/spa.min@18.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.componentator.com/spa.min@18.js"></script>
2 changes: 1 addition & 1 deletion j-PictureUpload/example.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div style="padding:50px;max-width:300px">
<div data-jc="pictureupload__picture__width:300;height:200;url:/upload/;icon:folder-o">Picture</div>
<div data---="pictureupload__picture__width:300;height:200;url:/upload/;icon:folder-o">Picture</div>
</div>

<script>
Expand Down
5 changes: 3 additions & 2 deletions j-PictureUpload/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- easy usage
- works with Bootstrap Grid System
- drag and drop support
- uploads a raw file (without resizing)

__Configuration__:

Expand All @@ -14,8 +15,8 @@ __Configuration__:
- `src` {String} an image path (default: `null`), e.g. `/img/{0}.jpg`
- `extension` {Boolean} response without file extension (default: `false`)
- `singlefile` {Boolean} response will be string instead of array (default: `true`)
- __new__ `type` {String} output type (default: `png`)
- __new__ `quality` {Number} output quality
- __new__ `type` {String} preview: output type (default: `png`)
- __new__ `quality` {Number} preview: output quality

### Author

Expand Down
6 changes: 3 additions & 3 deletions j-Preview/component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
COMPONENT('preview', 'width:200;height:100;background:#FFFFFF;quality:90;customize:1;schema:{file\\:base64,name\\:filename}', function(self, config) {
COMPONENT('preview', 'width:200;height:100;background:#FFFFFF;quality:90;customize:1;schema:{file\\:base64,name\\:filename}', function(self, config, cls) {

var empty, img, canvas, name, content = null;

Expand Down Expand Up @@ -129,7 +129,7 @@ COMPONENT('preview', 'width:200;height:100;background:#FFFFFF;quality:90;customi

self.redraw = function() {
var label = config.label || content;
self.html((label ? '<div class="ui-preview-label">{0}{1}:</div>'.format(config.icon ? '<i class="fa fa-{0}"></i>'.format(config.icon) : '', label) : '') + '<input type="file" accept="image/*" class="hidden" /><img src="{0}" class="img-responsive" alt="" />'.format(empty, config.width, config.height));
self.html((label ? ('<div class="' + cls + '-label">{0}{1}:</div>'.format(config.icon ? '<i class="fa fa-{0}"></i>'.format(config.icon) : '', label)) : '') + '<input type="file" accept="image/*" class="hidden" /><img src="{0}" class="img-responsive" alt="" />'.format(empty, config.width, config.height));
img = self.find('img');
img.on('click', function() {
self.find('input').trigger('click');
Expand All @@ -139,7 +139,7 @@ COMPONENT('preview', 'width:200;height:100;background:#FFFFFF;quality:90;customi
self.make = function() {

content = self.html();
self.aclass('ui-preview');
self.aclass(cls);
self.reinit();
self.redraw();

Expand Down
2 changes: 1 addition & 1 deletion j-Preview/component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"datecreated": "2017-11-23T20:42:02.000Z",
"dateupdated": "2019-05-07T15:39:00.000Z",
"dateupdated": "2020-03-12T09:24:00.000Z",
"name": "j-Preview",
"tags": [
"picture",
Expand Down
4 changes: 2 additions & 2 deletions j-Preview/dependencies.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<link href="https://cdn.componentator.com/spa.min@17.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.componentator.com/spa.min@17.js"></script>
<link href="https://cdn.componentator.com/spa.min@18.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.componentator.com/spa.min@18.js"></script>

0 comments on commit 1269799

Please sign in to comment.