Skip to content

Commit

Permalink
Change call signature of onUpdateMarker
Browse files Browse the repository at this point in the history
Add onUpdateMarker description to README
  • Loading branch information
waynegm committed Jul 30, 2014
1 parent 723ae33 commit 1ed711c
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 23 deletions.
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
imgNotes
=========

imgNotes is an extension of the jQuery [imgViewer](https://github.com/waynegm/imgViewer) plugin that adds markers and notes to an image
that can be zoomed in and out with the mousewheel and panned around by click and drag. Try out the [demo](http://waynegm.github.io/imgNotes/).
imgNotes is an extension of the jQuery [imgViewer](https://github.com/waynegm/imgViewer) plugin that adds markers and notes to an image that can be zoomed in and out with the mousewheel and panned around by click and drag. Try out the [demo](http://waynegm.github.io/imgNotes/).

The widget has an edit and a view mode controlled by an option flag (canEdit).

In edit mode (canEdit: true) the default action associated with clicking on the image is to insert a marker and open a dialog with a
textarea to enter a note. The "Delete" button on this dialog deletes the marker and note. Callbacks are provided for developers to
override the default marker and the note editor.
In edit mode (canEdit: true) the default action associated with clicking on the image is to insert a marker and open a dialog with a textarea to enter a note. The "Delete" button on this dialog deletes the marker and note. Callbacks are provided for developers to override the default marker and the note editor.

In view mode (canEdit: false) markers cannot be changed. By default, clicking on a marker displays the associated note in a dialog window.
This default action can be overriden by a callback option.
In view mode (canEdit: false) markers cannot be changed. By default, clicking on a marker displays the associated note in a dialog window. This default action can be overriden by a callback option.

Methods are provided to import and export notes from and to a javascript array.

Expand Down Expand Up @@ -153,6 +149,13 @@ $("#image1").imgNotes("option", "onAdd", function() {
* ev: the click event
* elem: the marker DOM element

###onUpdateMarker
* Callback triggered when a marker is redrawn
Within the callback "this" refers to the imgNotes widget
* Default: Display the marker at its original size on the image positioned according to the vAll and hAll alignment options
* Callback Arguments:
* elem: the marker DOM element

## Public Methods

###addNote
Expand Down Expand Up @@ -214,3 +217,10 @@ Copyright (c) 2013 Wayne Mogg.

### 0.7.2
- Bump version number for bug fix in imgViewer

### 0.7.3
- Add onUpdateMarker callback
- Add example with custom onUpdateMarker
- Fix so that zoom option value reflects zoom of underlying imgViewer


11 changes: 6 additions & 5 deletions dist/imgNotes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! jQuery imgNotes - v0.7.2 - 2014-07-28
/*! jQuery imgNotes - v0.7.3 - 2014-07-30
* https://github.com/waynegm/imgNotes
* Copyright (c) 2014 Wayne Mogg; Licensed MIT */
;(function($) {
Expand Down Expand Up @@ -92,9 +92,9 @@
/*
* Default callback when the markers are repainted
*/
onUpdateMarker: function(ev, data) {
var $elem = $(data.marker);
var $img = $(data.img);
onUpdateMarker: function(elem) {
var $elem = $(elem);
var $img = $(this.img);
var pos = $img.imgViewer("imgToView", $elem.data("relx"), $elem.data("rely"));
if (pos) {
$elem.css({
Expand Down Expand Up @@ -134,7 +134,8 @@
onUpdate: function(ev, imgv) {
self.options.zoom = imgv.options.zoom;
$.each(self.notes, function() {
self._trigger("onUpdateMarker", ev, {"img": self.img, "marker": this});
self.options.onUpdateMarker.call(self, this);

});
},
zoom: self.options.zoom,
Expand Down
4 changes: 2 additions & 2 deletions dist/imgNotes.min.js

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

6 changes: 3 additions & 3 deletions examples/custom_updatemarker.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ <h1 style="text-align: center;">jQuery imgNotes - Custom Update Marker Example</
});
return elem;
},
onUpdateMarker: function(ev, data) {
var $elem = $(data.marker);
var $img = $(data.img);
onUpdateMarker: function(elem) {
var $elem = $(elem);
var $img = $(this.img);
var pos = $img.imgViewer("imgToView", $elem.data("relx"), $elem.data("rely"));
var zoom = $img.imgViewer("option", "zoom");
if (pos) {
Expand Down
2 changes: 1 addition & 1 deletion imgNotes.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "imgNotes",
"title": "jQuery imgNotes",
"description": "Extension of the jQuery imgViewer plugin to add markers and notes to the image.",
"version": "0.7.2",
"version": "0.7.3",
"homepage": "",
"author": {
"name": "Wayne Mogg"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-imgNotes-plugin",
"version": "0.7.2",
"version": "0.7.3",
"engines": {
"node": ">= 0.8.0"
},
Expand Down
9 changes: 5 additions & 4 deletions src/imgNotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@
/*
* Default callback when the markers are repainted
*/
onUpdateMarker: function(ev, data) {
var $elem = $(data.marker);
var $img = $(data.img);
onUpdateMarker: function(elem) {
var $elem = $(elem);
var $img = $(this.img);
var pos = $img.imgViewer("imgToView", $elem.data("relx"), $elem.data("rely"));
if (pos) {
$elem.css({
Expand Down Expand Up @@ -138,7 +138,8 @@
onUpdate: function(ev, imgv) {
self.options.zoom = imgv.options.zoom;
$.each(self.notes, function() {
self._trigger("onUpdateMarker", ev, {"img": self.img, "marker": this});
self.options.onUpdateMarker.call(self, this);

});
},
zoom: self.options.zoom,
Expand Down

0 comments on commit 1ed711c

Please sign in to comment.