Skip to content

Commit 30593a0

Browse files
committed
Added getData method to retrive data
1 parent e66bc46 commit 30593a0

File tree

4 files changed

+43
-6
lines changed

4 files changed

+43
-6
lines changed

demo/index.html

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,24 @@
55
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
66

77
<script src="media/jquery.min.js"></script>
8-
<script src="../jquery.textover.js"></script>
8+
<script src="../jquery.textover.min.js"></script>
99
<script type="text/javascript">
1010
jQuery(function($){
1111

12+
var textover_api;
13+
1214
// How easy is this??
13-
$('#target').TextOver();
15+
$('#target').TextOver({}, function() {
16+
textover_api = this;
17+
});
18+
19+
$('#show').click(function () {
20+
html = '';
21+
$.each(textover_api.getData(), function() {
22+
html += 'Text &raquo; ' + this.text + ' Left &raquo; ' + this.left + ' Top &raquo; ' + this.top + '<br />';
23+
});
24+
$('#data').html(html).show();
25+
});
1426

1527
});
1628

@@ -23,7 +35,7 @@
2335

2436
<div class="container">
2537
<div class="row">
26-
<div class="span12">
38+
<div class="span11">
2739
<div class="demo-box">
2840

2941
<div class="page-header">
@@ -36,10 +48,13 @@ <h1>jQuery Text Over</h1>
3648
<div class="description">
3749
<p>
3850
<b>This example demonstrates the default behavior of jQuery Text Over.</b><br />
39-
Click on the top of the image and type the text. For add another one click and write again. Esc will remove your last typed text.
51+
Click on the top of the image and type the text. For add another one click and type again. Esc will remove your last typed text.
4052
</p>
4153
</div>
4254

55+
<div id="data" class="well"></div>
56+
<button id="show">Show Data</button>
57+
4358
<div class="clearfix"></div>
4459

4560
</div>

demo/media/demos.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@
1111
box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.25);
1212
padding: 1em 2em 2em;
1313
}
14+
15+
#data {
16+
display: none;
17+
}

jquery.textover.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,26 @@
2828
'resize': 'none'
2929
};
3030

31+
var $img = $(obj);
32+
3133
getPos = function(obj) {
3234
var pos = $(obj).offset();
3335
return [pos.left, pos.top];
3436
};
3537

38+
getData = function() {
39+
removeEmpty();
40+
data = [];
41+
imgPos = getPos($img);
42+
$.each(messages, function() {
43+
pos = getPos(this);
44+
textLeft = pos[0] - imgPos[0];
45+
textTop = pos[1] - imgPos[1];
46+
data.push({ 'text': this.val(), 'left': textLeft, 'top': textTop });
47+
});
48+
return data;
49+
}
50+
3651
mouseAbs = function(e) {
3752
return [e.pageX, e.pageY];
3853
};
@@ -111,7 +126,6 @@
111126

112127
api = $.TextOver(this, options);
113128
if ($.isFunction(callback)) callback.call(api);
114-
115129

116130
// Return "this" so the object is chainable (jQuery-style)
117131
return this;

jquery.textover.min.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)