Merge remote-tracking branch 'dseif/t469' into develop

This commit is contained in:
Jon Buckley 2011-06-03 16:45:42 -04:00
Родитель 5ee6491d53 192aff6435
Коммит 29402e7d18
1 изменённых файлов: 30 добавлений и 14 удалений

Просмотреть файл

@ -86,9 +86,11 @@
Popcorn.plugin( 'mustache' , function( options ) {
Popcorn.getScript('https://github.com/janl/mustache.js/raw/master/mustache.js');
var getData, data, getTemplate, template, loaded = false;
var getData, data, getTemplate, template;
Popcorn.getScript('https://github.com/janl/mustache.js/raw/master/mustache.js', function() {
loaded = true;
});
var shouldReload = !!options.dynamic,
typeOfTemplate = typeof options.template,
@ -103,7 +105,7 @@
} else if ( typeOfTemplate === 'string' ) {
template = options.template;
} else {
throw 'Mustache Plugin Error: options.template must be a String or a Function.';
Popcorn.error( 'Mustache Plugin Error: options.template must be a String or a Function.' );
}
if ( typeOfData === 'function' ) {
@ -117,24 +119,38 @@
} else if ( typeOfData === 'object' ) {
data = options.data;
} else {
throw 'Mustache Plugin Error: options.data must be a String, Object, or Function.';
Popcorn.error( 'Mustache Plugin Error: options.data must be a String, Object, or Function.' );
}
return {
start: function( event, options ) {
// if dynamic, freshen json data on every call to start, just in case.
if ( getData ) {
data = getData( options );
var interval = function() {
if( !loaded ) {
setTimeout( function() {
interval();
}, 10 );
} else {
// if dynamic, freshen json data on every call to start, just in case.
if ( getData ) {
data = getData( options );
}
if ( getTemplate ) {
template = getTemplate( options );
}
var html = Mustache.to_html( template,
data
).replace( /^\s*/mg, '' );
document.getElementById( options.target ).innerHTML = html;
}
}
if ( getTemplate ) {
template = getTemplate( options );
}
interval();
var html = Mustache.to_html( template,
data
).replace( /^\s*/mg, '' );
document.getElementById( options.target ).innerHTML = html;
},
end: function( event, options ) {