Skip to content
This repository has been archived by the owner on May 7, 2018. It is now read-only.

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bupy7 committed Aug 19, 2015
1 parent ab14fb4 commit f40f628
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 9 deletions.
59 changes: 57 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ This Cropper can resize, zoom, move image before crop.
bower install jq-cropbox#1.0.*
```

## Requirements

- [jQuery](https://github.com/jquery/jquery) >= 1.8
- [jquery-mousewheel](https://github.com/jquery/jquery-mousewheel)

## Usage

Include:
Expand Down Expand Up @@ -91,10 +96,60 @@ $('#plugin').cropbox({

## Options

TODO
### ```selectors``` (required)

Selectors is required property where must be content:

**Required:**
- ```inputInfo``` - Selector to input type "text"/"textarea" where will be write information about cropped.
- ```inputFile``` - Selector to input type "file" for select image from file.
- ```btnCrop``` - Selector to button for run crop action.
- ```btnReset``` - Selector to button for run reset action.
- ```resultContainer``` - Content cropped images.

**Additional:**
- ```messageBlock``` - If you set property ```messages``` then you must be set selector for display it messages.

### ```variants``` (required)

Variants of crop image. Supported few crop settings.

By default variants content following settings:

```js
variants = [
{
width: 200,
height: 200,
minWidth: 200,
minHeight: 200,
maxWidth: 350,
maxHeight: 350
}
]
```

You can set your settings of frame crop.

**Required:**
- ```width``` - Width of frame crop (px).
- ```height``` - Height of frame crop (px).

**Additional:**
- ```minWidth``` - Minimal width of frame crop for resize it (px).
- ```maxWidth``` - Maximum width of frame crop for resize it (px).
- ```minHeight``` - Minimal height of frame crop for resize it (px).
- ```maxHeight``` - Maximum height of frame crop for resize it (px).

You can set both or one options max(min)Width/max(min)Height of resize frame crop.

### ```imageOptions```

HTML-attributes for cropped images which content to ```resultContainer```.

- ```selectors``` - Selectors of skeleton plugin.
### ```messages```

Text/Html messages for current frame crop settings.

## License

Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.cropbox.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions src/jquery.cropbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,17 @@
init: function(options) {
$th = $(this);
// merge options
variants = options.variants || variants;
imageOptions = options.imageOptions || imageOptions;
messages = options.messages || messages;
$inputFile = $(options.selectors.inputFile);
$inputInfo = $(options.selectors.inputInfo);
$btnReset = $(options.selectors.btnReset);
$btnCrop = $(options.selectors.btnCrop);
$resultContainer = $(options.selectors.resultContainer);
$messageBlock = $(options.selectors.messageBlock);
variants = options.variants || variants;
imageOptions = options.imageOptions || imageOptions;
messages = options.messages || messages;
if (typeof options.selectors.messageBlock != 'undefined') {
$messageBlock = $(options.selectors.messageBlock);
}
// initialize plugin
initResultBackup();
initComponents();
Expand Down Expand Up @@ -440,14 +442,16 @@
}
},
showMessage = function() {
if (typeof messages[indexVariant] != 'undefined') {
if (typeof messages[indexVariant] != 'undefined' && $messageBlock !== null) {
$messageBlock.html(messages[indexVariant]).show();
return true;
}
return false;
},
hideMessage = function() {
$messageBlock.hide();
if ($messageBlock !== null) {
$messageBlock.hide();
}
},
initResultBackup = function() {
$backupResultContainer = $resultContainer.clone();
Expand Down

0 comments on commit f40f628

Please sign in to comment.