Browse Source

Added a JSONP variation to allow loading of data across domains! Reference issue #20 and #23

pull/197/head
Zach Wise 13 years ago
parent
commit
bf3926555e
  1. 58
      README.markdown
  2. 9
      compiled/js/timeline-min.js
  3. 623
      compiled/js/timeline.js
  4. 2
      examples/example_jquery_load.html
  5. 3
      examples/example_json.html
  6. 247
      examples/example_jsonp.jsonp
  7. 47
      examples/model.jsonp
  8. 2
      source/js/Core
  9. 10
      source/js/VMM.Timeline.DataObj.js

58
README.markdown

@ -223,6 +223,64 @@ Here is the full model:
} }
} }
``` ```
### JSONP :
Timeline can use a variation of JSONP to allow you to easily load data across different domains.
To allow this to happen, the file must end with the extention `.jsonp`
Here is the full model:
```javascript
storyjs_jsonp_data = {
"timeline":
{
"headline":"The Main Timeline Headline Goes here",
"type":"default",
"text":"<p>Intro body text goes here, some HTML is ok</p>",
"asset": {
"media":"http://yourdomain_or_socialmedialink_goes_here.jpg",
"credit":"Credit Name Goes Here",
"caption":"Caption text goes here"
},
"date": [
{
"startDate":"2011,12,10",
"endDate":"2011,12,11",
"headline":"Headline Goes Here",
"text":"<p>Body text goes here, some HTML is OK</p>",
"tag":"This is Optional",
"asset": {
"media":"http://twitter.com/ArjunaSoriano/status/164181156147900416",
"thumbnail":"optional-32x32px.jpg",
"credit":"Credit Name Goes Here",
"caption":"Caption text goes here"
}
}
],
"era": [
{
"startDate":"2011,12,10",
"endDate":"2011,12,11",
"headline":"Headline Goes Here",
"tag":"This is Optional"
}
],
"chart": [
{
"startDate":"2011,12,10",
"endDate":"2011,12,11",
"headline":"Headline Goes Here",
"value":"28"
}
]
}
}
```
### Google Docs: ### Google Docs:
If you don’t want to mess with JSON, fire up Google Docs and build your If you don’t want to mess with JSON, fire up Google Docs and build your

9
compiled/js/timeline-min.js vendored

File diff suppressed because one or more lines are too long

623
compiled/js/timeline.js

@ -2042,254 +2042,455 @@ if(typeof VMM != 'undefined' && typeof VMM.Util == 'undefined') {
} }
/*********************************************** /***********************************************
Begin VMM.LoadLib.js Begin LazyLoad.js
***********************************************/ ***********************************************/
/* * LoadLib Based on LazyLoad by Ryan Grove /*jslint browser: true, eqeqeq: true, bitwise: true, newcap: true, immed: true, regexp: false */
* https://github.com/rgrove/lazyload/
* Copyright (c) 2011 Ryan Grove <ryan@wonko.com>
* All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy of /**
* this software and associated documentation files (the 'Software'), to deal in LazyLoad makes it easy and painless to lazily load one or more external
* the Software without restriction, including without limitation the rights to JavaScript or CSS files on demand either during or after the rendering of a web
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of page.
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions: Supported browsers include Firefox 2+, IE6+, Safari 3+ (including Mobile
Safari), Google Chrome, and Opera 9+. Other browsers may or may not work and
are not officially supported.
Visit https://github.com/rgrove/lazyload/ for more info.
Copyright (c) 2011 Ryan Grove <ryan@wonko.com>
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the 'Software'), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@module lazyload
@class LazyLoad
@static
@version 2.0.3 (git)
*/
* The above copyright notice and this permission notice shall be included in all LazyLoad = (function (doc) {
* copies or substantial portions of the Software. // -- Private Variables ------------------------------------------------------
================================================== */ // User agent and feature test information.
window.loadedJS = []; var env,
// Reference to the <head> element (populated lazily).
head,
if(typeof VMM != 'undefined' && typeof VMM.LoadLib == 'undefined') { // Requests currently in progress, if any.
//VMM.LoadLib.js('http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', onJQueryLoaded); pending = {},
//VMM.LoadLib.css('http://someurl.css', onCSSLoaded);
// Number of times we've polled to check whether a pending stylesheet has
// finished loading. If this gets too high, we're probably stalled.
pollCount = 0,
// Queued requests.
queue = {css: [], js: []},
VMM.LoadLib = (function (doc) { // Reference to the browser's list of stylesheets.
var env, styleSheets = doc.styleSheets;
head,
pending = {},
pollCount = 0,
queue = {css: [], js: []},
styleSheets = doc.styleSheets;
var loaded_Array = []; // -- Private Methods --------------------------------------------------------
function isLoaded(url) { /**
var has_been_loaded = false; Creates and returns an HTML element with the specified name and attributes.
for(var i=0; i<loaded_Array.length; i++) {
if (loaded_Array[i] == url) {
has_been_loaded = true;
}
}
if (!has_been_loaded) {
loaded_Array.push(url);
}
return has_been_loaded;
}
function createNode(name, attrs) { @method createNode
var node = doc.createElement(name), attr; @param {String} name element name
@param {Object} attrs name/value mapping of element attributes
@return {HTMLElement}
@private
*/
function createNode(name, attrs) {
var node = doc.createElement(name), attr;
for (attr in attrs) { for (attr in attrs) {
if (attrs.hasOwnProperty(attr)) { if (attrs.hasOwnProperty(attr)) {
node.setAttribute(attr, attrs[attr]); node.setAttribute(attr, attrs[attr]);
} }
} }
return node; return node;
} }
function finish(type) { /**
var p = pending[type], Called when the current pending resource of the specified type has finished
callback, loading. Executes the associated callback (if any) and loads the next
urls; resource in the queue.
if (p) { @method finish
callback = p.callback; @param {String} type resource type ('css' or 'js')
urls = p.urls; @private
urls.shift(); */
pollCount = 0; function finish(type) {
if (!urls.length) { var p = pending[type],
callback && callback.call(p.context, p.obj); callback,
pending[type] = null; urls;
queue[type].length && load(type);
} if (p) {
} callback = p.callback;
} urls = p.urls;
function getEnv() { urls.shift();
var ua = navigator.userAgent; pollCount = 0;
env = { // If this is the last of the pending URLs, execute the callback and
// start the next request in the queue (if any).
async: doc.createElement('script').async === true if (!urls.length) {
}; callback && callback.call(p.context, p.obj);
pending[type] = null;
(env.webkit = /AppleWebKit\//.test(ua)) queue[type].length && load(type);
|| (env.ie = /MSIE/.test(ua)) }
|| (env.opera = /Opera/.test(ua)) }
|| (env.gecko = /Gecko\//.test(ua)) }
|| (env.unknown = true);
}
function load(type, urls, callback, obj, context) {
var _finish = function () { finish(type); },
isCSS = type === 'css',
nodes = [],
i, len, node, p, pendingUrls, url;
env || getEnv();
if (urls) {
urls = typeof urls === 'string' ? [urls] : urls.concat();
if (isCSS || env.async || env.gecko || env.opera) {
queue[type].push({
urls : urls,
callback: callback,
obj : obj,
context : context
});
} else {
for (i = 0, len = urls.length; i < len; ++i) {
queue[type].push({
urls : [urls[i]],
callback: i === len - 1 ? callback : null,
obj : obj,
context : context
});
}
}
}
if (pending[type] || !(p = pending[type] = queue[type].shift())) { /**
return; Populates the <code>env</code> variable with user agent and feature test
} information.
@method getEnv
@private
*/
function getEnv() {
var ua = navigator.userAgent;
env = {
// True if this browser supports disabling async mode on dynamically
// created script nodes. See
// http://wiki.whatwg.org/wiki/Dynamic_Script_Execution_Order
async: doc.createElement('script').async === true
};
head || (head = doc.head || doc.getElementsByTagName('head')[0]); (env.webkit = /AppleWebKit\//.test(ua))
pendingUrls = p.urls; || (env.ie = /MSIE/.test(ua))
|| (env.opera = /Opera/.test(ua))
for (i = 0, len = pendingUrls.length; i < len; ++i) { || (env.gecko = /Gecko\//.test(ua))
url = pendingUrls[i]; || (env.unknown = true);
}
if (isCSS) {
node = env.gecko ? createNode('style') : createNode('link', {
href: url,
rel : 'stylesheet'
});
} else {
node = createNode('script', {src: url});
node.async = false;
}
node.className = 'lazyload';
node.setAttribute('charset', 'utf-8');
if (env.ie && !isCSS) {
node.onreadystatechange = function () {
if (/loaded|complete/.test(node.readyState)) {
node.onreadystatechange = null;
_finish();
}
};
} else if (isCSS && (env.gecko || env.webkit)) {
if (env.webkit) {
p.urls[i] = node.href;
pollWebKit();
} else {
node.innerHTML = '@import "' + url + '";';
pollGecko(node);
}
} else {
node.onload = node.onerror = _finish;
}
nodes.push(node);
}
for (i = 0, len = nodes.length; i < len; ++i) { /**
head.appendChild(nodes[i]); Loads the specified resources, or the next resource of the specified type
} in the queue if no resources are specified. If a resource of the specified
} type is already being loaded, the new request will be queued until the
first request has been finished.
When an array of resource URLs is specified, those URLs will be loaded in
parallel if it is possible to do so while preserving execution order. All
browsers support parallel loading of CSS, but only Firefox and Opera
support parallel loading of scripts. In other browsers, scripts will be
queued and loaded one at a time to ensure correct execution order.
@method load
@param {String} type resource type ('css' or 'js')
@param {String|Array} urls (optional) URL or array of URLs to load
@param {Function} callback (optional) callback function to execute when the
resource is loaded
@param {Object} obj (optional) object to pass to the callback function
@param {Object} context (optional) if provided, the callback function will
be executed in this object's context
@private
*/
function load(type, urls, callback, obj, context) {
var _finish = function () { finish(type); },
isCSS = type === 'css',
nodes = [],
i, len, node, p, pendingUrls, url;
env || getEnv();
if (urls) {
// If urls is a string, wrap it in an array. Otherwise assume it's an
// array and create a copy of it so modifications won't be made to the
// original.
urls = typeof urls === 'string' ? [urls] : urls.concat();
// Create a request object for each URL. If multiple URLs are specified,
// the callback will only be executed after all URLs have been loaded.
//
// Sadly, Firefox and Opera are the only browsers capable of loading
// scripts in parallel while preserving execution order. In all other
// browsers, scripts must be loaded sequentially.
//
// All browsers respect CSS specificity based on the order of the link
// elements in the DOM, regardless of the order in which the stylesheets
// are actually downloaded.
if (isCSS || env.async || env.gecko || env.opera) {
// Load in parallel.
queue[type].push({
urls : urls,
callback: callback,
obj : obj,
context : context
});
} else {
// Load sequentially.
for (i = 0, len = urls.length; i < len; ++i) {
queue[type].push({
urls : [urls[i]],
callback: i === len - 1 ? callback : null, // callback is only added to the last URL
obj : obj,
context : context
});
}
}
}
function pollGecko(node) { // If a previous load request of this type is currently in progress, we'll
var hasRules; // wait our turn. Otherwise, grab the next item in the queue.
if (pending[type] || !(p = pending[type] = queue[type].shift())) {
return;
}
try { head || (head = doc.head || doc.getElementsByTagName('head')[0]);
pendingUrls = p.urls;
hasRules = !!node.sheet.cssRules; for (i = 0, len = pendingUrls.length; i < len; ++i) {
} catch (ex) { url = pendingUrls[i];
pollCount += 1;
if (pollCount < 200) { if (isCSS) {
setTimeout(function () { pollGecko(node); }, 50); node = env.gecko ? createNode('style') : createNode('link', {
} else { href: url,
rel : 'stylesheet'
});
} else {
node = createNode('script', {src: url});
node.async = false;
}
hasRules && finish('css'); node.className = 'lazyload';
} node.setAttribute('charset', 'utf-8');
return; if (env.ie && !isCSS) {
} node.onreadystatechange = function () {
if (/loaded|complete/.test(node.readyState)) {
node.onreadystatechange = null;
_finish();
}
};
} else if (isCSS && (env.gecko || env.webkit)) {
// Gecko and WebKit don't support the onload event on link nodes.
if (env.webkit) {
// In WebKit, we can poll for changes to document.styleSheets to
// figure out when stylesheets have loaded.
p.urls[i] = node.href; // resolve relative URLs (or polling won't work)
pollWebKit();
} else {
// In Gecko, we can import the requested URL into a <style> node and
// poll for the existence of node.sheet.cssRules. Props to Zach
// Leatherman for calling my attention to this technique.
node.innerHTML = '@import "' + url + '";';
pollGecko(node);
}
} else {
node.onload = node.onerror = _finish;
}
finish('css'); nodes.push(node);
} }
function pollWebKit() { for (i = 0, len = nodes.length; i < len; ++i) {
var css = pending.css, i; head.appendChild(nodes[i]);
}
}
if (css) { /**
i = styleSheets.length; Begins polling to determine when the specified stylesheet has finished loading
in Gecko. Polling stops when all pending stylesheets have loaded or after 10
seconds (to prevent stalls).
Thanks to Zach Leatherman for calling my attention to the @import-based
cross-domain technique used here, and to Oleg Slobodskoi for an earlier
same-domain implementation. See Zach's blog for more details:
http://www.zachleat.com/web/2010/07/29/load-css-dynamically/
@method pollGecko
@param {HTMLElement} node Style node to poll.
@private
*/
function pollGecko(node) {
var hasRules;
try {
// We don't really need to store this value or ever refer to it again, but
// if we don't store it, Closure Compiler assumes the code is useless and
// removes it.
hasRules = !!node.sheet.cssRules;
} catch (ex) {
// An exception means the stylesheet is still loading.
pollCount += 1;
if (pollCount < 200) {
setTimeout(function () { pollGecko(node); }, 50);
} else {
// We've been polling for 10 seconds and nothing's happened. Stop
// polling and finish the pending requests to avoid blocking further
// requests.
hasRules && finish('css');
}
while (--i >= 0) { return;
if (styleSheets[i].href === css.urls[0]) { }
finish('css');
break;
}
}
pollCount += 1; // If we get here, the stylesheet has loaded.
finish('css');
}
if (css) { /**
if (pollCount < 200) { Begins polling to determine when pending stylesheets have finished loading
setTimeout(pollWebKit, 50); in WebKit. Polling stops when all pending stylesheets have loaded or after 10
} else { seconds (to prevent stalls).
@method pollWebKit
@private
*/
function pollWebKit() {
var css = pending.css, i;
if (css) {
i = styleSheets.length;
// Look for a stylesheet matching the pending URL.
while (--i >= 0) {
if (styleSheets[i].href === css.urls[0]) {
finish('css');
break;
}
}
finish('css'); pollCount += 1;
}
} if (css) {
} if (pollCount < 200) {
} setTimeout(pollWebKit, 50);
} else {
// We've been polling for 10 seconds and nothing's happened, which may
// indicate that the stylesheet has been removed from the document
// before it had a chance to load. Stop polling and finish the pending
// request to prevent blocking further requests.
finish('css');
}
}
}
}
return {
/**
Requests the specified CSS URL or URLs and executes the specified
callback (if any) when they have finished loading. If an array of URLs is
specified, the stylesheets will be loaded in parallel and the callback
will be executed after all stylesheets have finished loading.
@method css
@param {String|Array} urls CSS URL or array of CSS URLs to load
@param {Function} callback (optional) callback function to execute when
the specified stylesheets are loaded
@param {Object} obj (optional) object to pass to the callback function
@param {Object} context (optional) if provided, the callback function
will be executed in this object's context
@static
*/
css: function (urls, callback, obj, context) {
load('css', urls, callback, obj, context);
},
/**
Requests the specified JavaScript URL or URLs and executes the specified
callback (if any) when they have finished loading. If an array of URLs is
specified and the browser supports it, the scripts will be loaded in
parallel and the callback will be executed after all scripts have
finished loading.
Currently, only Firefox and Opera support parallel loading of scripts while
preserving execution order. In other browsers, scripts will be
queued and loaded one at a time to ensure correct execution order.
@method js
@param {String|Array} urls JS URL or array of JS URLs to load
@param {Function} callback (optional) callback function to execute when
the specified scripts are loaded
@param {Object} obj (optional) object to pass to the callback function
@param {Object} context (optional) if provided, the callback function
will be executed in this object's context
@static
*/
js: function (urls, callback, obj, context) {
load('js', urls, callback, obj, context);
}
};
})(this.document);
/***********************************************
Begin VMM.LoadLib.js
***********************************************/
/*
LoadLib
Designed and built by Zach Wise digitalartwork.net
*/
/* * CodeKit Import
* http://incident57.com/codekit/
================================================== */
// @codekit-prepend "../Library/LazyLoad.js";
LoadLib = (function (doc) {
var loaded = [];
function isLoaded(url) {
return { var i = 0,
has_loaded = false;
for (i = 0; i < loaded; i++) {
if (loaded[i] == url) {
has_loaded = true;
}
}
if (has_loaded) {
return true;
} else {
loaded.push(url);
return false;
}
}
return {
css: function (urls, callback, obj, context) { css: function (urls, callback, obj, context) {
if (isLoaded(urls)) { if (!isLoaded(urls)) {
return callback; LazyLoad.css(urls, callback, obj, context);
} else {
load('css', urls, callback, obj, context);
} }
}, },
js: function (urls, callback, obj, context) { js: function (urls, callback, obj, context) {
if (isLoaded(urls)) { if (!isLoaded(urls)) {
return callback; LazyLoad.js(urls, callback, obj, context);
} else {
load('js', urls, callback, obj, context);
} }
} }
};
}; })(this.document);
})(this.document);
}
/*********************************************** /***********************************************
@ -8184,9 +8385,12 @@ if (typeof VMM.Timeline !== 'undefined' && typeof VMM.Timeline.DataObj == 'undef
trace("DATA SOURCE: STORIFY"); trace("DATA SOURCE: STORIFY");
VMM.Timeline.DataObj.model.storify.getData(raw_data); VMM.Timeline.DataObj.model.storify.getData(raw_data);
//http://api.storify.com/v1/stories/number10gov/g8-and-nato-chicago-summit //http://api.storify.com/v1/stories/number10gov/g8-and-nato-chicago-summit
} else if (raw_data.match(".jsonp")) {
trace("DATA SOURCE: JSONP");
LoadLib.js(raw_data, VMM.Timeline.DataObj.onJSONPLoaded);
} else { } else {
trace("DATA SOURCE: JSON"); trace("DATA SOURCE: JSON");
VMM.getJSON(raw_data, VMM.Timeline.DataObj.parseJSON); VMM.getJSON(raw_data + "?callback=onJSONP_Data", VMM.Timeline.DataObj.parseJSON);
} }
} else if (type.of(raw_data) == "html") { } else if (type.of(raw_data) == "html") {
trace("DATA SOURCE: HTML"); trace("DATA SOURCE: HTML");
@ -8197,6 +8401,11 @@ if (typeof VMM.Timeline !== 'undefined' && typeof VMM.Timeline.DataObj == 'undef
}, },
onJSONPLoaded: function() {
trace("JSONP IS LOADED");
VMM.fireEvent(global, VMM.Timeline.Config.events.data_ready, storyjs_jsonp_data);
},
parseHTML: function (d) { parseHTML: function (d) {
trace("parseHTML"); trace("parseHTML");
trace("WARNING: THIS IS STILL ALPHA AND WILL NOT WORK WITH ID's other than #timeline"); trace("WARNING: THIS IS STILL ALPHA AND WILL NOT WORK WITH ID's other than #timeline");

2
examples/example_jquery_load.html

@ -12,7 +12,6 @@
<script type="text/javascript" src="../compiled/js/storyjs-embed.js"></script> <script type="text/javascript" src="../compiled/js/storyjs-embed.js"></script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
createStoryJS({ createStoryJS({
type: 'timeline', type: 'timeline',
width: '800', width: '800',
@ -21,7 +20,6 @@
embed_id: 'my-timeline', embed_id: 'my-timeline',
debug: true debug: true
}); });
}); });
</script> </script>
<!-- END TimelineJS --> <!-- END TimelineJS -->

3
examples/example_json.html

@ -22,7 +22,8 @@
var timeline_config = { var timeline_config = {
width: "100%", width: "100%",
height: "100%", height: "100%",
source: 'example_json.json' source: 'example_jsonp.jsonp',
debug: true
} }
</script> </script>
<script type="text/javascript" src="../compiled/js/storyjs-embed.js"></script> <script type="text/javascript" src="../compiled/js/storyjs-embed.js"></script>

247
examples/example_jsonp.jsonp

@ -0,0 +1,247 @@
storyjs_jsonp_data = {
"timeline":
{
"headline":"Sh*t People Say",
"type":"default",
"text":"People say stuff",
"date": [
{
"startDate":"2012,1,26",
"endDate":"2012,1,27",
"headline":"Sh*t Politicians Say",
"text":"<p>In true political fashion, his character rattles off common jargon heard from people running for office.</p>",
"asset":
{
"media":"http://youtu.be/u4XpeU9erbg",
"credit":"",
"caption":""
}
},
{
"startDate":"2012,1,10",
"headline":"Sh*t Nobody Says",
"text":"<p>Have you ever heard someone say “can I burn a copy of your Nickelback CD?” or “my Bazooka gum still has flavor!” Nobody says that.</p>",
"asset":
{
"media":"http://youtu.be/f-x8t0JOnVw",
"credit":"",
"caption":""
}
},
{
"startDate":"2012,1,26",
"headline":"Sh*t Chicagoans Say",
"text":"",
"asset":
{
"media":"http://youtu.be/Ofy5gNkKGOo",
"credit":"",
"caption":""
}
},
{
"startDate":"2011,12,12",
"headline":"Sh*t Girls Say",
"text":"",
"asset":
{
"media":"http://youtu.be/u-yLGIH7W9Y",
"credit":"",
"caption":"Writers & Creators: Kyle Humphrey & Graydon Sheppard"
}
},
{
"startDate":"2012,1,4",
"headline":"Sh*t Broke People Say",
"text":"",
"asset":
{
"media":"http://youtu.be/zyyalkHjSjo",
"credit":"",
"caption":""
}
},
{
"startDate":"2012,1,4",
"headline":"Sh*t Silicon Valley Says",
"text":"",
"asset":
{
"media":"http://youtu.be/BR8zFANeBGQ",
"credit":"",
"caption":"written, filmed, and edited by Kate Imbach & Tom Conrad"
}
},
{
"startDate":"2011,12,25",
"headline":"Sh*t Vegans Say",
"text":"",
"asset":
{
"media":"http://youtu.be/OmWFnd-p0Lw",
"credit":"",
"caption":""
}
},
{
"startDate":"2012,1,23",
"headline":"Sh*t Graphic Designers Say",
"text":"",
"asset":
{
"media":"http://youtu.be/KsT3QTmsN5Q",
"credit":"",
"caption":""
}
},
{
"startDate":"2011,12,30",
"headline":"Sh*t Wookiees Say",
"text":"",
"asset":
{
"media":"http://youtu.be/vJpBCzzcSgA",
"credit":"",
"caption":""
}
},
{
"startDate":"2012,1,17",
"headline":"Sh*t People Say About Sh*t People Say Videos",
"text":"",
"asset":
{
"media":"http://youtu.be/c9ehQ7vO7c0",
"credit":"",
"caption":""
}
},
{
"startDate":"2012,1,20",
"headline":"Sh*t Social Media Pros Say",
"text":"",
"asset":
{
"media":"http://youtu.be/eRQe-BT9g_U",
"credit":"",
"caption":""
}
},
{
"startDate":"2012,1,11",
"headline":"Sh*t Old People Say About Computers",
"text":"",
"asset":
{
"media":"http://youtu.be/HRmc5uuoUzA",
"credit":"",
"caption":""
}
},
{
"startDate":"2012,1,11",
"headline":"Sh*t College Freshmen Say",
"text":"",
"asset":
{
"media":"http://youtu.be/rwozXzo0MZk",
"credit":"",
"caption":""
}
},
{
"startDate":"2011,12,16",
"headline":"Sh*t Girls Say - Episode 2",
"text":"",
"asset":
{
"media":"http://youtu.be/kbovd-e-hRg",
"credit":"",
"caption":"Writers & Creators: Kyle Humphrey & Graydon Sheppard"
}
},
{
"startDate":"2011,12,24",
"headline":"Sh*t Girls Say - Episode 3 Featuring Juliette Lewis",
"text":"",
"asset":
{
"media":"http://youtu.be/bDHUhT71JN8",
"credit":"",
"caption":"Writers & Creators: Kyle Humphrey & Graydon Sheppard"
}
},
{
"startDate":"2012,1,27",
"headline":"Sh*t Web Designers Say",
"text":"",
"asset":
{
"media":"http://youtu.be/MEOb_meSHhQ",
"credit":"",
"caption":""
}
},
{
"startDate":"2012,1,12",
"headline":"Sh*t Hipsters Say",
"text":"No meme is complete without a bit of hipster-bashing.",
"asset":
{
"media":"http://youtu.be/FUhrSVyu0Kw",
"credit":"",
"caption":"Written, Directed, Conceptualized and Performed by Carrie Valentine and Jessica Katz"
}
},
{
"startDate":"2012,1,6",
"headline":"Sh*t Cats Say",
"text":"No meme is complete without cats. This had to happen, obviously.",
"asset":
{
"media":"http://youtu.be/MUX58Vi-YLg",
"credit":"",
"caption":""
}
},
{
"startDate":"2012,1,21",
"headline":"Sh*t Cyclists Say",
"text":"",
"asset":
{
"media":"http://youtu.be/GMCkuqL9IcM",
"credit":"",
"caption":"Video script, production, and editing by Allen Krughoff of Hardcastle Photography"
}
},
{
"startDate":"2011,12,30",
"headline":"Sh*t Yogis Say",
"text":"",
"asset":
{
"media":"http://youtu.be/IMC1_RH_b3k",
"credit":"",
"caption":""
}
},
{
"startDate":"2012,1,18",
"headline":"Sh*t New Yorkers Say",
"text":"",
"asset":
{
"media":"http://youtu.be/yRvJylbSg7o",
"credit":"",
"caption":"Directed and Edited by Matt Mayer, Produced by Seth Keim, Written by Eliot Glazer. Featuring Eliot and Ilana Glazer, who are siblings, not married."
}
}
]
}
}

47
examples/model.jsonp

@ -0,0 +1,47 @@
storyjs_jsonp_data = {
"timeline":
{
"headline":"The Main Timeline Headline Goes here",
"type":"default",
"text":"<p>Intro body text goes here, some HTML is ok</p>",
"asset": {
"media":"http://yourdomain_or_socialmedialink_goes_here.jpg",
"credit":"Credit Name Goes Here",
"caption":"Caption text goes here"
},
"date": [
{
"startDate":"2011,12,10",
"endDate":"2011,12,11",
"headline":"Headline Goes Here",
"text":"<p>Body text goes here, some HTML is OK</p>",
"tag":"This is Optional",
"asset": {
"media":"http://twitter.com/ArjunaSoriano/status/164181156147900416",
"thumbnail":"optional-32x32px.jpg",
"credit":"Credit Name Goes Here",
"caption":"Caption text goes here"
}
}
],
"era": [
{
"startDate":"2011,12,10",
"endDate":"2011,12,11",
"headline":"Headline Goes Here",
"tag":"This is Optional"
}
],
"chart": [
{
"startDate":"2011,12,10",
"endDate":"2011,12,11",
"headline":"Headline Goes Here",
"value":"28"
}
]
}
}

2
source/js/Core

@ -1 +1 @@
Subproject commit 36a2a055a1c93f8876e4faf8490e49339df73f66 Subproject commit 9288948b6e71776c12fd3a370622e35e053db9da

10
source/js/VMM.Timeline.DataObj.js

@ -22,9 +22,12 @@ if (typeof VMM.Timeline !== 'undefined' && typeof VMM.Timeline.DataObj == 'undef
trace("DATA SOURCE: STORIFY"); trace("DATA SOURCE: STORIFY");
VMM.Timeline.DataObj.model.storify.getData(raw_data); VMM.Timeline.DataObj.model.storify.getData(raw_data);
//http://api.storify.com/v1/stories/number10gov/g8-and-nato-chicago-summit //http://api.storify.com/v1/stories/number10gov/g8-and-nato-chicago-summit
} else if (raw_data.match(".jsonp")) {
trace("DATA SOURCE: JSONP");
LoadLib.js(raw_data, VMM.Timeline.DataObj.onJSONPLoaded);
} else { } else {
trace("DATA SOURCE: JSON"); trace("DATA SOURCE: JSON");
VMM.getJSON(raw_data, VMM.Timeline.DataObj.parseJSON); VMM.getJSON(raw_data + "?callback=onJSONP_Data", VMM.Timeline.DataObj.parseJSON);
} }
} else if (type.of(raw_data) == "html") { } else if (type.of(raw_data) == "html") {
trace("DATA SOURCE: HTML"); trace("DATA SOURCE: HTML");
@ -35,6 +38,11 @@ if (typeof VMM.Timeline !== 'undefined' && typeof VMM.Timeline.DataObj == 'undef
}, },
onJSONPLoaded: function() {
trace("JSONP IS LOADED");
VMM.fireEvent(global, VMM.Timeline.Config.events.data_ready, storyjs_jsonp_data);
},
parseHTML: function (d) { parseHTML: function (d) {
trace("parseHTML"); trace("parseHTML");
trace("WARNING: THIS IS STILL ALPHA AND WILL NOT WORK WITH ID's other than #timeline"); trace("WARNING: THIS IS STILL ALPHA AND WILL NOT WORK WITH ID's other than #timeline");

Loading…
Cancel
Save