-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ | |
Copyright 2013-2014, Pavel Kityan ([email protected]) | ||
Licensed under the MIT license. | ||
Version: 2.2.0b | ||
Build date: 10 September 2014 | ||
Version: 2.3.0b | ||
Build date: 29 September 2014 | ||
*/ | ||
|
||
(function (root, factory) { | ||
|
@@ -27,6 +27,7 @@ | |
|
||
var development = {colorize: false, log: false, showTmpDiv: false}; | ||
var config = {} ; | ||
var onQueueEmptyCallback; | ||
|
||
// set default values | ||
configure({ | ||
|
@@ -549,7 +550,8 @@ function setAllChildren(obj, param, value) { | |
* @param {string} selector - selector for jQuery | ||
* @param {string} markup - value for adding/replacing element's attribute "data-morfana-markup". | ||
*/ | ||
function draw (selector, markup) { | ||
function draw (selector, markup, callback) { | ||
onQueueEmptyCallback = (callback) ? callback : undefined; | ||
if (selector) { | ||
if (markup) { | ||
$(selector).data('morfana-markup', markup); | ||
|
@@ -587,7 +589,12 @@ function doQueue() { | |
} | ||
if (qty > 1) { // more than 1 berfore queue.pop()? | ||
setTimeout(doQueue, 10); | ||
} | ||
} else { // queue empty | ||
if (onQueueEmptyCallback && typeof onQueueEmptyCallback == 'function'){ | ||
onQueueEmptyCallback(); | ||
onQueueEmptyCallback = undefined; | ||
} | ||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.7/jquery.min.js"></script> | ||
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/rangy/1.2.3/rangy-core.js"></script> | ||
<script type="text/javascript" src="./../morfana.js"></script> | ||
<script type="text/x-morfana-config">Morfana.configure({autoStart: false});</script> | ||
</head> | ||
<body> | ||
<span class="test1" style="font-size: 25px; color: red;" data-morfana-markup="ok:3-5;ok:9-12;ko:1-2;ko:6-8;">двумя́ста́ми</span> | ||
<span class="test1" style="font-size: 25px; color: red;" data-morfana-markup="ok:3-5;ok:9-12;ko:1-2;ko:6-8;">двумя́ста́ми</span> | ||
<span class="next">next</span> | ||
|
||
|
||
<script type="text/javascript"> | ||
$(document).ready(function(){ | ||
Morfana.draw('.test1', false, function(){console.log('callback1');}); | ||
|
||
$('.next').on('click', function(){ | ||
Morfana.draw('.test1', 'ko:1-1;ko:2-2'); | ||
}); | ||
|
||
}); | ||
</script> | ||
</body> | ||
</html> | ||
|
||
|