Skip to content
Browse files

Simplifed README

  • Loading branch information...
1 parent d91b527 commit 593d8cd82620dbb794df14086e5c792489e306d5 @screeley screeley committed
View
1 .gitignore
@@ -1 +1,2 @@
.sass-cache
+node_modules
View
10 Gruntfile.js
@@ -13,18 +13,20 @@ module.exports = function(grunt) {
pkg: grunt.file.readJSON('jquery-preview.jquery.json'),
meta: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
- '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
- '<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
+ '<%= grunt.template.today("yyyy-mm-dd") + "\\n" %>' +
+ '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
- ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
+ ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */<%= "\\n" %>'
},
qunit: {
all: ['test/**/*.html']
},
concat: {
+ options: {
+ banner: '<%= meta.banner %>'
+ },
dist: {
src: [
- '<banner:meta.banner>',
'src/intro.js',
'lib/sprintf-0.7-beta1.js',
'src/hidden.js',
View
59 README.rest
@@ -10,41 +10,24 @@ metadata.
We have made this plugin overly verbose and infinitely customizable. Our goal
is not to dictate design, merely give a set of tools to make it easy to create
-a custom experience. There are 5 different demos that you should take a look at
-before getting started. It will give you a quick overview of what you should be
-able to build.
-
-* `Link <http://embedly.github.com/jquery-preview/demo/link.html>`_
-* `Status <http://embedly.github.com/jquery-preview/demo/status.html>`_
-* `Multipe Inputs <http://embedly.github.com/jquery-preview/demo/multi.html>`_
+a custom experience.
Basic Setup
-----------
To get started you need to put `jQuery <http://jquery.com/>`_,
-`jquery.preview.full.js
-<https://github.com/embedly/jquery-preview/blob/master/jquery.preview.full.js>`_
+`Embedly jQuery
+<https://github.com/embedly/embedly-jquery>`_,
+`jquery.preview.js
+<https://github.com/embedly/jquery-preview/blob/master/jquery.preview.js>`_
and `preview.css
<https://github.com/embedly/jquery-preview/blob/master/css/preview.css>`_. into
-the ``head`` of your page::
+your page::
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
- <script src="http://scripts.embed.ly/p/0.2/jquery.preview.full.min.js" type="text/javascript"></script>
- <link rel="stylesheet" href="http://scripts.embed.ly/p/0.2/css/preview.css" />
- </head>
-
-jquery.preview.full.js bundles `Underscore.js
-<http://documentcloud.github.com/underscore/>`_ and `Mustache.js
-<https://github.com/janl/mustache.js/>`_ in with jquery.preview.js. If you
-already have or use these two libs you can see up the ``head`` of the document
-like so::
-
- <head>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
- <script src="lib/mustache.js" type="text/javascript"></script>
- <script src="lib/underscore.js" type="text/javascript"></script>
- <script src="http://scripts.embed.ly/p/0.2/jquery.preview.min.js" type="text/javascript"></script>
- <link rel="stylesheet" href="http://scripts.embed.ly/p/0.2/css/preview.css" />
+ <script src="http://cdn.embed.ly/jquery.embedly-3.0.5.min.js" type="text/javascript"></script>
+ <script src="http://cdn.embed.ly/jquery.preview-0.3.0.min.js" type="text/javascript"></script>
+ <link rel="stylesheet" href="http://cdn.embed.ly/jquery.preview-0.3.0.css" />
</head>
Next set up a simple form that allows a user to input link::
@@ -72,10 +55,6 @@ You then need to tell preview what field to listen to::
And you are done setting up the front end solution for jQuery Preview. The
rest of this document will go into how to customize Preview.
-Note that the `Preview <http://embed.ly/docs/endpoints/1/preview>`_ endpoint is
-only available to Embedly developers with a Starter plan or above. You can sign
-up for a Starter plan at `embed.ly/pricing <http://embed.ly/pricing>`_.
-
How it Works
------------
The plugin works by listening to the field on ``paste``, ``keyup``, ``preview``
@@ -144,7 +123,7 @@ Options
If you would like to create your own selector, overwrite ``render`` with
your own function. We will go in more detail, in the writing your own
- selector function, but here is the simplest example I could think of.
+ selector function, but here is the simplest example I could think of::
$('#url').preview({
render: function(obj, options){
@@ -173,7 +152,7 @@ Events
``close``
Triggered when the selector should be closed. If you are implementing a
- custom selector, you must listen for this event.
+ custom selector, you must listen for this event::
var render = function(data, options){
// Insert selector
@@ -302,27 +281,17 @@ CDN
To get you going even faster, Embedly hosts all the files you need on
scripts.embed.ly. The latest version is available here::
- http://scripts.embed.ly/p/0.3/jquery.preview.min.js
- http://scripts.embed.ly/p/0.3/jquery.preview.full.min.js
- http://scripts.embed.ly/p/0.3/css/preview.css
+ http://cdn.embed.ly/jquery.preview-0.3.0.min.js
+ http://cdn.embed.ly/jquery.preview-0.3.0.css
-Development
------------
-The code is broken down into modules in the ``src`` folder and built by
-``grunt``. If you want to modify anything in ``preview.jquery.js`` please
-find the code in the module and run ``grunt run`` to build
-``preview.jquery.js``. ``preview.css`` is a `sass <http://sass-lang.com/>`_
-generated file. Please modify ``preview.scss`` by running ``sass --watch
-preview.scss:preview.css``
-
Changelog
---------
0.3
^^^
-* Full rewrite to simplify adding jQuery to a site.
+* Full rewrite to simplify adding jQuery Preview to a site.
0.2
^^^
View
40 bin/docs.py
@@ -0,0 +1,40 @@
+"""
+We use this in development to build jquery.preview.js
+"""
+import os
+import lxml.html
+from docutils.core import publish_string
+from optparse import OptionParser
+
+DIR_PATH = os.path.abspath(os.path.dirname(__file__))
+DEMO_PATH = os.path.join(DIR_PATH, '../demo')
+
+if __name__ == '__main__':
+
+ f = open(os.path.join(DIR_PATH, '../README.rest'), 'r')
+ html = publish_string(f.read(), writer_name='html')
+ f.close()
+ doc = lxml.html.fromstring(html)
+
+
+ for pre in doc.xpath('//pre'):
+ pre.set('class', 'prettyprint linenums')
+
+ body = doc.xpath('//div[@id="jquery-preview"]')[0]
+ body.xpath('.//h1[@class="title"]')[0].drop_tree()
+
+ for heading in body.xpath('//h1|//h2|//h3|//h4'):
+ heading.tag = 'h{}'.format(int(heading.tag[1])+1)
+
+ f = open(os.path.join(DEMO_PATH, 'index.html.tmpl'), 'r')
+ doc = lxml.html.fromstring(f.read())
+ f.close()
+ document = doc.xpath('//div[@id="document"]')[0]
+ for child in body.getchildren():
+ document.append(child)
+
+ f = open(os.path.join(DEMO_PATH, 'index.html'), 'w')
+ f.write(lxml.html.tostring(doc))
+ f.close()
+
+ print 'Done'
View
17 demo/common/css/demo.css
@@ -14,6 +14,7 @@ body {
.panel {
padding:3em;
+ margin-bottom: 2em;
}
.panel .selector {
@@ -67,5 +68,17 @@ body {
.item .attributes {
padding: 0 0 0 120px;
}
-.section { padding-top:60px; }
-fieldset .help-block { clear:both; display:block;}
+.section { padding-top:10px; }
+
+pre.prettyprint {
+ padding:5px 2px;
+ overflow-x:scroll;
+ border:1px solid #ddd;
+ margin-bottom: 1.25em
+}
+
+pre ol {
+ list-style-position: inside;
+}
+
+
View
1 demo/common/css/prettify.css
@@ -0,0 +1 @@
+.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:decimal}
View
1,722 demo/common/js/bootstrap.js
0 additions, 1,722 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
1 demo/common/js/bootstrap.min.js
@@ -1 +0,0 @@
-!function(a){a(function(){"use strict",a.support.transition=function(){var b=document.body||document.documentElement,c=b.style,d=c.transition!==undefined||c.WebkitTransition!==undefined||c.MozTransition!==undefined||c.MsTransition!==undefined||c.OTransition!==undefined;return d&&{end:function(){var b="TransitionEnd";return a.browser.webkit?b="webkitTransitionEnd":a.browser.mozilla?b="transitionend":a.browser.opera&&(b="oTransitionEnd"),b}()}}()})}(window.jQuery),!function(a){"use strict";var b='[data-dismiss="alert"]',c=function(c){a(c).on("click",b,this.close)};c.prototype={constructor:c,close:function(b){function f(){e.remove(),e.trigger("closed")}var c=a(this),d=c.attr("data-target"),e;d||(d=c.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,"")),e=a(d),e.trigger("close"),b&&b.preventDefault(),e.length||(e=c.hasClass("alert")?c:c.parent()),e.removeClass("in"),a.support.transition&&e.hasClass("fade")?e.on(a.support.transition.end,f):f()}},a.fn.alert=function(b){return this.each(function(){var d=a(this),e=d.data("alert");e||d.data("alert",e=new c(this)),typeof b=="string"&&e[b].call(d)})},a.fn.alert.Constructor=c,a(function(){a("body").on("click.alert.data-api",b,c.prototype.close)})}(window.jQuery),!function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.button.defaults,c)};b.prototype={constructor:b,setState:function(a){var b="disabled",c=this.$element,d=c.data(),e=c.is("input")?"val":"html";a+="Text",d.resetText||c.data("resetText",c[e]()),c[e](d[a]||this.options[a]),setTimeout(function(){a=="loadingText"?c.addClass(b).attr(b,b):c.removeClass(b).removeAttr(b)},0)},toggle:function(){var a=this.$element.parent('[data-toggle="buttons-radio"]');a&&a.find(".active").removeClass("active"),this.$element.toggleClass("active")}},a.fn.button=function(c){return this.each(function(){var d=a(this),e=d.data("button"),f=typeof c=="object"&&c;e||d.data("button",e=new b(this,f)),c=="toggle"?e.toggle():c&&e.setState(c)})},a.fn.button.defaults={loadingText:"loading..."},a.fn.button.Constructor=b,a(function(){a("body").on("click.button.data-api","[data-toggle^=button]",function(b){a(b.target).button("toggle")})})}(window.jQuery),!function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.carousel.defaults,c),this.options.slide&&this.slide(this.options.slide)};b.prototype={cycle:function(){return this.interval=setInterval(a.proxy(this.next,this),this.options.interval),this},to:function(b){var c=this.$element.find(".active"),d=c.parent().children(),e=d.index(c),f=this;if(b>d.length-1||b<0)return;return this.sliding?this.$element.one("slid",function(){f.to(b)}):e==b?this.pause().cycle():this.slide(b>e?"next":"prev",a(d[b]))},pause:function(){return clearInterval(this.interval),this},next:function(){if(this.sliding)return;return this.slide("next")},prev:function(){if(this.sliding)return;return this.slide("prev")},slide:function(b,c){var d=this.$element.find(".active"),e=c||d[b](),f=this.interval,g=b=="next"?"left":"right",h=b=="next"?"first":"last",i=this;return this.sliding=!0,f&&this.pause(),e=e.length?e:this.$element.find(".item")[h](),!a.support.transition&&this.$element.hasClass("slide")?(this.$element.trigger("slide"),d.removeClass("active"),e.addClass("active"),this.sliding=!1,this.$element.trigger("slid")):(e.addClass(b),e[0].offsetWidth,d.addClass(g),e.addClass(g),this.$element.trigger("slide"),this.$element.one(a.support.transition.end,function(){e.removeClass([b,g].join(" ")).addClass("active"),d.removeClass(["active",g].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger("slid")},0)})),f&&this.cycle(),this}},a.fn.carousel=function(c){return this.each(function(){var d=a(this),e=d.data("carousel"),f=typeof c=="object"&&c;e||d.data("carousel",e=new b(this,f)),typeof c=="number"?e.to(c):typeof c=="string"||(c=f.slide)?e[c]():e.cycle()})},a.fn.carousel.defaults={interval:5e3},a.fn.carousel.Constructor=b,a(function(){a("body").on("click.carousel.data-api","[data-slide]",function(b){var c=a(this),d,e=a(c.attr("data-target")||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,"")),f=!e.data("modal")&&a.extend({},e.data(),c.data());e.carousel(f),b.preventDefault()})})}(window.jQuery),!function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.collapse.defaults,c),this.options.parent&&(this.$parent=a(this.options.parent)),this.options.toggle&&this.toggle()};b.prototype={constructor:b,dimension:function(){var a=this.$element.hasClass("width");return a?"width":"height"},show:function(){var b=this.dimension(),c=a.camelCase(["scroll",b].join("-")),d=this.$parent&&this.$parent.find(".in"),e;d&&d.length&&(e=d.data("collapse"),d.collapse("hide"),e||d.data("collapse",null)),this.$element[b](0),this.transition("addClass","show","shown"),this.$element[b](this.$element[0][c])},hide:function(){var a=this.dimension();this.reset(this.$element[a]()),this.transition("removeClass","hide","hidden"),this.$element[a](0)},reset:function(a){var b=this.dimension();this.$element.removeClass("collapse")[b](a||"auto")[0].offsetWidth,this.$element.addClass("collapse")},transition:function(b,c,d){var e=this,f=function(){c=="show"&&e.reset(),e.$element.trigger(d)};this.$element.trigger(c)[b]("in"),a.support.transition&&this.$element.hasClass("collapse")?this.$element.one(a.support.transition.end,f):f()},toggle:function(){this[this.$element.hasClass("in")?"hide":"show"]()}},a.fn.collapse=function(c){return this.each(function(){var d=a(this),e=d.data("collapse"),f=typeof c=="object"&&c;e||d.data("collapse",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.collapse.defaults={toggle:!0},a.fn.collapse.Constructor=b,a(function(){a("body").on("click.collapse.data-api","[data-toggle=collapse]",function(b){var c=a(this),d,e=c.attr("data-target")||b.preventDefault()||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""),f=a(e).data("collapse")?"toggle":c.data();a(e).collapse(f)})})}(window.jQuery),!function(a){function d(){a(b).parent().removeClass("open")}"use strict";var b='[data-toggle="dropdown"]',c=function(b){var c=a(b).on("click.dropdown.data-api",this.toggle);a("html").on("click.dropdown.data-api",function(){c.parent().removeClass("open")})};c.prototype={constructor:c,toggle:function(b){var c=a(this),e=c.attr("data-target"),f,g;return e||(e=c.attr("href"),e=e&&e.replace(/.*(?=#[^\s]*$)/,"")),f=a(e),f.length||(f=c.parent()),g=f.hasClass("open"),d(),!g&&f.toggleClass("open"),!1}},a.fn.dropdown=function(b){return this.each(function(){var d=a(this),e=d.data("dropdown");e||d.data("dropdown",e=new c(this)),typeof b=="string"&&e[b].call(d)})},a.fn.dropdown.Constructor=c,a(function(){a("html").on("click.dropdown.data-api",d),a("body").on("click.dropdown.data-api",b,c.prototype.toggle)})}(window.jQuery),!function(a){function c(){var b=this,c=setTimeout(function(){b.$element.off(a.support.transition.end),d.call(b)},500);this.$element.one(a.support.transition.end,function(){clearTimeout(c),d.call(b)})}function d(a){this.$element.hide().trigger("hidden"),e.call(this)}function e(b){var c=this,d=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var e=a.support.transition&&d;this.$backdrop=a('<div class="modal-backdrop '+d+'" />').appendTo(document.body),this.options.backdrop!="static"&&this.$backdrop.click(a.proxy(this.hide,this)),e&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),e?this.$backdrop.one(a.support.transition.end,b):b()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),a.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(a.support.transition.end,a.proxy(f,this)):f.call(this)):b&&b()}function f(){this.$backdrop.remove(),this.$backdrop=null}function g(){var b=this;this.isShown&&this.options.keyboard?a(document).on("keyup.dismiss.modal",function(a){a.which==27&&b.hide()}):this.isShown||a(document).off("keyup.dismiss.modal")}"use strict";var b=function(b,c){this.options=a.extend({},a.fn.modal.defaults,c),this.$element=a(b).delegate('[data-dismiss="modal"]',"click.dismiss.modal",a.proxy(this.hide,this))};b.prototype={constructor:b,toggle:function(){return this[this.isShown?"hide":"show"]()},show:function(){var b=this;if(this.isShown)return;a("body").addClass("modal-open"),this.isShown=!0,this.$element.trigger("show"),g.call(this),e.call(this,function(){var c=a.support.transition&&b.$element.hasClass("fade");!b.$element.parent().length&&b.$element.appendTo(document.body),b.$element.show(),c&&b.$element[0].offsetWidth,b.$element.addClass("in"),c?b.$element.one(a.support.transition.end,function(){b.$element.trigger("shown")}):b.$element.trigger("shown")})},hide:function(b){b&&b.preventDefault();if(!this.isShown)return;var e=this;this.isShown=!1,a("body").removeClass("modal-open"),g.call(this),this.$element.trigger("hide").removeClass("in"),a.support.transition&&this.$element.hasClass("fade")?c.call(this):d.call(this)}},a.fn.modal=function(c){return this.each(function(){var d=a(this),e=d.data("modal"),f=typeof c=="object"&&c;e||d.data("modal",e=new b(this,f)),typeof c=="string"?e[c]():e.show()})},a.fn.modal.defaults={backdrop:!0,keyboard:!0},a.fn.modal.Constructor=b,a(function(){a("body").on("click.modal.data-api",'[data-toggle="modal"]',function(b){var c=a(this),d,e=a(c.attr("data-target")||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,"")),f=e.data("modal")?"toggle":a.extend({},e.data(),c.data());b.preventDefault(),e.modal(f)})})}(window.jQuery),!function(a){"use strict";var b=function(a,b){this.init("tooltip",a,b)};b.prototype={constructor:b,init:function(b,c,d){var e,f;this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.enabled=!0,this.options.trigger!="manual"&&(e=this.options.trigger=="hover"?"mouseenter":"focus",f=this.options.trigger=="hover"?"mouseleave":"blur",this.$element.on(e,this.options.selector,a.proxy(this.enter,this)),this.$element.on(f,this.options.selector,a.proxy(this.leave,this))),this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},getOptions:function(b){return b=a.extend({},a.fn[this.type].defaults,b,this.$element.data()),b.delay&&typeof b.delay=="number"&&(b.delay={show:b.delay,hide:b.delay}),b},enter:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);!c.options.delay||!c.options.delay.show?c.show():(c.hoverState="in",setTimeout(function(){c.hoverState=="in"&&c.show()},c.options.delay.show))},leave:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);!c.options.delay||!c.options.delay.hide?c.hide():(c.hoverState="out",setTimeout(function(){c.hoverState=="out"&&c.hide()},c.options.delay.hide))},show:function(){var a,b,c,d,e,f,g;if(this.hasContent()&&this.enabled){a=this.tip(),this.setContent(),this.options.animation&&a.addClass("fade"),f=typeof this.options.placement=="function"?this.options.placement.call(this,a[0],this.$element[0]):this.options.placement,b=/in/.test(f),a.remove().css({top:0,left:0,display:"block"}).appendTo(b?this.$element:document.body),c=this.getPosition(b),d=a[0].offsetWidth,e=a[0].offsetHeight;switch(b?f.split(" ")[1]:f){case"bottom":g={top:c.top+c.height,left:c.left+c.width/2-d/2};break;case"top":g={top:c.top-e,left:c.left+c.width/2-d/2};break;case"left":g={top:c.top+c.height/2-e/2,left:c.left-d};break;case"right":g={top:c.top+c.height/2-e/2,left:c.left+c.width}}a.css(g).addClass(f).addClass("in")}},setContent:function(){var a=this.tip();a.find(".tooltip-inner").html(this.getTitle()),a.removeClass("fade in top bottom left right")},hide:function(){function d(){var b=setTimeout(function(){c.off(a.support.transition.end).remove()},500);c.one(a.support.transition.end,function(){clearTimeout(b),c.remove()})}var b=this,c=this.tip();c.removeClass("in"),a.support.transition&&this.$tip.hasClass("fade")?d():c.remove()},fixTitle:function(){var a=this.$element;(a.attr("title")||typeof a.attr("data-original-title")!="string")&&a.attr("data-original-title",a.attr("title")||"").removeAttr("title")},hasContent:function(){return this.getTitle()},getPosition:function(b){return a.extend({},b?{top:0,left:0}:this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight})},getTitle:function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||(typeof c.title=="function"?c.title.call(b[0]):c.title),a=a.toString().replace(/(^\s*|\s*$)/,""),a},tip:function(){return this.$tip=this.$tip||a(this.options.template)},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled},toggle:function(){this[this.tip().hasClass("in")?"hide":"show"]()}},a.fn.tooltip=function(c){return this.each(function(){var d=a(this),e=d.data("tooltip"),f=typeof c=="object"&&c;e||d.data("tooltip",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.tooltip.Constructor=b,a.fn.tooltip.defaults={animation:!0,delay:0,selector:!1,placement:"top",trigger:"hover",title:"",template:'<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'}}(window.jQuery),!function(a){"use strict";var b=function(a,b){this.init("popover",a,b)};b.prototype=a.extend({},a.fn.tooltip.Constructor.prototype,{constructor:b,setContent:function(){var b=this.tip(),c=this.getTitle(),d=this.getContent();b.find(".popover-title")[a.type(c)=="object"?"append":"html"](c),b.find(".popover-content > *")[a.type(d)=="object"?"append":"html"](d),b.removeClass("fade top bottom left right in")},hasContent:function(){return this.getTitle()||this.getContent()},getContent:function(){var a,b=this.$element,c=this.options;return a=b.attr("data-content")||(typeof c.content=="function"?c.content.call(b[0]):c.content),a=a.toString().replace(/(^\s*|\s*$)/,""),a},tip:function(){return this.$tip||(this.$tip=a(this.options.template)),this.$tip}}),a.fn.popover=function(c){return this.each(function(){var d=a(this),e=d.data("popover"),f=typeof c=="object"&&c;e||d.data("popover",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.popover.Constructor=b,a.fn.popover.defaults=a.extend({},a.fn.tooltip.defaults,{placement:"right",content:"",template:'<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'})}(window.jQuery),!function(a){function b(b,c){var d=a.proxy(this.process,this),e=a(b).is("body")?a(window):a(b),f;this.options=a.extend({},a.fn.scrollspy.defaults,c),this.$scrollElement=e.on("scroll.scroll.data-api",d),this.selector=(this.options.target||(f=a(b).attr("href"))&&f.replace(/.*(?=#[^\s]+$)/,"")||"")+" .nav li > a",this.$body=a("body").on("click.scroll.data-api",this.selector,d),this.refresh(),this.process()}"use strict",b.prototype={constructor:b,refresh:function(){this.targets=this.$body.find(this.selector).map(function(){var b=a(this).attr("href");return/^#\w/.test(b)&&a(b).length?b:null}),this.offsets=a.map(this.targets,function(b){return a(b).position().top})},process:function(){var a=this.$scrollElement.scrollTop()+this.options.offset,b=this.offsets,c=this.targets,d=this.activeTarget,e;for(e=b.length;e--;)d!=c[e]&&a>=b[e]&&(!b[e+1]||a<=b[e+1])&&this.activate(c[e])},activate:function(a){var b;this.activeTarget=a,this.$body.find(this.selector).parent(".active").removeClass("active"),b=this.$body.find(this.selector+'[href="'+a+'"]').parent("li").addClass("active"),b.parent(".dropdown-menu")&&b.closest("li.dropdown").addClass("active")}},a.fn.scrollspy=function(c){return this.each(function(){var d=a(this),e=d.data("scrollspy"),f=typeof c=="object"&&c;e||d.data("scrollspy",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.scrollspy.Constructor=b,a.fn.scrollspy.defaults={offset:10},a(function(){a('[data-spy="scroll"]').each(function(){var b=a(this);b.scrollspy(b.data())})})}(window.jQuery),!function(a){"use strict";var b=function(b){this.element=a(b)};b.prototype={constructor:b,show:function(){var b=this.element,c=b.closest("ul:not(.dropdown-menu)"),d=b.attr("data-target"),e,f;d||(d=b.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,""));if(b.parent("li").hasClass("active"))return;e=c.find(".active a").last()[0],b.trigger({type:"show",relatedTarget:e}),f=a(d),this.activate(b.parent("li"),c),this.activate(f,f.parent(),function(){b.trigger({type:"shown",relatedTarget:e})})},activate:function(b,c,d){function g(){e.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),b.addClass("active"),f?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu")&&b.closest("li.dropdown").addClass("active"),d&&d()}var e=c.find("> .active"),f=d&&a.support.transition&&e.hasClass("fade");f?e.one(a.support.transition.end,g):g(),e.removeClass("in")}},a.fn.tab=function(c){return this.each(function(){var d=a(this),e=d.data("tab");e||d.data("tab",e=new b(this)),typeof c=="string"&&e[c]()})},a.fn.tab.Constructor=b,a(function(){a("body").on("click.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(b){b.preventDefault(),a(this).tab("show")})})}(window.jQuery),!function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.typeahead.defaults,c),this.matcher=this.options.matcher||this.matcher,this.sorter=this.options.sorter||this.sorter,this.highlighter=this.options.highlighter||this.highlighter,this.$menu=a(this.options.menu).appendTo("body"),this.source=this.options.source,this.shown=!1,this.listen()};b.prototype={constructor:b,select:function(){var a=this.$menu.find(".active").attr("data-value");return this.$element.val(a),this.hide()},show:function(){var b=a.extend({},this.$element.offset(),{height:this.$element[0].offsetHeight});return this.$menu.css({top:b.top+b.height,left:b.left}),this.$menu.show(),this.shown=!0,this},hide:function(){return this.$menu.hide(),this.shown=!1,this},lookup:function(b){var c=this,d,e;return this.query=this.$element.val(),this.query?(d=a.grep(this.source,function(a){if(c.matcher(a))return a}),d=this.sorter(d),d.length?this.render(d.slice(0,this.options.items)).show():this.shown?this.hide():this):this.shown?this.hide():this},matcher:function(a){return~a.toLowerCase().indexOf(this.query.toLowerCase())},sorter:function(a){var b=[],c=[],d=[],e;while(e=a.shift())e.toLowerCase().indexOf(this.query.toLowerCase())?~e.indexOf(this.query)?c.push(e):d.push(e):b.push(e);return b.concat(c,d)},highlighter:function(a){return a.replace(new RegExp("("+this.query+")","ig"),function(a,b){return"<strong>"+b+"</strong>"})},render:function(b){var c=this;return b=a(b).map(function(b,d){return b=a(c.options.item).attr("data-value",d),b.find("a").html(c.highlighter(d)),b[0]}),b.first().addClass("active"),this.$menu.html(b),this},next:function(b){var c=this.$menu.find(".active").removeClass("active"),d=c.next();d.length||(d=a(this.$menu.find("li")[0])),d.addClass("active")},prev:function(a){var b=this.$menu.find(".active").removeClass("active"),c=b.prev();c.length||(c=this.$menu.find("li").last()),c.addClass("active")},listen:function(){this.$element.on("blur",a.proxy(this.blur,this)).on("keypress",a.proxy(this.keypress,this)).on("keyup",a.proxy(this.keyup,this)),(a.browser.webkit||a.browser.msie)&&this.$element.on("keydown",a.proxy(this.keypress,this)),this.$menu.on("click",a.proxy(this.click,this)).on("mouseenter","li",a.proxy(this.mouseenter,this))},keyup:function(a){a.stopPropagation(),a.preventDefault();switch(a.keyCode){case 40:case 38:break;case 9:case 13:if(!this.shown)return;this.select();break;case 27:this.hide();break;default:this.lookup()}},keypress:function(a){a.stopPropagation();if(!this.shown)return;switch(a.keyCode){case 9:case 13:case 27:a.preventDefault();break;case 38:a.preventDefault(),this.prev();break;case 40:a.preventDefault(),this.next()}},blur:function(a){var b=this;a.stopPropagation(),a.preventDefault(),setTimeout(function(){b.hide()},150)},click:function(a){a.stopPropagation(),a.preventDefault(),this.select()},mouseenter:function(b){this.$menu.find(".active").removeClass("active"),a(b.currentTarget).addClass("active")}},a.fn.typeahead=function(c){return this.each(function(){var d=a(this),e=d.data("typeahead"),f=typeof c=="object"&&c;e||d.data("typeahead",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.typeahead.defaults={source:[],items:8,menu:'<ul class="typeahead dropdown-menu"></ul>',item:'<li><a href="#"></a></li>'},a.fn.typeahead.Constructor=b,a(function(){a("body").on("focus.typeahead.data-api",'[data-provide="typeahead"]',function(b){var c=a(this);if(c.data("typeahead"))return;b.preventDefault(),c.typeahead(c.data())})})}(window.jQuery);
View
28 demo/common/js/prettify.js
@@ -0,0 +1,28 @@
+var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
+(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
+[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
+f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
+(j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
+{b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
+t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
+"string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
+l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
+q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
+q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
+"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
+a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
+for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
+m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
+a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
+j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
+"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
+H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
+J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
+I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
+["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
+/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
+["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
+hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
+!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
+250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
+PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();
View
275 demo/index.html
@@ -1,36 +1,14 @@
-<!DOCTYPE html>
-<html>
- <head>
- <link rel="shortcut icon" href="http://embed.ly/static/favicon.ico">
- <script src="../lib/jquery.min.js" type="text/javascript" ></script>
- <script src="../lib/jquery.embedly.js" type="text/javascript"></script>
- <script src="../lib/mustache.js" type="text/javascript"></script>
- <script src="../dist/jquery.preview.js" type="text/javascript"></script>
- <link rel="stylesheet" href="common/css/foundation.min.css">
- <link rel="stylesheet" href="common/css/font-awesome.min.css">
- <link rel="stylesheet" href="common/css/demo.css" />
- <link rel="stylesheet" href="../css/preview.css" />
- <title>jQuery Preview - Link</title>
- </head>
- <body>
- <nav class="top-bar">
- <ul class="title-area">
- <li class="name">
+<html><head><link rel="shortcut icon" href="http://embed.ly/static/favicon.ico"><script src="../lib/jquery.min.js" type="text/javascript"></script><script src="common/js/prettify.js" type="text/javascript"></script><script src="../lib/jquery.embedly.js" type="text/javascript"></script><script src="../lib/mustache.js" type="text/javascript"></script><script src="../dist/jquery.preview.js" type="text/javascript"></script><link rel="stylesheet" href="common/css/foundation.min.css"><link rel="stylesheet" href="common/css/font-awesome.min.css"><link rel="stylesheet" href="common/css/prettify.css"><link rel="stylesheet" href="common/css/demo.css"><link rel="stylesheet" href="../css/preview.css"><title>jQuery Preview</title></head><body>
+ <nav class="top-bar"><ul class="title-area"><li class="name">
<h1><a href="index.html">jQuery Preview</a></h1>
</li>
- </ul>
- <section class="top-bar-section">
- <ul class="right">
- <li><a href="status.html">Status</a></li>
+ </ul><section class="top-bar-section"><ul class="right"><li><a href="status.html">Status</a></li>
<li><a href="link.html">Link</a></li>
<li><a href="multi.html">Multiple Inputs</a></li>
- </ul>
- </section>
- </nav>
- <div class="row">
+ </ul></section></nav><div class="row">
<div class="large-12 columns">
<div class="panel">
- <h1> jQuery Preview <a id="doc" href="https://github.com/embedly/jquery-preview" class="button">Get the Code &raquo;</a></h1>
+ <h1> jQuery Preview <a id="doc" href="https://github.com/embedly/jquery-preview" class="button">Get the Code &#187;</a></h1>
<p>
<a href="https://github.com/embedly/jquery-preview">jQuery Preview</a>
is a plugin that allows users to preview URLs before
@@ -41,35 +19,25 @@
<form id="preview_form" class="form-vertical" method="post" action=".">
<div class="arrow">
<p>Try it out.</p>
- <img src='../images/arrow.png'>
- </div>
+ <img src="../images/arrow.png"></div>
<div class="row collapse">
<div class="large-8 columns">
- <input type="text" class="input-xxlarge" name="url" id="id_url" value="http://vimeo.com/18150336" />
- </div>
+ <input type="text" class="input-xxlarge" name="url" id="id_url" value="http://vimeo.com/18150336"></div>
<div class="large-3 end columns">
<a id="id_attach" class="button postfix">Attach</a>
</div>
</div>
- <!-- Placeholder that tells Preview where to put the loading icon-->
-
- <!-- Placeholder that tells Preview where to put the selector-->
<div class="row">
<div class="large-11 columns end">
- <div class="selector-wrapper"></div>
+ <div class="selector-wrapper"></div>
</div>
</div>
</form>
<div id="feed"></div>
</div>
<div class="row">
- <div class="large-11 large-centered columns">
-
-<!--
-Generated from the README.rest.
-run python watch.py --html
--->
-p>jQuery Preview is a plugin by <a class="reference external" href="http://embed.ly">Embedly</a> that allows
+ <div id="document" class="large-11 large-centered columns">
+ <p>jQuery Preview is a plugin by <a class="reference external" href="http://embed.ly">Embedly</a> that allows
developers to create tools that enable users to share links with rich previews
attached. This method of letting users select thumbnails, edit title and
description has been adopted as the norm across the web. This plugin allows
@@ -78,50 +46,33 @@
metadata.</p>
<p>We have made this plugin overly verbose and infinitely customizable. Our goal
is not to dictate design, merely give a set of tools to make it easy to create
-a custom experience. There are 5 different demos that you should take a look at
-before getting started. It will give you a quick overview of what you should be
-able to build.</p>
-<ul class="simple">
-<li><a class="reference external" href="http://embedly.github.com/jquery-preview/demo/link.html">Link</a></li>
-<li><a class="reference external" href="http://embedly.github.com/jquery-preview/demo/status.html">Status</a></li>
-<li><a class="reference external" href="http://embedly.github.com/jquery-preview/demo/multi.html">Multipe Inputs</a></li>
-</ul>
+a custom experience.</p>
<div class="section" id="basic-setup">
-<h1>Basic Setup</h1>
+<h2>Basic Setup</h2>
<p>To get started you need to put <a class="reference external" href="http://jquery.com/">jQuery</a>,
-<a class="reference external" href="https://github.com/embedly/jquery-preview/blob/master/jquery.preview.full.js">jquery.preview.full.js</a>
+<a class="reference external" href="https://github.com/embedly/embedly-jquery">Embedly jQuery</a>,
+<a class="reference external" href="https://github.com/embedly/jquery-preview/blob/master/jquery.preview.js">jquery.preview.js</a>
and <a class="reference external" href="https://github.com/embedly/jquery-preview/blob/master/css/preview.css">preview.css</a>. into
-the <tt class="docutils literal">head</tt> of your page:</p>
-<pre class="literal-block">
+your page:</p>
+<pre class="prettyprint linenums">
&lt;head&gt;
- &lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
- &lt;script src=&quot;http://scripts.embed.ly/p/0.2/jquery.preview.full.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
- &lt;link rel=&quot;stylesheet&quot; href=&quot;http://scripts.embed.ly/p/0.2/css/preview.css&quot; /&gt;
-&lt;/head&gt;
-</pre>
-<p>jquery.preview.full.js bundles <a class="reference external" href="http://documentcloud.github.com/underscore/">Underscore.js</a> and <a class="reference external" href="https://github.com/janl/mustache.js/">Mustache.js</a> in with jquery.preview.js. If you
-already have or use these two libs you can see up the <tt class="docutils literal">head</tt> of the document
-like so:</p>
-<pre class="literal-block">
-&lt;head&gt;
- &lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
- &lt;script src=&quot;lib/mustache.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
- &lt;script src=&quot;lib/underscore.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
- &lt;script src=&quot;http://scripts.embed.ly/p/0.2/jquery.preview.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
- &lt;link rel=&quot;stylesheet&quot; href=&quot;http://scripts.embed.ly/p/0.2/css/preview.css&quot; /&gt;
+ &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;
+ &lt;script src="http://cdn.embed.ly/jquery.embedly-3.0.5.min.js" type="text/javascript"&gt;&lt;/script&gt;
+ &lt;script src="http://cdn.embed.ly/jquery.preview-0.3.0.min.js" type="text/javascript"&gt;&lt;/script&gt;
+ &lt;link rel="stylesheet" href="http://cdn.embed.ly/jquery.preview-0.3.0.css" /&gt;
&lt;/head&gt;
</pre>
<p>Next set up a simple form that allows a user to input link:</p>
-<pre class="literal-block">
-&lt;form action=&quot;/update&quot; method=&quot;POST&quot;&gt;
- &lt;input id=&quot;url&quot; type=&quot;text&quot; name=&quot;url&quot;/&gt;
+<pre class="prettyprint linenums">
+&lt;form action="/update" method="POST"&gt;
+ &lt;input id="url" type="text" name="url"/&gt;
&lt;!-- Placeholder that tells Preview where to put the selector--&gt;
- &lt;div class=&quot;selector-wrapper&quot;&gt;&lt;/div&gt;
+ &lt;div class="selector-wrapper"&gt;&lt;/div&gt;
&lt;/form&gt;
</pre>
<p>You then need to tell preview what field to listen to:</p>
-<pre class="literal-block">
+<pre class="prettyprint linenums">
&lt;script&gt;
// Set up preview.
$('#url').preview({key:'your_embedly_key'})
@@ -135,12 +86,9 @@
</pre>
<p>And you are done setting up the front end solution for jQuery Preview. The
rest of this document will go into how to customize Preview.</p>
-<p>Note that the <a class="reference external" href="http://embed.ly/docs/endpoints/1/preview">Preview</a> endpoint is
-only available to Embedly developers with a Starter plan or above. You can sign
-up for a Starter plan at <a class="reference external" href="http://embed.ly/pricing">embed.ly/pricing</a>.</p>
</div>
<div class="section" id="how-it-works">
-<h1>How it Works</h1>
+<h2>How it Works</h2>
<p>The plugin works by listening to the field on <tt class="docutils literal">paste</tt>, <tt class="docutils literal">keyup</tt>, <tt class="docutils literal">preview</tt>
and <tt class="docutils literal">blur</tt>. If a URL is entered a call is made to Embedly's <a class="reference external" href="http://embed.ly/docs/extract/api/endpoints/1/extract">Extract</a> endpoint and the
result is then passed to the <tt class="docutils literal">render</tt> function. <tt class="docutils literal">render</tt> uses <tt class="docutils literal">sprintf</tt>
@@ -151,7 +99,7 @@
to deal with that data on submit. jQuery Preview comes with a helper function
<tt class="docutils literal">addInputs</tt> so all the data can be added to the form. This is the code to
enable it:</p>
-<pre class="literal-block">
+<pre class="prettyprint linenums">
// On submit add hidden inputs to the form.
$('form').on('submit', function(){
$(this).addInputs($('#url').data('preview'));
@@ -161,16 +109,15 @@
<p>The developer can then choose how they wish to display the preview in the feed.
We will show some simple examples for handling this in the documentation.</p>
</div>
-<div class="section" id="id1">
-<h1>Preview</h1>
+<div class="section" id="preview">
+<h2>Preview</h2>
<p>Preview holds all the logic for calls to Embedly and rendering the selector.</p>
<div class="section" id="options">
-<h2>Options</h2>
-<dl class="docutils">
-<dt><tt class="docutils literal">bind</tt></dt>
+<h3>Options</h3>
+<dl class="docutils"><dt><tt class="docutils literal">bind</tt></dt>
<dd><p class="first">By default preview will bind to <tt class="docutils literal">keyup</tt>, <tt class="docutils literal">blur</tt> and <tt class="docutils literal">paste</tt> if you
wish to define your own bindings you can set this attribute to false:</p>
-<pre class="last literal-block">
+<pre class="prettyprint linenums">
// Don't bind the listeners
$('#url').preview({bind:false});
@@ -183,7 +130,7 @@
the way. Depending on the use case you may want notify the user or hide it
from them. The default behavior is to not notify the user. To notify them
you can use:</p>
-<pre class="last literal-block">
+<pre class="prettyprint linenums">
$('#url').preview({
error: function(obj){
alert('The URL you entered was not processed.');
@@ -195,7 +142,7 @@
if you want to change state after the URL has been successfully processed.
For example if you want to change a button from 'Share' to 'Submit' you can
do it like so:</p>
-<pre class="last literal-block">
+<pre class="prettyprint linenums">
$('#url').preview({
success : function(obj){
$('button').text('Submit');
@@ -203,89 +150,65 @@
});
</pre>
</dd>
-</dl>
-<p><tt class="docutils literal">render</tt></p>
+</dl><p><tt class="docutils literal">render</tt></p>
<blockquote>
<p>If you would like to create your own selector, overwrite <tt class="docutils literal">render</tt> with
your own function. We will go in more detail, in the writing your own
-selector function, but here is the simplest example I could think of.</p>
-<blockquote>
-<dl class="docutils">
-<dt>$('#url').preview({</dt>
-<dd><dl class="first docutils">
-<dt>render: function(obj, options){</dt>
-<dd>// Put the title after the input.
-$(this).after(obj.title);</dd>
-</dl>
-<div class="system-message">
-<p class="system-message-title">System Message: WARNING/2 (<tt class="docutils">&lt;string&gt;</tt>, line 153)</p>
-Definition list ends without a blank line; unexpected unindent.</div>
-<p class="last">}});</p>
-</dd>
-</dl>
-</blockquote>
+selector function, but here is the simplest example I could think of:</p>
+<pre class="prettyprint linenums">
+$('#url').preview({
+ render: function(obj, options){
+ // Put the title after the input.
+ $(this).after(obj.title);
+ }});
+</pre>
</blockquote>
</div>
<div class="section" id="events">
-<h2>Events</h2>
-<dl class="docutils">
-<dt><tt class="docutils literal">preview</tt></dt>
+<h3>Events</h3>
+<dl class="docutils"><dt><tt class="docutils literal">preview</tt></dt>
<dd><p class="first">Manually trigger the input to fetch the URL. This is generally only needed
if <tt class="docutils literal">bind</tt> is set to false:</p>
-<pre class="last literal-block">
+<pre class="prettyprint linenums">
$('a.attach').on('click', function(){$('#url').trigger('preview')});
</pre>
</dd>
<dt><tt class="docutils literal">loading</tt></dt>
<dd><p class="first">Triggered when the request is being made to the API endpoint:</p>
-<pre class="last literal-block">
+<pre class="prettyprint linenums">
$('#url').on('loading', function(){$('.loading').show()});
</pre>
</dd>
<dt><tt class="docutils literal">loaded</tt></dt>
<dd><p class="first">Triggered when a response has been returned from the API endpoint:</p>
-<pre class="last literal-block">
+<pre class="prettyprint linenums">
$('#url').on('loaded', function(){$('.loading').hide()});
</pre>
</dd>
<dt><tt class="docutils literal">close</tt></dt>
<dd><p class="first">Triggered when the selector should be closed. If you are implementing a
-custom selector, you must listen for this event.</p>
-<blockquote class="last">
-<dl class="docutils">
-<dt>var render = function(data, options){</dt>
-<dd><p class="first">// Insert selector
-$(this).on('close', function(){</p>
-<div class="system-message">
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">&lt;string&gt;</tt>, line 181)</p>
-Unexpected indentation.</div>
-<blockquote>
-//Remove selector.</blockquote>
-<div class="system-message">
-<p class="system-message-title">System Message: WARNING/2 (<tt class="docutils">&lt;string&gt;</tt>, line 182)</p>
-Block quote ends without a blank line; unexpected unindent.</div>
-<p class="last">});</p>
-</dd>
-</dl>
-<div class="system-message">
-<p class="system-message-title">System Message: WARNING/2 (<tt class="docutils">&lt;string&gt;</tt>, line 183)</p>
-Definition list ends without a blank line; unexpected unindent.</div>
-<p>}</p>
-</blockquote>
+custom selector, you must listen for this event:</p>
+<pre class="prettyprint linenums">
+var render = function(data, options){
+ // Insert selector
+ $(this).on('close', function(){
+ //Remove selector.
+ });
+}
+</pre>
</dd>
-</dl>
-</div>
+</dl></div>
</div>
<div class="section" id="custom-selector">
-<h1>Custom Selector</h1>
+<h2>Custom Selector</h2>
<p>It's actually recommended that you build a custom selector. While the default
one is pretty good, you are going to want to customize it more than just the
default styles. Here's how you can create your own.</p>
<div class="section" id="render">
-<h2>Render</h2>
+<h3>Render</h3>
<p>To create our own selector you just need to pass in a function into the
<tt class="docutils literal">render</tt> option when calling preview:</p>
-<pre class="literal-block">
+<pre class="prettyprint linenums">
var render = function(data, options){
// custom render
};
@@ -296,7 +219,7 @@
set custom options in preview. <tt class="docutils literal">this</tt> is the HTMLElement of the input. This
will let you listen for events or trigger events on the input.</p>
<p>The simplest version of a custom selector looks like so:</p>
-<pre class="literal-block">
+<pre class="prettyprint linenums">
var render = function(data, options){
// Add the title after the input.
$(this).after('&lt;span&gt;'+data.title+'&lt;/span&gt;');
@@ -310,10 +233,10 @@
</div>
</div>
<div class="section" id="display">
-<h1>Display</h1>
+<h2>Display</h2>
<p>jQuery Preview has no concept of displaying the item in a feed. This should be
handled by the developer. This is a simple example from one of the demos:</p>
-<pre class="literal-block">
+<pre class="prettyprint linenums">
$('#preview_form').on('submit', function(){
// Preview data.
var preview = $('#id_url').data('preview');
@@ -323,12 +246,12 @@
$('#id_url').val('');
// Create a post using mustache, i.e. the nice way.
- var template = ['&lt;div class=&quot;row&quot;&gt;',
- '&lt;div class=&quot;large-3 columns&quot;&gt;',
- '&lt;img class=&quot;thumb&quot; src=&quot;{{thumbnail_url}}&quot;&gt;&lt;/img&gt;',
+ var template = ['&lt;div class="row"&gt;',
+ '&lt;div class="large-3 columns"&gt;',
+ '&lt;img class="thumb" src="{{thumbnail_url}}"&gt;&lt;/img&gt;',
'&lt;/div&gt;',
- '&lt;div class=&quot;large-9 column&quot;&gt;',
- '&lt;a href=&quot;{{original_url}}&quot;&gt;{{title}}&lt;/a&gt;',
+ '&lt;div class="large-9 column"&gt;',
+ '&lt;a href="{{original_url}}"&gt;{{title}}&lt;/a&gt;',
'&lt;p&gt;{{description}}&lt;/p&gt;',
'&lt;/div&gt;',
'&lt;/div&gt;'].join('');
@@ -351,19 +274,19 @@
</pre>
</div>
<div class="section" id="server-side">
-<h1>Server Side</h1>
+<h2>Server Side</h2>
<p>When the user submits the link, we must save it and echo it back to the page
so it can be displayed. The code contains a simple <a class="reference external" href="http://www.tornadoweb.org/">Tornado</a> example of this dance in <a class="reference external" href="https://github.com/embedly/jquery-preview/blob/master/demo/stream/app.py">app.py</a>.
When we set up the form we need to specify where we are going to be making the
the AJAX post. In this case it's '/update':</p>
-<pre class="literal-block">
-&lt;form method=&quot;post&quot; action=&quot;/update&quot;&gt;
- &lt;input type=&quot;text&quot; class=&quot;xlarge&quot; name=&quot;url&quot; id=&quot;id_url&quot; /&gt;
- &lt;input id=&quot;id_submit&quot; type=&quot;submit&quot; class=&quot;btn btn-primary&quot; value=&quot;Share&quot;/&gt;
+<pre class="prettyprint linenums">
+&lt;form method="post" action="/update"&gt;
+ &lt;input type="text" class="xlarge" name="url" id="id_url" /&gt;
+ &lt;input id="id_submit" type="submit" class="btn btn-primary" value="Share"/&gt;
&lt;/form&gt;
</pre>
<p>We then build a handler to deal with the form data:</p>
-<pre class="literal-block">
+<pre class="prettyprint linenums">
class UpdateHandler(tornado.web.RequestHandler):
def post(self):
@@ -387,51 +310,34 @@
object to be rendered and displayed.</p>
</div>
<div class="section" id="cdn">
-<h1>CDN</h1>
+<h2>CDN</h2>
<p>To get you going even faster, Embedly hosts all the files you need on
scripts.embed.ly. The latest version is available here:</p>
-<pre class="literal-block">
-http://scripts.embed.ly/p/0.3/jquery.preview.min.js
-http://scripts.embed.ly/p/0.3/jquery.preview.full.min.js
-http://scripts.embed.ly/p/0.3/css/preview.css
+<pre class="prettyprint linenums">
+http://cdn.embed.ly/jquery.preview-0.3.0.min.js
+http://cdn.embed.ly/jquery.preview-0.3.0.css
</pre>
</div>
-<div class="section" id="development">
-<h1>Development</h1>
-<p>The code is broken down into modules in the <tt class="docutils literal">src</tt> folder and built by
-<tt class="docutils literal">grunt</tt>. If you want to modify anything in <tt class="docutils literal">preview.jquery.js</tt> please
-find the code in the module and run <tt class="docutils literal">grunt run</tt> to build
-<tt class="docutils literal">preview.jquery.js</tt>. <tt class="docutils literal">preview.css</tt> is a <a class="reference external" href="http://sass-lang.com/">sass</a>
-generated file. Please modify <tt class="docutils literal">preview.scss</tt> by running <tt class="docutils literal">sass <span class="pre">--watch</span>
-preview.scss:preview.css</tt></p>
-</div>
<div class="section" id="changelog">
-<h1>Changelog</h1>
+<h2>Changelog</h2>
+<div class="section" id="id1">
+<h3>0.3</h3>
+<ul class="simple"><li>Full rewrite to simplify adding jQuery Preview to a site.</li>
+</ul></div>
<div class="section" id="id2">
-<h2>0.3</h2>
-<ul class="simple">
-<li>Full rewrite to simplify adding jQuery to a site.</li>
-</ul>
-</div>
-<div class="section" id="id3">
-<h2>0.2</h2>
-<ul class="simple">
-<li>Added the $.preview so it can be used before the a form is initialized.</li>
+<h3>0.2</h3>
+<ul class="simple"><li>Added the $.preview so it can be used before the a form is initialized.</li>
<li>Added <tt class="docutils literal">error</tt> and <tt class="docutils literal">callback</tt> to the Preview object.</li>
-</ul>
+</ul></div>
</div>
</div>
-<!-- End Generated -->
-
- </div>
</div>
</div>
</div>
<script>
-
$(document).ready(function(){
-
+ prettyPrint();
$('#id_url').preview({key: 'c31f5208f04511e0b79e4040d3dc5c07', // Sign up for a key: http://embed.ly/pricing
bind: false,
query : {
@@ -482,7 +388,4 @@
}
});
});
- </script>
-
- </body>
-</html>
+ </script></body></html>
View
126 demo/index.html.tmpl
@@ -0,0 +1,126 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <link rel="shortcut icon" href="http://embed.ly/static/favicon.ico">
+ <script src="../lib/jquery.min.js" type="text/javascript" ></script>
+ <script src="common/js/prettify.js" type="text/javascript"></script>
+ <script src="../lib/jquery.embedly.js" type="text/javascript"></script>
+ <script src="../lib/mustache.js" type="text/javascript"></script>
+ <script src="../dist/jquery.preview.js" type="text/javascript"></script>
+ <link rel="stylesheet" href="common/css/foundation.min.css">
+ <link rel="stylesheet" href="common/css/font-awesome.min.css">
+ <link rel="stylesheet" href="common/css/prettify.css" />
+ <link rel="stylesheet" href="common/css/demo.css" />
+ <link rel="stylesheet" href="../css/preview.css" />
+ <title>jQuery Preview</title>
+ </head>
+ <body>
+ <nav class="top-bar">
+ <ul class="title-area">
+ <li class="name">
+ <h1><a href="index.html">jQuery Preview</a></h1>
+ </li>
+ </ul>
+ <section class="top-bar-section">
+ <ul class="right">
+ <li><a href="status.html">Status</a></li>
+ <li><a href="link.html">Link</a></li>
+ <li><a href="multi.html">Multiple Inputs</a></li>
+ </ul>
+ </section>
+ </nav>
+ <div class="row">
+ <div class="large-12 columns">
+ <div class="panel">
+ <h1> jQuery Preview <a id="doc" href="https://github.com/embedly/jquery-preview" class="button">Get the Code &raquo;</a></h1>
+ <p>
+ <a href="https://github.com/embedly/jquery-preview">jQuery Preview</a>
+ is a plugin that allows users to preview URLs before
+ submitting them to be saved by an application. Facebook, Google+
+ and Yammer are all examples of tools with this functionality.
+ </p>
+
+ <form id="preview_form" class="form-vertical" method="post" action=".">
+ <div class="arrow">
+ <p>Try it out.</p>
+ <img src='../images/arrow.png'>
+ </div>
+ <div class="row collapse">
+ <div class="large-8 columns">
+ <input type="text" class="input-xxlarge" name="url" id="id_url" value="http://vimeo.com/18150336" />
+ </div>
+ <div class="large-3 end columns">
+ <a id="id_attach" class="button postfix">Attach</a>
+ </div>
+ </div>
+ <div class="row">
+ <div class="large-11 columns end">
+ <div class="selector-wrapper"></div>
+ </div>
+ </div>
+ </form>
+ <div id="feed"></div>
+ </div>
+ <div class="row">
+ <div id="document" class="large-11 large-centered columns">
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <script>
+ $(document).ready(function(){
+ prettyPrint();
+ $('#id_url').preview({key: 'c31f5208f04511e0b79e4040d3dc5c07', // Sign up for a key: http://embed.ly/pricing
+ bind: false,
+ query : {
+ autoplay : 1,
+ maxwidth: 600
+ }})
+ .on('loading', function(){
+ $(this).prop('disabled', true);
+ $('form .button').html('<i class="icon-spinner icon-spin"></i>');
+ }).on('loaded', function(){
+ $(this).prop('disabled', false);
+ $('form .button').text('Share');
+ $('.arrow p').text('Now Share it!');
+ })
+
+ $('#id_attach').bind('click', function(e){
+ if ($(this).text() == 'Attach'){
+ $('#id_url').trigger('preview');
+ } else {
+
+ var preview = $('#id_url').data('preview');
+ $('#id_url').trigger('close');
+ $('#id_url').val('');
+
+ // Create a post using mustache, i.e. the nice way.
+ var template = ['<div class="row">',
+ '<div class="large-3 columns">',
+ '<img class="thumb" src="{{thumbnail_url}}"></img>',
+ '</div>',
+ '<div class="large-9 column">',
+ '<a href="{{original_url}}">{{title}}</a>',
+ '<p>{{description}}</p>',
+ '</div>',
+ '</div>'].join('');
+
+ html = $(Mustache.to_html(template, preview));
+ html.data('preview', preview);
+ html.on('click', function(){
+ var data = $(this).data('preview');
+ // Insert the video or rich object.
+ if (data.media.type === 'video' || data.media.type === 'rich'){
+ $(this).html(data.media.html);
+ return false;
+ }
+ return true;
+ })
+ $('#feed').append(html);
+ }
+ });
+ });
+ </script>
+ </body>
+</html>
View
2 demo/link.html
@@ -8,8 +8,8 @@
<script src="../dist/jquery.preview.js" type="text/javascript"></script>
<link rel="stylesheet" href="common/css/foundation.min.css">
<link rel="stylesheet" href="common/css/font-awesome.min.css">
+ <link rel="stylesheet" href="common/css/prettify.css" />
<link rel="stylesheet" href="common/css/demo.css" />
- <link rel="stylesheet" href="../css/preview.css" />
<title>jQuery Preview - Link</title>
</head>
<body>
View
39 demo/multi.html
@@ -31,33 +31,20 @@
<div class="large-8 large-centered columns">
<h3>Share what's new...</h3>
<form id="preview_form" class="form-vertical" method="post" action=".">
- <fieldset>
- <textarea class="xxlarge holler" name="status" id="id_status" ></textarea>
- <span class="help-block">Enter a url.</span>
- </fieldset>
- <!-- Placeholder that tells Preview where to put the loading icon-->
- <div class="loading">
- <img src='../images/loading-rectangle.gif'>
- </div>
+ <textarea class="xxlarge holler" name="status" id="id_status" ></textarea>
+
<!-- Placeholder that tells Preview where to put the selector-->
- <div class="selector"></div>
+ <div class="selector-wrapper"></div>
<div class="actions">
- <input id="id_submit" type="submit" class="btn btn-primary" value="Share"/>
+ <input id="id_submit" type="submit" class="button" value="Share"/>
</div>
</form>
<form id="link_form" class="form-vertical" method="post" action=".">
- <fieldset>
- <input type="text" class="xlarge holler" name="url" id="id_url" />
- <span class="help-block">Enter a url.</span>
- </fieldset>
- <!-- Placeholder that tells Preview where to put the loading icon-->
- <div class="loading">
- <img src='../images/loading-rectangle.gif'>
- </div>
+ <input type="text" class="xlarge holler" name="url" id="id_url" placeholder="Enter a URL" />
<!-- Placeholder that tells Preview where to put the selector-->
- <div class="selector"></div>
+ <div class="selector-wrapper"></div>
<div class="actions">
- <input id="id_submit" type="submit" class="btn btn-primary" value="Share"/>
+ <input id="id_submit" type="submit" class="button" value="Share"/>
</div>
</form>
<div id="feed"></div>
@@ -65,14 +52,12 @@
</div>
</div>
<script>
- var preview = {
- submit : function(e, data){
- e.preventDefault();
- this.display.create(data);
- }
- }
$('.holler').preview({key: 'c31f5208f04511e0b79e4040d3dc5c07', // Sign up for a key: http://embed.ly/pricing
- preview:preview});
+ });
+ $('form').on('submit', function(){
+ alert('You Selected: ' + $(this).find('.holler').data('preview').title);
+ return false;
+ });
</script>
</body>
</html>
View
2 demo/status.html
@@ -10,7 +10,7 @@
<link rel="stylesheet" href="common/css/font-awesome.min.css">
<link rel="stylesheet" href="common/css/demo.css" />
<link rel="stylesheet" href="../css/preview.css" />
- <title>jQuery Preview - Link</title>
+ <title>jQuery Preview - Status</title>
</head>
<body>
<nav class="top-bar">
View
247 dist/jquery.preview.js
@@ -1,22 +1,6 @@
-/*
- * Embedly Preview JQuery v0.0.2
- * =============================
- * This library allows you to easily create a status or url submisstion tool
- * utilizing Embedly's Preview API. For more information see:
- *
- * Embedly: http://embed.ly
- * Embedly Preview API: http://embed.ly/docs/endpoints/1/preview
- *
- * Requirements:
- * -------------
- * jquery-1.6 or higher
- *
- * Usage:
- * ------
- *
- *
- */
-
+/*! jQuery Preview - v0.3.0 - 2013-04-03
+* https://github.com/embedly/jquery-preview
+* Copyright (c) 2013 Sean Creeley; Licensed BSD */
;(function($){
/**
sprintf() for JavaScript 0.7-beta1
@@ -79,127 +63,127 @@ Changelog:
**/
var sprintf = (function() {
- function get_type(variable) {
- return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
- }
- function str_repeat(input, multiplier) {
- for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */}
- return output.join('');
- }
+ function get_type(variable) {
+ return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
+ }
+ function str_repeat(input, multiplier) {
+ for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */}
+ return output.join('');
+ }
- var str_format = function() {
- if (!str_format.cache.hasOwnProperty(arguments[0])) {
- str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
- }
- return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
- };
+ var str_format = function() {
+ if (!str_format.cache.hasOwnProperty(arguments[0])) {
+ str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
+ }
+ return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
+ };
- str_format.format = function(parse_tree, argv) {
- var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
- for (i = 0; i < tree_length; i++) {
- node_type = get_type(parse_tree[i]);
- if (node_type === 'string') {
- output.push(parse_tree[i]);
- }
- else if (node_type === 'array') {
- match = parse_tree[i]; // convenience purposes only
- if (match[2]) { // keyword argument
- arg = argv[cursor];
- for (k = 0; k < match[2].length; k++) {
- if (!arg.hasOwnProperty(match[2][k])) {
- throw(sprintf('[sprintf] property "%s" does not exist', match[2][k]));
- }
- arg = arg[match[2][k]];
- }
- }
- else if (match[1]) { // positional argument (explicit)
- arg = argv[match[1]];
- }
- else { // positional argument (implicit)
- arg = argv[cursor++];
- }
+ str_format.format = function(parse_tree, argv) {
+ var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
+ for (i = 0; i < tree_length; i++) {
+ node_type = get_type(parse_tree[i]);
+ if (node_type === 'string') {
+ output.push(parse_tree[i]);
+ }
+ else if (node_type === 'array') {
+ match = parse_tree[i]; // convenience purposes only
+ if (match[2]) { // keyword argument
+ arg = argv[cursor];
+ for (k = 0; k < match[2].length; k++) {
+ if (!arg.hasOwnProperty(match[2][k])) {
+ throw(sprintf('[sprintf] property "%s" does not exist', match[2][k]));
+ }
+ arg = arg[match[2][k]];
+ }
+ }
+ else if (match[1]) { // positional argument (explicit)
+ arg = argv[match[1]];
+ }
+ else { // positional argument (implicit)
+ arg = argv[cursor++];
+ }
- if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) {
- throw(sprintf('[sprintf] expecting number but found %s', get_type(arg)));
- }
- switch (match[8]) {
- case 'b': arg = arg.toString(2); break;
- case 'c': arg = String.fromCharCode(arg); break;
- case 'd': arg = parseInt(arg, 10); break;
- case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
- case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
- case 'o': arg = arg.toString(8); break;
- case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
- case 'u': arg = Math.abs(arg); break;
- case 'x': arg = arg.toString(16); break;
- case 'X': arg = arg.toString(16).toUpperCase(); break;
- }
- arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
- pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
- pad_length = match[6] - String(arg).length;
- pad = match[6] ? str_repeat(pad_character, pad_length) : '';
- output.push(match[5] ? arg + pad : pad + arg);
- }
- }
- return output.join('');
- };
+ if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) {
+ throw(sprintf('[sprintf] expecting number but found %s', get_type(arg)));
+ }
+ switch (match[8]) {
+ case 'b': arg = arg.toString(2); break;
+ case 'c': arg = String.fromCharCode(arg); break;
+ case 'd': arg = parseInt(arg, 10); break;
+ case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
+ case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
+ case 'o': arg = arg.toString(8); break;
+ case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
+ case 'u': arg = Math.abs(arg); break;
+ case 'x': arg = arg.toString(16); break;
+ case 'X': arg = arg.toString(16).toUpperCase(); break;
+ }
+ arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
+ pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
+ pad_length = match[6] - String(arg).length;
+ pad = match[6] ? str_repeat(pad_character, pad_length) : '';
+ output.push(match[5] ? arg + pad : pad + arg);
+ }
+ }
+ return output.join('');
+ };
- str_format.cache = {};
+ str_format.cache = {};
- str_format.parse = function(fmt) {
- var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
- while (_fmt) {
- if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
- parse_tree.push(match[0]);
- }
- else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
- parse_tree.push('%');
- }
- else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) {
- if (match[2]) {
- arg_names |= 1;
- var field_list = [], replacement_field = match[2], field_match = [];
- if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
- field_list.push(field_match[1]);
- while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
- if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
- field_list.push(field_match[1]);
- }
- else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
- field_list.push(field_match[1]);
- }
- else {
- throw('[sprintf] huh?');
- }
- }
- }
- else {
- throw('[sprintf] huh?');
- }
- match[2] = field_list;
- }
- else {
- arg_names |= 2;
- }
- if (arg_names === 3) {
- throw('[sprintf] mixing positional and named placeholders is not (yet) supported');
- }
- parse_tree.push(match);
- }
- else {
- throw('[sprintf] huh?');
- }
- _fmt = _fmt.substring(match[0].length);
- }
- return parse_tree;
- };
+ str_format.parse = function(fmt) {
+ var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
+ while (_fmt) {
+ if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
+ parse_tree.push(match[0]);
+ }
+ else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
+ parse_tree.push('%');
+ }
+ else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) {
+ if (match[2]) {
+ arg_names |= 1;
+ var field_list = [], replacement_field = match[2], field_match = [];
+ if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
+ field_list.push(field_match[1]);
+ while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
+ if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
+ field_list.push(field_match[1]);
+ }
+ else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
+ field_list.push(field_match[1]);
+ }
+ else {
+ throw('[sprintf] huh?');
+ }
+ }
+ }
+ else {
+ throw('[sprintf] huh?');
+ }
+ match[2] = field_list;
+ }
+ else {
+ arg_names |= 2;
+ }
+ if (arg_names === 3) {
+ throw('[sprintf] mixing positional and named placeholders is not (yet) supported');
+ }
+ parse_tree.push(match);
+ }
+ else {
+ throw('[sprintf] huh?');
+ }
+ _fmt = _fmt.substring(match[0].length);
+ }
+ return parse_tree;
+ };
- return str_format;
+ return str_format;
})();
var vsprintf = function(fmt, argv) {
- argv.unshift(fmt);
- return sprintf.apply(null, argv);
+ argv.unshift(fmt);
+ return sprintf.apply(null, argv);
};
/*globals jQuery:true, sprintf:true, escape:true*/
@@ -579,7 +563,6 @@ var vsprintf = function(fmt, argv) {
this.$elem.data('preview')[name] = value;
}, this));
-
},
log: function(){
if (this.options.debug && window.console){
View
5 dist/jquery.preview.min.js
@@ -1,4 +1 @@
-/*! jQuery Preview - v3.0.0 - 2013-01-25
-* https://github.com/embedly/jquery-preview
-* Copyright (c) 2013 Sean Creeley; Licensed BSD */
-(function(e){var t=function(){function e(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function n(e,t){for(var n=[];t>0;n[--t]=e);return n.join("")}var r=function(){return r.cache.hasOwnProperty(arguments[0])||(r.cache[arguments[0]]=r.parse(arguments[0])),r.format.call(null,r.cache[arguments[0]],arguments)};return r.format=function(r,i){var s=1,o=r.length,u="",a,f=[],l,c,h,p,d,v;for(l=0;l<o;l++){u=e(r[l]);if(u==="string")f.push(r[l]);else if(u==="array"){h=r[l];if(h[2]){a=i[s];for(c=0;c<h[2].length;c++){if(!a.hasOwnProperty(h[2][c]))throw t('[sprintf] property "%s" does not exist',h[2][c]);a=a[h[2][c]]}}else h[1]?a=i[h[1]]:a=i[s++];if(/[^s]/.test(h[8])&&e(a)!="number")throw t("[sprintf] expecting number but found %s",e(a));switch(h[8]){case"b":a=a.toString(2);break;case"c":a=String.fromCharCode(a);break;case"d":a=parseInt(a,10);break;case"e":a=h[7]?a.toExponential(h[7]):a.toExponential();break;case"f":a=h[7]?parseFloat(a).toFixed(h[7]):parseFloat(a);break;case"o":a=a.toString(8);break;case"s":a=(a=String(a))&&h[7]?a.substring(0,h[7]):a;break;case"u":a=Math.abs(a);break;case"x":a=a.toString(16);break;case"X":a=a.toString(16).toUpperCase()}a=/[def]/.test(h[8])&&h[3]&&a>=0?"+"+a:a,d=h[4]?h[4]=="0"?"0":h[4].charAt(1):" ",v=h[6]-String(a).length,p=h[6]?n(d,v):"",f.push(h[5]?a+p:p+a)}}return f.join("")},r.cache={},r.parse=function(e){var t=e,n=[],r=[],i=0;while(t){if((n=/^[^\x25]+/.exec(t))!==null)r.push(n[0]);else if((n=/^\x25{2}/.exec(t))!==null)r.push("%");else{if((n=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(t))===null)throw"[sprintf] huh?";if(n[2]){i|=1;var s=[],o=n[2],u=[];if((u=/^([a-z_][a-z_\d]*)/i.exec(o))===null)throw"[sprintf] huh?";s.push(u[1]);while((o=o.substring(u[0].length))!=="")if((u=/^\.([a-z_][a-z_\d]*)/i.exec(o))!==null)s.push(u[1]);else{if((u=/^\[(\d+)\]/.exec(o))===null)throw"[sprintf] huh?";s.push(u[1])}n[2]=s}else i|=2;if(i===3)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";r.push(n)}t=t.substring(n[0].length)}return r},r}(),n=function(e,n){return n.unshift(e),t.apply(null,n)};(function(e){var t=["original_url","url","type","provider_url","provider_display","provider_name","favicon_url","title","description","thumbnail_url","author_name","author_url","object_type","object_html","object_url","object_width","object_height"];e.fn.addInputs=function(n,r){return e(this).each(function(){r=e.isArray(r)?r:t;var i=e(this);e.each(r,function(t,r){var s="";if(r.indexOf("object")===0){var o=r.split("_")[1];n.object.hasOwnProperty(o)&&(s=n.object[o])}else n.hasOwnProperty(r)&&(s=n[r]);var u=e('<input type="hidden"/>').attr({name:r,value:escape(s)});i.append(u)})})}})(jQuery,window,document),function(e){var t=function(e,t){this.init(e,t)};t.prototype={init:function(t,n){this.$elem=e(t),this.options=e.extend({},{onchange:e.noop},n),this.$elem.find(".controls .left").on("click",e.proxy(this.left,this)),this.$elem.find(".controls .right").on("click",e.proxy(this.right,this)),this.$elem.find(".controls .nothumb").on("click",e.proxy(this.nothumb,this)),this.$elem.on("right",e.proxy(this.right,this)),this.$elem.on("left",e.proxy(this.left,this)),this.$elem.on("none",e.proxy(this.nothumb,this)),this.$elem.one("mouseenter",function(){e(this).on("mouseenter mouseleave",function(){e(this).find(".controls").toggle()})})},left:function(e){e.preventDefault(),this.scroll(-1)},right:function(e){e.preventDefault(),this.scroll(1)},scroll:function(e){var t=this.$elem.find(".images"),n=parseInt(t.find("li").css("width"),10),r=parseInt(t.css("left"),10),i=t.find("img").length*n;if(e<0){r=parseInt(r,10)+n;if(r>0)return!1}else{r=parseInt(r,10)-n;if(r<=-i)return!1}var s=t.find("img").eq(r/-n);this.options.onchange.call(s,s),t.css("left",r+"px")},nothumb:function(e){e.preventDefault(),this.$elem.hide(),this.options.onchange.call(null,null)}},e.fn.thumb=function(n){return e(this).each(function(){e(this).data("thumb",new t(this,n))})}}(jQuery),function(e){var n=function(){};n.prototype={protocolExp:/^http(s?):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i,urlExp:/[-\w]+(\.[a-z]{2,})+(\S+)?(\/|\/[\w#!:.?+=&%@!\-\/])?/gi,url:function(t){t=e.trim(t);if(t==="")return null;var n=t.match(this.protocolExp),r=n?n[0]:null;return r===null&&(n=t.match(this.urlExp),r=n?"http://"+n[0]:null),r=e.trim(r),r===""?null:r},none:function(e){return e===null||e===undefined}};var r=new n,i=function(e){this.init(e)};i.prototype={init:function(e){this.options=e},render:function(n,i,s){this.preview=s;var o=e.extend(!0,{},i);o.title=o.title?o.title:o.url;var u=o.favicon_url?'<img class="favicon" src="%(favicon_url)s">':"",a=o.images.map(function(e){return t('<li><img src="%(url)s"/></li>',e)}).join("");a!==""&&(a=['<div class="thumb">','<div class="controls">','<a class="left" href="#">&#9664;</a>','<a class="right" href="#">&#9654;</a>','<a class="nothumb" href="#">&#10005;</a>',"</div>",'<div class="items">','<ul class="images">',a,"</ul>","</div>","</div>"].join(""));var f=['<div class="selector">',a,'<div class="attributes">','<a class="title" href="#" contenteditable=true>%(title)s</a>','<p><a class="description" href="#" contenteditable=true>%(description)s</a></p>','<span class="meta">',u,'<a class="provider" href="%(provider_url)s">%(provider_display)s</a>',"</span>","</div>",'<div class="action"><a href="#" class="close">&#10005;</a></div>',"</div>"].join(""),l=t(f,o),c=n.closest(this.options.container).find(this.options.wrapper).eq(0);c.length===0&&(c=e(this.options.wrapper).eq(0));if(c.length!==1)return!1;c.html(e(l)),c.find(".thumb").thumb({onchange:e.proxy(function(t){r.none(t)?this.preview.update("thumbnail_url",null):this.preview.update("thumbnail_url",e(t).attr("src"))},this)}),c.find(".title").on("blur",e.proxy(function(t){this.preview.update("title",e(t.target).text())},this)),c.find(".description").on("blur",e.proxy(function(t){this.preview.update("description",e(t.target).text())},this)),c.find(".action .close").bind("click",e.proxy(function(e){this.preview.clear(),n.trigger("closed"),c.find(".selector").remove()},this)),c.find(".selector").bind("mouseenter mouseleave",function(){e(this).find(".action").toggle()}),n.on("close",function(){c.find(".selector").remove()})}};var s={debug:!0,selector:{wrapper:".selector-wrapper",container:"form"},preview:{},field:null,query:{wmode:"opaque",words:30,maxwidth:560}},o=function(e,t){this.init(e,t)};o.prototype={$form:null,data:{},init:function(t,n){this.elem=t,this.$elem=e(t),this.url=null;var r=this.$elem.parents("form").eq(0);r.length===1&&(this.$form=r),this.options=e.extend({},s,n),this.$elem.on("keyup",e.proxy(this.keyUp,this)),this.$elem.on("paste",e.proxy(this.paste,this)),this.$elem.on("blur",e.proxy(this.paste,this)),this.$elem.on("close",e.proxy(this.clear,this)),this.$elem.data("preview",{})},log:function(){this.options.debug&&window.console&&window.console.log(Array.prototype.slice.call(arguments))},update:function(e,t){var n=this.$elem.data("preview");n[e]=t},clear:function(){this.$elem.data("preview",{})},keyUp:function(e){if(e.which!==32&&e.which!==13&&e.which!==8)return null;var t=r.url(this.$elem.val());this.log("onKeyUp url:"+t);if(t===null)return this.$elem.trigger("close"),null;this.fetch(t)},paste:function(t){setTimeout(e.proxy(function(){this.fetch()},this),200)},fetch:function(t){t===undefined&&(t=r.url(this.$elem.val())),this.log(t);if(t===null||this.url===t)return!1;this.$elem.trigger("close"),this.url=t,this.$elem.trigger("loading"),e.embedly.preview(t,{key:this.options.key,query:this.options.query}).progress(e.proxy(this._callback,this))},error:function(e){},_callback:function(e){this.log(e),this.$elem.trigger("loaded");if(!e.hasOwnProperty("type"))return this.log("Embedly returned an invalid response"),this.error(e),!1;if(e.type==="error")return this.log("URL ("+e.url+") returned an error: "+e.error_message),this.error(e),!1;if(!e.safe)return this.log("URL ("+e.url+") was deemed unsafe: "+e.safe_message),this.error(e),!1;if(!(e.type in{html:"",image:""}))return this.log("URL ("+e.url+") returned a type ("+e.type+") not handled"),this.error(e),!1;e.images.length>0&&(e.thumbnail_url=e.images[0].url),this.$elem.data("preview",e);var t;this.options.selector.hasOwnProperty("render")?t=this.options.selector:t=new i(this.options.selector),t.render(this.$elem,e,this),this.log("done",e)}},e.fn.preview=function(t,n){return e(this).each(function(e,n){new o(this,t)})}}(jQuery,window,document)})(jQuery,window,document);
+;(function(){var e=function(){function t(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function i(e,t){for(var i=[];t>0;i[--t]=e);return i.join("")}var r=function(){return r.cache.hasOwnProperty(arguments[0])||(r.cache[arguments[0]]=r.parse(arguments[0])),r.format.call(null,r.cache[arguments[0]],arguments)};return r.format=function(r,n){var s,o,l,a,h,u,c,p=1,f=r.length,d="",m=[];for(o=0;f>o;o++)if(d=t(r[o]),"string"===d)m.push(r[o]);else if("array"===d){if(a=r[o],a[2])for(s=n[p],l=0;a[2].length>l;l++){if(!s.hasOwnProperty(a[2][l]))throw e('[sprintf] property "%s" does not exist',a[2][l]);s=s[a[2][l]]}else s=a[1]?n[a[1]]:n[p++];if(/[^s]/.test(a[8])&&"number"!=t(s))throw e("[sprintf] expecting number but found %s",t(s));switch(a[8]){case"b":s=s.toString(2);break;case"c":s=String.fromCharCode(s);break;case"d":s=parseInt(s,10);break;case"e":s=a[7]?s.toExponential(a[7]):s.toExponential();break;case"f":s=a[7]?parseFloat(s).toFixed(a[7]):parseFloat(s);break;case"o":s=s.toString(8);break;case"s":s=(s+="")&&a[7]?s.substring(0,a[7]):s;break;case"u":s=Math.abs(s);break;case"x":s=s.toString(16);break;case"X":s=s.toString(16).toUpperCase()}s=/[def]/.test(a[8])&&a[3]&&s>=0?"+"+s:s,u=a[4]?"0"==a[4]?"0":a[4].charAt(1):" ",c=a[6]-(s+"").length,h=a[6]?i(u,c):"",m.push(a[5]?s+h:h+s)}return m.join("")},r.cache={},r.parse=function(e){for(var t=e,i=[],r=[],n=0;t;){if(null!==(i=/^[^\x25]+/.exec(t)))r.push(i[0]);else if(null!==(i=/^\x25{2}/.exec(t)))r.push("%");else{if(null===(i=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(t)))throw"[sprintf] huh?";if(i[2]){n|=1;var s=[],o=i[2],l=[];if(null===(l=/^([a-z_][a-z_\d]*)/i.exec(o)))throw"[sprintf] huh?";for(s.push(l[1]);""!==(o=o.substring(l[0].length));)if(null!==(l=/^\.([a-z_][a-z_\d]*)/i.exec(o)))s.push(l[1]);else{if(null===(l=/^\[(\d+)\]/.exec(o)))throw"[sprintf] huh?";s.push(l[1])}i[2]=s}else n|=2;if(3===n)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";r.push(i)}t=t.substring(i[0].length)}return r},r}();(function(e){var t=["original_url","url","type","provider_url","provider_display","provider_name","favicon_url","title","description","thumbnail_url","author_name","author_url","media_type","media_html","media_url","media_width","media_height"];e.fn.addInputs=function(i,r){return e(this).each(function(){r=e.isArray(r)?r:t;var n=e(this);e.each(r,function(t,r){var s="";if(0===r.indexOf("object")){var o=r.split("_")[1];i.object.hasOwnProperty(o)&&(s=i.object[o])}else i.hasOwnProperty(r)&&(s=i[r]);var l=e('<input type="hidden"/>').attr({name:r,value:escape(s)});n.append(l)})})}})(jQuery,window,document),function(e){var t=function(e,t){this.init(e,t)};t.prototype={init:function(t,i){this.$elem=e(t),this.options=e.extend({},{preview:null,onchange:e.noop},i),this.$elem.find(".controls .left").on("click",e.proxy(this.left,this)),this.$elem.find(".controls .right").on("click",e.proxy(this.right,this)),this.$elem.find(".controls .nothumb").on("click",e.proxy(function(e){e.preventDefault(),this.$elem.hide()},this)),this.$elem.on("right",e.proxy(this.right,this)),this.$elem.on("left",e.proxy(this.left,this)),this.$elem.on("hide",e.proxy(this.hide,this)),this.$elem.on("show",e.proxy(this.show,this)),this.$elem.one("mouseenter",function(){e(this).on("mouseenter mouseleave",function(){e(this).find(".controls").toggle()})}),this.$elem.data("length",this.$elem.find(".images li").length),this.$elem.data("current",1)},left:function(e){e.preventDefault(),this.scroll(-1)},right:function(e){e.preventDefault(),this.scroll(1)},update:function(e){void 0===e&&(e=null),this.options.onchange.call(e,e)},scroll:function(e){var t=this.$elem.find(".images"),i=parseInt(t.find("li").css("width"),10),r=parseInt(t.css("left"),10),n=t.find("img").length*i;if(0>e){if(r=parseInt(r,10)+i,r>0)return!1}else if(r=parseInt(r,10)-i,-n>=r)return!1;var s=this.$elem.data("current");this.$elem.data("current",s+e);var o=t.find("img").eq(r/-i).get(0);this.update(o),t.css("left",r+"px")},hide:function(){this.$elem.hide(),this.update(null)},show:function(){this.$elem.show();var e=this.$elem.data("current"),t=this.$elem.find(".images img").eq(e-1).get(0);this.update(t)}},e.fn.thumb=function(i){return e(this).each(function(){e(this).data("thumb",new t(this,i))})}}(jQuery),function(t){var i=function(){};i.prototype={protocolExp:/^http(s?):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i,urlExp:/[\-\w]+(\.[a-z]{2,})+(\S+)?(\/|\/[\w#!:.?+=&%@!\-\/])?/gi,url:function(e){if(e=t.trim(e),""===e)return null;var i=e.match(this.protocolExp),r=i?i[0]:null;return null===r&&(i=e.match(this.urlExp),r=i?"http://"+i[0]:null),r=t.trim(r),""===r?null:r},none:function(e){return null===e||void 0===e}};var r=new i,n=function(i,n){var s=t(this),o=t.extend(!0,{},i);o.title=o.title?o.title:o.url;var l=o.favicon_url?'<img class="favicon" src="%(favicon_url)s">':"",a=t.map(o.images,function(t){return e('<li><img src="%(url)s"/></li>',t)}).join("");""!==a&&(a=['<div class="thumb">','<div class="controls">','<a class="left" href="#">&#9664;</a>','<a class="right" href="#">&#9654;</a>','<a class="nothumb" href="#">&#10005;</a>',"</div>",'<div class="items">','<ul class="images">',a,"</ul>","</div>","</div>"].join(""));var h=['<div class="selector">',a,'<div class="attributes">','<a class="title" href="#" contenteditable=true>%(title)s</a>','<p><a class="description" href="#" contenteditable=true>%(description)s</a></p>','<span class="meta">',l,'<a class="provider" href="%(provider_url)s">%(provider_display)s</a>',"</span>","</div>",'<div class="action"><a href="#" class="close">&#10005;</a></div>',"</div>"].join(""),u=e(h,o),c=s.closest(n.container).find(n.wrapper).eq(0);return 0===c.length&&(c=t(n.wrapper).eq(0)),1!==c.length?!1:(c.html(t(u)),c.find(".thumb").thumb({onchange:function(e){var i=null;r.none(e)||(i=t(e).attr("src")),s.data("preview").thumbnail_url=i}}),c.find(".title").on("blur",function(e){s.data("preview").title=t(e.target).text()}),c.find(".description").on("blur",function(e){s.data("preview").description=t(e.target).text()}),c.find(".action .close").bind("click",t.proxy(function(){s.trigger("close"),c.find(".selector").remove()},this)),c.find(".selector").bind("mouseenter mouseleave",function(){t(this).find(".action").toggle()}),s.on("close",function(){c.find(".selector").remove()}),void 0)},s={debug:!0,bind:!0,error:null,success:null,render:n,wrapper:".selector-wrapper",container:"form",field:null,query:{wmode:"opaque",words:30,maxwidth:560}},o=function(e,t){this.init(e,t)};o.prototype={$form:null,data:{},init:function(e,i){this.elem=e,this.$elem=t(e),this.url=null;var r=this.$elem.parents("form").eq(0);1===r.length&&(this.$form=r),this.options=t.extend({},s,i),this.options.bind===!0&&(this.$elem.on("keyup",t.proxy(this.keyUp,this)),this.$elem.on("paste",t.proxy(this.paste,this)),this.$elem.on("blur",t.proxy(this.paste,this))),this.$elem.data("preview",{}),this.$elem.on("close",t.proxy(this.clear,this)),this.$elem.on("clear",t.proxy(this.clear,this)),this.$elem.on("preview",t.proxy(this.fetch,this)),this.$elem.on("update",t.proxy(function(e,t,i){this.$elem.data("preview")[t]=i},this))},log:function(){this.options.debug&&window.console&&window.console.log(Array.prototype.slice.call(arguments))},update:function(e,t){var i=this.$elem.data("preview");i[e]=t},clear:function(){this.$elem.data("preview",{})},keyUp:function(e){if(32!==e.which&&13!==e.which&&8!==e.which)return null;var t=r.url(this.$elem.val());return this.log("onKeyUp url:"+t),null===t?(this.$elem.trigger("close"),null):(this.fetch(t),void 0)},paste:function(){setTimeout(t.proxy(function(){this.fetch()},this),200)},fetch:function(e){return"string"!==t.type(e)&&(e=r.url(this.$elem.val())),this.log(e),null===e||this.url===e?!1:(this.$elem.trigger("close"),this.url=e,this.$elem.trigger("loading"),t.embedly.extract(e,{key:this.options.key,query:this.options.query}).progress(t.proxy(this._callback,this)),void 0)},error:function(e){null!==this.options.error&&t.proxy(this.options.error,this.elem)(e)},_callback:function(e){return this.log(e),this.$elem.trigger("loaded"),e.hasOwnProperty("type")?"error"===e.type?(this.log("URL ("+e.url+") returned an error: "+e.error_message),this.error(e),!1):e.safe?e.type in{html:"",image:""}?(e.images.length>0&&(e.thumbnail_url=e.images[0].url),this.$elem.data("preview",e),t.proxy(this.options.render,this.elem)(e,this.options),null!==this.options.success&&t.proxy(this.options.success,this.elem)(e),this.log("done",e),void 0):(this.log("URL ("+e.url+") returned a type ("+e.type+") not handled"),this.error(e),!1):(this.log("URL ("+e.url+") was deemed unsafe: "+e.safe_message),this.error(e),!1):(this.log("Embedly returned an invalid response"),this.error(e),!1)}},t.fn.preview=function(e){return t(this).each(function(){new o(this,e)})}}(jQuery,window,document)})(jQuery,window,document);
View
2,371 jquery.preview.full.js
0 additions, 2,371 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
12 jquery.preview.full.min.js
@@ -1,12 +0,0 @@
-var Mustache=function(){var a=function(){};a.prototype={otag:"{{",ctag:"}}",pragmas:{},buffer:[],pragmas_implemented:{"IMPLICIT-ITERATOR":true},context:{},render:function(e,d,c,f){if(!f){this.context=d;this.buffer=[]}if(!this.includes("",e)){if(f){return e}else{this.send(e);return}}e=this.render_pragmas(e);var b=this.render_section(e,d,c);if(f){return this.render_tags(b,d,c,f)}this.render_tags(b,d,c,f)},send:function(b){if(b!=""){this.buffer.push(b)}},render_pragmas:function(b){if(!this.includes("%",b)){return b}var d=this;var c=new RegExp(this.otag+"%([\\w-]+) ?([\\w]+=[\\w]+)?"+this.ctag);return b.replace(c,function(g,e,f){if(!d.pragmas_implemented[e]){throw ({message:"This implementation of mustache doesn't understand the '"+e+"' pragma"})}d.pragmas[e]={};if(f){var h=f.split("=");d.pragmas[e][h[0]]=h[1]}return""})},render_partial:function(b,d,c){b=this.trim(b);if(!c||c[b]===undefined){throw ({message:"unknown_partial '"+b+"'"})}if(typeof(d[b])!="object"){return this.render(c[b],d,c,true)}return this.render(c[b],d[b],c,true)},render_section:function(d,c,b){if(!this.includes("#",d)&&!this.includes("^",d)){return d}var f=this;var e=new RegExp(this.otag+"(\\^|\\#)\\s*(.+)\\s*"+this.ctag+"\n*([\\s\\S]+?)"+this.otag+"\\/\\s*\\2\\s*"+this.ctag+"\\s*","mg");return d.replace(e,function(h,i,g,j){var k=f.find(g,c);if(i=="^"){if(!k||f.is_array(k)&&k.length===0){return f.render(j,c,b,true)}else{return""}}else{if(i=="#"){if(f.is_array(k)){return f.map(k,function(l){return f.render(j,f.create_context(l),b,true)}).join("")}else{if(f.is_object(k)){return f.render(j,f.create_context(k),b,true)}else{if(typeof k==="function"){return k.call(c,j,function(l){return f.render(l,c,b,true)})}else{if(k){return f.render(j,c,b,true)}else{return""}}}}}}})},render_tags:function(k,b,d,f){var e=this;var j=function(){return new RegExp(e.otag+"(=|!|>|\\{|%)?([^\\/#\\^]+?)\\1?"+e.ctag+"+","g")};var g=j();var h=function(n,i,m){switch(i){case"!":return"";case"=":e.set_delimiters(m);g=j();return"";case">":return e.render_partial(m,b,d);case"{":return e.find(m,b);default:return e.escape(e.find(m,b))}};var l=k.split("\n");for(var c=0;c<l.length;c++){l[c]=l[c].replace(g,h,this);if(!f){this.send(l[c])}}if(f){return l.join("\n")}},set_delimiters:function(c){var b=c.split(" ");this.otag=this.escape_regex(b[0]);this.ctag=this.escape_regex(b[1])},escape_regex:function(c){if(!arguments.callee.sRE){var b=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+b.join("|\\")+")","g")}return c.replace(arguments.callee.sRE,"\\$1")},find:function(c,d){c=this.trim(c);function b(f){return f===false||f===0||f}var e;if(b(d[c])){e=d[c]}else{if(b(this.context[c])){e=this.context[c]}}if(typeof e==="function"){return e.apply(d)}if(e!==undefined){return e}return""},includes:function(c,b){return b.indexOf(this.otag+c)!=-1},escape:function(b){b=String(b===null?"":b);return b.replace(/&(?!\w+;)|["<>\\]/g,function(c){switch(c){case"&":return"&amp;";case"\\":return"\\\\";case'"':return'"';case"<":return"&lt;";case">":return"&gt;";default:return c}})},create_context:function(c){if(this.is_object(c)){return c}else{var d=".";if(this.pragmas["IMPLICIT-ITERATOR"]){d=this.pragmas["IMPLICIT-ITERATOR"].iterator}var b={};b[d]=c;return b}},is_object:function(b){return b&&typeof b=="object"},is_array:function(b){return Object.prototype.toString.call(b)==="[object Array]"},trim:function(b){return b.replace(/^\s*|\s*$/g,"")},map:function(f,d){if(typeof f.map=="function"){return f.map(d)}else{var e=[];var b=f.length;for(var c=0;c<b;c++){e.push(d(f[c]))}return e}}};return({name:"mustache.js",version:"0.3.0",to_html:function(d,b,c,f){var e=new a();if(f){e.send=f}e.render(d,b,c);if(!f){return e.buffer.join("\n")}}})}();(function(){var u=this;var r=u._;var b={};var i=Array.prototype,B=Object.prototype,E=Function.prototype;var s=i.slice,w=i.unshift,v=B.toString,o=B.hasOwnProperty;var m=i.forEach,h=i.map,z=i.reduce,e=i.reduceRight,l=i.filter,a=i.every,y=i.some,t=i.indexOf,f=i.lastIndexOf,c=Array.isArray,A=Object.keys,j=E.bind;var D=function(F){return new g(F)};if(typeof module!=="undefined"&&module.exports){module.exports=D;D._=D}else{u._=D}D.VERSION="1.2.0";var d=D.each=D.forEach=function(K,J,I){if(K==null){return}if(m&&K.forEach===m){K.forEach(J,I)}else{if(K.length===+K.length){for(var H=0,F=K.length;H<F;H++){if(H in K&&J.call(I,K[H],H,K)===b){return}}}else{for(var G in K){if(o.call(K,G)){if(J.call(I,K[G],G,K)===b){return}}}}}};D.map=function(I,H,G){var F=[];if(I==null){return F}if(h&&I.map===h){return I.map(H,G)}d(I,function(L,J,K){F[F.length]=H.call(G,L,J,K)});return F};D.reduce=D.foldl=D.inject=function(J,I,F,H){var G=F!==void 0;if(J==null){J=[]}if(z&&J.reduce===z){if(H){I=D.bind(I,H)}return G?J.reduce(I,F):J.reduce(I)}d(J,function(M,K,L){if(!G){F=M;G=true}else{F=I.call(H,F,M,K,L)}});if(!G){throw new TypeError("Reduce of empty array with no initial value")}return F};D.reduceRight=D.foldr=function(I,H,F,G){if(I==null){I=[]}if(e&&I.reduceRight===e){if(G){H=D.bind(H,G)}return F!==void 0?I.reduceRight(H,F):I.reduceRight(H)}var J=(D.isArray(I)?I.slice():D.toArray(I)).reverse();return D.reduce(J,H,F,G)};D.find=D.detect=function(I,H,G){var F;p(I,function(L,J,K){if(H.call(G,L,J,K)){F=L;return true}});return F};D.filter=D.select=function(I,H,G){var F=[];if(I==null){return F}if(l&&I.filter===l){return I.filter(H,G)}d(I,function(L,J,K){if(H.call(G,L,J,K)){F[F.length]=L}});return F};D.reject=function(I,H,G){var F=[];if(I==null){return F}d(I,function(L,J,K){if(!H.call(G,L,J,K)){F[F.length]=L}});return F};D.every=D.all=function(I,H,G){var F=true;if(I==null){return F}if(a&&I.every===a){return I.every(H,G)}d(I,function(L,J,K){if(!(F=F&&H.call(G,L,J,K))){return b}});return F};var p=D.some=D.any=function(I,H,G){H=H||D.identity;var F=false;if(I==null){return F}if(y&&I.some===y){return I.some(H,G)}d(I,function(L,J,K){if(F|=H.call(G,L,J,K)){return b}});return !!F};D.include=D.contains=function(H,G){var F=false;if(H==null){return F}if(t&&H.indexOf===t){return H.indexOf(G)!=-1}p(H,function(I){if(F=I===G){return true}});return F};D.invoke=function(G,H){var F=s.call(arguments,2);return D.map(G,function(I){return(H.call?H||I:I[H]).apply(I,F)})};D.pluck=function(G,F){return D.map(G,function(H){return H[F]})};D.max=function(I,H,G){if(!H&&D.isArray(I)){return Math.max.apply(Math,I)}if(!H&&D.isEmpty(I)){return -Infinity}var F={computed:-Infinity};d(I,function(M,J,L){var K=H?H.call(G,M,J,L):M;K>=F.computed&&(F={value:M,computed:K})});return F.value};D.min=function(I,H,G){if(!H&&D.isArray(I)){return Math.min.apply(Math,I)}if(!H&&D.isEmpty(I)){return Infinity}var F={computed:Infinity};d(I,function(M,J,L){var K=H?H.call(G,M,J,L):M;K<F.computed&&(F={value:M,computed:K})});return F.value};D.shuffle=function(H){var F=[],G;d(H,function(K,I,J){if(I==0){F[0]=K}else{G=Math.floor(Math.random()*(I+1));F[I]=F[G];F[G]=K}});return F};D.sortBy=function(H,G,F){return D.pluck(D.map(H,function(K,I,J){return{value:K,criteria:G.call(F,K,I,J)}}).sort(function(L,K){var J=L.criteria,I=K.criteria;return J<I?-1:J>I?1:0}),"value")};D.groupBy=function(H,G){var F={};d(H,function(K,I){var J=G(K,I);(F[J]||(F[J]=[])).push(K)});return F};D.sortedIndex=function(K,J,H){H||(H=D.identity);var F=0,I=K.length;while(F<I){var G=(F+I)>>1;H(K[G])<H(J)?F=G+1:I=G}return F};D.toArray=function(F){if(!F){return[]}if(F.toArray){return F.toArray()}if(D.isArray(F)){return s.call(F)}if(D.isArguments(F)){return s.call(F)}return D.values(F)};D.size=function(F){return D.toArray(F).length};D.first=D.head=function(H,G,F){return(G!=null)&&!F?s.call(H,0,G):H[0]};D.initial=function(H,G,F){return s.call(H,0,H.length-((G==null)||F?1:G))};D.last=function(H,G,F){return(G!=null)&&!F?s.call(H,H.length-G):H[H.length-1]};D.rest=D.tail=function(H,F,G){return s.call(H,(F==null)||G?1:F)};D.compact=function(F){return D.filter(F,function(G){return !!G})};D.flatten=function(F){return D.reduce(F,function(G,H){if(D.isArray(H)){return G.concat(D.flatten(H))}G[G.length]=H;return G},[])};D.without=function(F){return D.difference(F,s.call(arguments,1))};D.uniq=D.unique=function(J,I,H){var G=H?D.map(J,H):J;var F=[];D.reduce(G,function(K,M,L){if(0==L||(I===true?D.last(K)!=M:!D.include(K,M))){K[K.length]=M;F[F.length]=J[L]}return K},[]);return F};D.union=function(){return D.uniq(D.flatten(arguments))};D.intersection=D.intersect=function(G){var F=s.call(arguments,1);return D.filter(D.uniq(G),function(H){return D.every(F,function(I){return D.indexOf(I,H)>=0})})};D.difference=function(G,F){return D.filter(G,function(H){return !D.include(F,H)})};D.zip=function(){var F=s.call(arguments);var I=D.max(D.pluck(F,"length"));var H=new Array(I);for(var G=0;G<I;G++){H[G]=D.pluck(F,""+G)}return H};D.indexOf=function(J,H,I){if(J==null){return -1}var G,F;if(I){G=D.sortedIndex(J,H);return J[G]===H?G:-1}if(t&&J.indexOf===t){return J.indexOf(H)}for(G=0,F=J.length;G<F;G++){if(J[G]===H){return G}}return -1};D.lastIndexOf=function(H,G){if(H==null){return -1}if(f&&H.lastIndexOf===f){return H.lastIndexOf(G)}var F=H.length;while(F--){if(H[F]===G){return F}}return -1};D.range=function(K,I,J){if(arguments.length<=1){I=K||0;K=0}J=arguments[2]||1;var G=Math.max(Math.ceil((I-K)/J),0);var F=0;var H=new Array(G);while(F<G){H[F++]=K;K+=J}return H};D.bind=function(G,H){if(G.bind===j&&j){return j.apply(G,s.call(arguments,1))}var F=s.call(arguments,2);return function(){return G.apply(H,F.concat(s.call(arguments)))}};D.bindAll=function(G){var F=s.call(arguments,1);if(F.length==0){F=D.functions(G)}d(F,function(H){G[H]=D.bind(G[H],G)});return G};D.memoize=function(H,G){var F={};G||(G=D.identity);return function(){var I=G.apply(this,arguments);return o.call(F,I)?F[I]:(F[I]=H.apply(this,arguments))}};D.delay=function(G,H){var F=s.call(arguments,2);return setTimeout(function(){return G.apply(G,F)},H)};D.defer=function(F){return D.delay.apply(D,[F,1].concat(s.call(arguments,1)))};var x=function(G,I,F){var H;return function(){var K=this,J=arguments;var L=function(){H=null;G.apply(K,J)};if(F){clearTimeout(H)}if(F||!H){H=setTimeout(L,I)}}};D.throttle=function(F,G){return x(F,G,false)};D.debounce=function(F,G){return x(F,G,true)};D.once=function(H){var F=false,G;return function(){if(F){return G}F=true;return G=H.apply(this,arguments)}};D.wrap=function(F,G){return function(){var H=[F].concat(s.call(arguments));return G.apply(this,H)}};D.compose=function(){var F=s.call(arguments);return function(){var G=s.call(arguments);for(var H=F.length-1;H>=0;H--){G=[F[H].apply(this,G)]}return G[0]}};D.after=function(G,F){return function(){if(--G<1){return F.apply(this,arguments)}}};D.keys=A||function(H){if(H!==Object(H)){throw new TypeError("Invalid object")}var G=[];for(var F in H){if(o.call(H,F)){G[G.length]=F}}return G};D.values=function(F){return D.map(F,D.identity)};D.functions=D.methods=function(H){var G=[];for(var F in H){if(D.isFunction(H[F])){G.push(F)}}return G.sort()};D.extend=function(F){d(s.call(arguments,1),function(G){for(var H in G){if(G[H]!==void 0){F[H]=G[H]}}});return F};D.defaults=function(F){d(s.call(arguments,1),function(G){for(var H in G){if(F[H]==null){F[H]=G[H]}}});return F};D.clone=function(F){return D.isArray(F)?F.slice():D.extend({},F)};D.tap=function(G,F){F(G);return G};function C(U,S,I){if(U===S){return U!==0||1/U==1/S}if((U==null)||(S==null)){return U===S}if(U._chain){U=U._wrapped}if(S._chain){S=S._wrapped}if(D.isFunction(U.isEqual)){return U.isEqual(S)}if(D.isFunction(S.isEqual)){return S.isEqual(U)}var O=typeof U;if(O!=typeof S){return false}if(!U!=!S){return false}if(D.isNaN(U)){return D.isNaN(S)}var R=D.isString(U),Q=D.isString(S);if(R||Q){return R&&Q&&String(U)==String(S)}var V=D.isNumber(U),T=D.isNumber(S);if(V||T){return V&&T&&+U==+S}var G=D.isBoolean(U),F=D.isBoolean(S);if(G||F){return G&&F&&+U==+S}var M=D.isDate(U),L=D.isDate(S);if(M||L){return M&&L&&U.getTime()==S.getTime()}var K=D.isRegExp(U),J=D.isRegExp(S);if(K||J){return K&&J&&U.source==S.source&&U.global==S.global&&U.multiline==S.multiline&&U.ignoreCase==S.ignoreCase}if(O!="object"){return false}var H=I.length;while(H--){if(I[H]==U){return true}}I.push(U);var P=0,N=true;if(U.length===+U.length||S.length===+S.length){P=U.length;N=P==S.length;if(N){while(P--){if(!(N=P in U==P in S&&C(U[P],S[P],I))){break}}}}else{for(var W in U){if(o.call(U,W)){P++;if(!(N=o.call(S,W)&&C(U[W],S[W],I))){break}}}if(N){for(W in S){if(o.call(S,W)&&!P--){break}}N=!P}}I.pop();return N}D.isEqual=function(G,F){return C(G,F,[])};D.isEmpty=function(G){if(D.isArray(G)||D.isString(G)){return G.length===0}for(var F in G){if(o.call(G,F)){return false}}return true};D.isElement=function(F){return !!(F&&F.nodeType==1)};D.isArray=c||function(F){return v.call(F)==="[object Array]"};D.isObject=function(F){return F===Object(F)};D.isArguments=function(F){return !!(F&&o.call(F,"callee"))};D.isFunction=function(F){return !!(F&&F.constructor&&F.call&&F.apply)};D.isString=function(F){return !!(F===""||(F&&F.charCodeAt&&F.substr))};D.isNumber=function(F){return !!(F===0||(F&&F.toExponential&&F.toFixed))};D.isNaN=function(F){return F!==F};D.isBoolean=function(F){return F===true||F===false||v.call(F)=="[object Boolean]"};D.isDate=function(F){return !!(F&&F.getTimezoneOffset&&F.setUTCFullYear)};D.isRegExp=function(F){return !!(F&&F.test&&F.exec&&(F.ignoreCase||F.ignoreCase===false))};D.isNull=function(F){return F===null};D.isUndefined=function(F){return F===void 0};D.noConflict=function(){u._=r;return this};D.identity=function(F){return F};D.times=function(I,H,G){for(var F=0;F<I;F++){H.call(G,F)}};D.escape=function(F){return(""+F).replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")};D.mixin=function(F){d(D.functions(F),function(G){q(G,D[G]=F[G])})};var k=0;D.uniqueId=function(F){var G=k++;return F?F+G:G};D.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};D.template=function(I,H){var J=D.templateSettings;var F="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+I.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(J.escape,function(K,L){return"',_.escape("+L.replace(/\\'/g,"'")+"),'"}).replace(J.interpolate,function(K,L){return"',"+L.replace(/\\'/g,"'")+",'"}).replace(J.evaluate||null,function(K,L){return"');"+L.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');";var G=new Function("obj",F);return H?G(H):G};var g=function(F){this._wrapped=F};D.prototype=g.prototype;var n=function(G,F){return F?D(G).chain():G};var q=function(F,G){g.prototype[F]=function(){var H=s.call(arguments);w.call(H,this._wrapped);return n(G.apply(D,H),this._chain)}};D.mixin(D);d(["pop","push","reverse","shift","sort","splice","unshift"],function(F){var G=i[F];g.prototype[F]=function(){G.apply(this._wrapped,arguments);return n(this._wrapped,this._chain)}});d(["concat","join","slice"],function(F){var G=i[F];g.prototype[F]=function(){return n(G.apply(this._wrapped,arguments),this._chain)}});g.prototype.chain=function(){this._chain=true;return this};g.prototype.value=function(){return this._wrapped}})();(function(e){function b(){if(e.preview!==undefined&&e.preview.debug&&window.console){console.log(Array.prototype.slice.call(arguments))}}
-/*!
- * linkify - v0.3 - 6/27/2009
- * http://benalman.com/code/test/js-linkify/
- *
- * Copyright (c) 2009 "Cowboy" Ben Alman
- * Licensed under the MIT license
- * http://benalman.com/about/license/
- *
- * Some regexps adapted from http://userscripts.org/scripts/review/7122
- */
-window.linkify=(function(){var k="[a-z\\d.-]+://",m="(?:(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.){3}(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])",l="(?:(?:[^\\s!@#$%^&*()_=+[\\]{}\\\\|;:'\",.<>/?]+)\\.)+",s="(?:ac|ad|aero|ae|af|ag|ai|al|am|an|ao|aq|arpa|ar|asia|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|biz|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|cat|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|coop|com|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|info|int|in|io|iq|ir|is|it|je|jm|jobs|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mobi|mo|mp|mq|mr|ms|mt|museum|mu|mv|mw|mx|my|mz|name|na|nc|net|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|travel|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|xn--0zwm56d|xn--11b5bs3a9aj6g|xn--80akhbyknj4f|xn--9t4b11yi5a|xn--deba0ad|xn--g6w251d|xn--hgbk6aj7f53bba|xn--hlcj6aya9esc7a|xn--jxalpdlp|xn--kgbechtv|xn--zckzah|ye|yt|yu|za|zm|zw)",h="(?:"+l+s+"|"+m+")",t="(?:[;/][^#?<>\\s]*)?",i="(?:\\?[^#<>\\s]*)?(?:#[^<>\\s]*)?",j="\\b"+k+"[^<>\\s]+",g="\\b"+h+t+i+"(?!\\w)",r="mailto:",n="(?:"+r+")?[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@"+h+i+"(?!\\w)",f=new RegExp("(?:"+j+"|"+g+"|"+n+")","ig"),p=new RegExp("^"+k,"i"),q={"'":"`",">":"<",")":"(","]":"[","}":"{","»":"«","›":"‹"},o={callback:function(v,u){return u?'<a href="'+u+'" title="'+u+'">'+v+"</a>":v},punct_regexp:/(?:[!?.,:;'"]|(?:&|&amp;)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)$/};return function(A,J){J=J||{};var C,z,E,v,B="",y=[],x,I,H,u,w,G,F,D;for(z in o){if(J[z]===undefined){J[z]=o[z]}}while(C=f.exec(A)){E=C[0];I=f.lastIndex;H=I-E.length;if(/[\/:]/.test(A.charAt(H-1))){continue}do{u=E;D=E.substr(-1);F=q[D];if(F){w=E.match(new RegExp("\\"+F+"(?!$)","g"));G=E.match(new RegExp("\\"+D,"g"));if((w?w.length:0)<(G?G.length:0)){E=E.substr(0,E.length-1);I--}}if(J.punct_regexp){E=E.replace(J.punct_regexp,function(K){I-=K.length;return""})}}while(E.length&&E!==u);v=E;if(!p.test(v)){v=(v.indexOf("@")!==-1?(!v.indexOf(r)?"":r):!v.indexOf("irc.")?"irc://":!v.indexOf("ftp.")?"ftp://":"http://")+v}if(x!=H){y.push([A.slice(x,H)]);x=I}y.push([E,v])}y.push([A.substr(x)]);for(z=0;z<y.length;z++){B+=J.callback.apply(window,y[z])}return B||A}})();function a(h,f){var g={selector:".selector",type:"small",template:null,elem:null,partials:{images_small:['<div class="thumbnail">','<div class="controls">','<a class="left" href="#">&#9664;</a>','<a class="right" href="#">&#9654;</a>','<a class="nothumb" href="#">&#10005;</a>',"</div>",'<div class="items">','<ul class="images">',"{{#images}}",'<li><img src="{{url}}"/></li>',"{{/images}}","</ul>","</div>","</div>"].join(""),images_large:['<div class="thumbnail">','<a class="left" href="#">&#9664;</a>','<div class="items">','<ul class="images">',"{{#images}}",'<li><img src="{{url}}"/></li>',"{{/images}}","</ul>","</div>",'<a class="right" href="#">&#9654;</a>','<a class="nothumb" href="#">&#10005;</a>',"</div>"].join(""),attributes:['<a class="title" href="#">{{title}}</a>','<p><a class="description" href="#">{{description}}</a></p>'].join(""),title:'<a class="title" href="#">{{title}}</a>',description:'<p><a class="description" href="#">{{description}}</a></p>',favicon:'<img class="favicon" src="{{favicon_url}}">'},templates:{small:['<div class="selector small">',"{{>images_small}}",'<div class="attributes">',"{{>attributes}}",'<span class="meta">',"{{>favicon}}",'<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',"</span>","</div>",'<div class="action"><a href="#" class="close">&#10005;</a></div>',"</div>"].join(""),large:['<div class="selector large">',"{{>title}}","{{>images_large}}",'<div class="attributes">',"{{>description}}",'<span class="meta">',"{{>favicon}}",'<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',"</span>","</div>","</div>"].join(""),rich:{video:['<div class="selector rich">',"{{>title}}","{{>object}}",'<div class="attributes">',"{{>description}}",'<span class="meta">',"{{>favicon}}",'<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',"</span>","</div>","</div>"].join(""),rich:['<div class="selector rich">',"{{>title}}","{{>object}}",'<div class="attributes">',"{{>description}}",'<span class="meta">',"{{>favicon}}",'<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',"</span>","</div>","</div>"].join(""),photo:['<div class="selector rich">',"{{>title}}","{{>object}}",'<div class="attributes">',"{{>description}}",'<span class="meta">',"{{>favicon}}",'<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',"</span>","</div>","</div>"].join(""),link:['<div class="selector rich">',"{{>images_small}}",'<div class="attributes">',"{{>attributes}}",'<span class="meta">',"{{>favicon}}",'<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',"</span>","</div>","</div>"].join("")}},render:function(m){var l=null;if(this.template!==null){l=this.template}else{l=this.templates[this.type]}if(_.isObject(l)){l=l[m.object_type]}var i=this.toView(m);var k=this.toPartials(m);var j=Mustache.to_html(l,i,k);if(h.find(this.selector).length){this.elem=h.find(this.selector).replaceWith(j)}else{this.elem=h.append(j)}this.elem=h.find(this.selector);this.elem.show();if(m.images.length>0){h.find("#id_thumbnail_url").val(m.images[0].url)}else{this.elem.find(".thumbnail").hide()}if(m.images.length===1){this.elem.find(".left, .right").hide()}this.bind()},toView:function(i){return i},toPartials:function(j){var i=e.extend(true,{},this.partials);i.object="";if(j.object&&(j.object.type==="video"||j.object.type==="rich")){i.object='<div class="media">{{{html}}}</div>'}else{if(j.object&&j.object.type==="photo"){i.object='<div class="media"><img src="{{url}}"/></div>'}}if(!j.favion_url){i.favicon=""}return i},clear:function(i){if(i!==undefined){i.preventDefault()}this.elem.html("");this.elem.hide();h.find('input[type="hidden"].preview_input').remove()},scroll:function(l,o){o.preventDefault();var j=this.elem.find(".images");var m=parseInt(j.find("li").css("width"),10);var n=parseInt(j.css("left"),10);var i=j.find("img").length*m;if(l==="left"){n=parseInt(n,10)+m;if(n>0){return false}}else{if(l==="right"){n=parseInt(n,10)-m;if(n<=-i){return false}}else{b("not a valid direction: "+l);return false}}var k=j.find("img").eq((n/-m)).attr("src");h.find("#id_thumbnail_url").val(k);j.css("left",n+"px")},nothumb:function(i){i.preventDefault();this.elem.find(".thumbnail").hide();h.find("#id_thumbnail_url").val("")},title:function(k){k.preventDefault();var j=e("<input/>").attr({value:e(k.target).text(),"class":"title",type:"text"});e(k.target).replaceWith(j);j.focus();var i=this.title;j.one("blur",function(n){var m=e(n.target);h.find("#id_title").val(m.val());var l=e("<a/>").attr({"class":"title",href:"#"}).text(m.val());e(n.target).replaceWith(l);l.bind("click",i)})},description:function(j){j.preventDefault();var i=e("<textarea/>").attr({"class":"description"}).text(e(j.target).text());e(j.target).replaceWith(i);i.focus();var k=this.description;i.one("blur",function(n){var m=e(n.target);h.find("#id_description").val(m.val());var l=e("<a/>").attr({"class":"description",href:"#"}).text(m.val());e(n.target).replaceWith(l);l.bind("click",k)})},update:function(i){this.elem.find("."+e(i.target).attr("name")).text(e(i.target).val())},bind:function(){this.elem.find(".left").bind("click",_.bind(this.scroll,{},"left"));this.elem.find(".right").bind("click",_.bind(this.scroll,{},"right"));this.elem.find(".nothumb").bind("click",this.nothumb);this.elem.find(".action .close").bind("click",this.clear);this.elem.bind("mouseenter mouseleave",function(){e(this).find(".action").toggle()});this.elem.find(".thumbnail").one("mouseenter",function(){e(this).bind("mouseenter mouseleave",function(){e(this).find(".controls").toggle()})});this.elem.find(".title").bind("click",this.title);this.elem.find(".description").bind("click",this.description)}};_.extend(g,f);_.bindAll(g);return g}function d(g){var f={selector:"#feed",type:"small",template:null,partials:{thumbnail:['<div class="thumbnail {{object_type}}">','<a href="{{original_url}}" target="_blank">','<img title="{{title}}" src="{{thumbnail_url}}"/>','<span class="overlay"></span>',"</a>","</div>"].join("")},templates:{small:['<div class="item">',"{{>thumbnail}}",'<div class="attributes">','<a class="title" href="{{original_url}}" target="_blank">{{title}}</a>','<p class="description">{{description}}</p>','<span class="meta">','<img class="favicon" src="{{favicon_url}}"/>','<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',"</span>","</div>",'<div class="clearfix"></div>',"</div>"].join(""),status:['<div class="item">','<div class="status">{{{status_linked}}}</div>',"{{>thumbnail}}",'<div class="attributes">','<a class="title" href="{{original_url}}" target="_blank">{{title}}</a>','<p class="description">{{description}}</p>','<span class="meta">','<img class="favicon" src="{{favicon_url}}"/>','<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',"</span>","</div>",'<div class="clearfix"></div>',"</div>"].join(""),rich:{video:['<div class="item video">','<a class="title" href="{{original_url}}" target="_blank">{{title}}</a>',"{{>object}}",'<div class="attributes">','<p class="description">{{description}}</p>','<span class="meta">','<img class="favicon" src="{{favicon_url}}"/>','<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',"</span>","</div>",'<div class="clearfix"></div>',"</div>"].join(""),rich:['<div class="item rich">','<a class="title" href="{{original_url}}" target="_blank">{{title}}</a>',"{{>object}}",'<div class="attributes">','<p class="description">{{description}}</p>','<span class="meta">','<img class="favicon" src="{{favicon_url}}"/>','<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',"</span>","</div>",'<div class="clearfix"></div>',"</div>"].join(""),photo:['<div class="item photo">','<a class="title" href="{{original_url}}" target="_blank">{{title}}</a>',"{{>object}}",'<div class="attributes">','<p class="description">{{description}}</p>','<span class="meta">','<img class="favicon" src="{{favicon_url}}"/>','<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',"</span>","</div>",'<div class="clearfix"></div>',"</div>"].join(""),link:['<div class="item link">',"{{>thumbnail}}",'<div class="attributes">','<a class="title" href="{{original_url}}" target="_blank">{{title}}</a>','<p class="description">{{description}}</p>','<span class="meta">','<img class="favicon" src="{{favicon_url}}"/>','<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',"</span>","</div>",'<div class="clearfix"></div>',"</div>"].join("")}},toView:function(h){if(h.hasOwnProperty("status")){h.status_linked=linkify(h.status)}return h},toPartials:function(i){var h=e.extend(true,{},this.partials);if(!i.thumbnail_url){h.thumbnail=""}h.object="";if(i.object_type==="video"||i.object_type==="rich"){h.object='<div class="media video">{{{html}}}</div>'}else{if(i.object_type==="photo"||i.type==="image"){h.object='<div class="media image"><img alt="{{title}}" src="{{image_url}}"/></div>'}}if(this.type==="rich"&&i.object_type!=="link"){h.thumbnail=""}return h},create:function(m){var k=null;if(this.template!==null){k=this.template}else{k=this.templates[this.type]}if(_.isObject(k)){k=k[m.object_type]}var h=this.toView(m);var j=this.toPartials(m);var i=Mustache.to_html(k,h,j);var l=e(this.selector).prepend(i).children().first();l.data("preview",m)},play:function(h){},bind:function(){e(".thumbnail.video a, .thumbnail.rich a").live("click",function(i){i.preventDefault();var h=e(this).parents(".item").data("preview");e(this).parents(".item").replaceWith(h.html)})}};_.extend(f,g);_.bindAll(f);f.bind();return f}function c(h,f){var g={api_args:["key","maxwidth","maxheight","width","wmode","autoplay","videosrc","allowscripts","words","chars","secure","frame"],display_attrs:["type","original_url","url","title","description","favicon_url","provider_url","provider_display","provider_name","safe","html","thumbnail_url","object_type","image_url"],default_data:{},debug:false,form:null,type:"link",loading_selector:".loading",options:{debug:false,selector:{},field:null,display:{},preview:{},wmode:"opaque",words:30,maxwidth:560},init:function(j,i){this.options=_.extend(this.options,typeof i!=="undefined"?i:{});var k={};_.each(_.intersection(_.keys(this.options),this.api_args),function(m){var l=i[m];if(!(_.isNull(l)||_.isUndefined(l))){k[m]=l}});this.default_data=k;this.form=null;if(j){this.form=f.form?f.form:j.parents("form")}this.debug=this.options.debug;this.selector=a(this.form,this.options.selector);this.display=d(this.options.display);_.extend(this,this.options.preview);if(j){this.bind()}},getStatusUrl:function(m){var j=h.val();if(j===""){return null}var i=/^http(s?):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i;var l=j.match(i);var k=l?l[0]:null;if(k===null){i=/[-\w]+(\.[a-z]{2,})+(\S+)?(\/|\/[\w#!:.?+=&%@!\-\/])?/gi;l=j.match(i);k=l?"http://"+l[0]:null}return k},toggleLoading:function(){this.form.find(this.loading_selector).toggle()},callback:function(i){},_callback:function(j){this.toggleLoading();b(j);if(!j.hasOwnProperty("type")){b("Embedly returned an invalid response");this.error(j);return false}if(j.type==="error"){b("URL ("+j.url+") returned an error: "+j.error_message);this.error(j);return false}if(!j.safe){b("URL ("+j.url+") was deemed unsafe: "+j.safe_message);this.error(j);return false}if(!(j.type in {html:"",image:""})){b("URL ("+j.url+") returned a type ("+j.type+") not handled");this.error(j);return false}this.form.find('input[type="hidden"].preview_input').remove();var i=this.form;_.each(this.display_attrs,function(o){var k=null;if(o==="object_type"){if(j.hasOwnProperty("object")&&j.object.hasOwnProperty("type")){k=j.object.type}else{k="link"}j.object_type=k}else{if(o==="html"){if(j.hasOwnProperty("object")&&j.object.hasOwnProperty("html")){k=j.object.html}}else{if(o==="image_url"){if(j.hasOwnProperty("object")&&j.object.hasOwnProperty("type")&&j.object.type==="photo"){k=j.object.url}else{if(j.type==="image"){k=j.url}}j.image_url=k}else{k=j[o]}}}var m={name:o,type:"hidden",id:"id_"+o,value:k};var l=i.find("#id_"+o);if(l.length){if(l.attr("type")==="hidden"){delete m.type;l.attr(m)}else{if(!l.val()){l.val(j[o])}else{j[o]=l.val()}l.bind("keyup",function(n){e.preview.selector.update(n)})}l.addClass("preview_input")}else{m["class"]="preview_input";i.append(e("<input />").attr(m))}});this.selector.render(j);this.callback(j)},error:function(){b("error");b(arguments)},ajax:function(i){e.ajax({url:"http://api.embed.ly/1/preview",dataType:"jsonp",data:i,success:this._callback,error:this.error})},fetch:function(i){if(typeof i==="undefined"||typeof i!=="string"){i=this.getStatusUrl()}if(i===null){return true}i=e.trim(i);var k=this.form.find("#id_original_url").val();if(k===i){return true}this.toggleLoading();var j=_.clone(this.default_data);j.url=i;this.ajax(j);return true},keyUp:function(j){if(j.which!==32&&j.which!==13){return null}var i=this.getStatusUrl();if(i===null){return null}b("onKeyUp url:"+i);e(this.status_selector).unbind("keyup");this.fetch(i)},paste:function(i){_.delay(this.fetch,200)},_submit:function(j){var i={};this.form.find("textarea, input").not('input[type="submit"]').each(function(k,l){var m=e(l).attr("name");if(m!==undefined){i[m]=e(l).val()}});this.selector.clear();this.submit(j,i);h.val("");this.form.find('input[type="hidden"].preview_input').remove()},submit:function(k,j){k.preventDefault();var i=e(k.target);e.ajax({type:"post",url:i.attr("action"),data:e.param(j),dataType:"json",success:this.display.create})},bind:function(){b("Starting Bind");h.bind("blur",this.fetch);h.bind("keyup",this.keyUp);h.bind("paste",this.paste);this.form.bind("submit",this._submit);h.bind("attach",this.fetch)}};_.bindAll(g);g.init(h,f);return g}e.preview=new c(null,{});e.fn.preview=function(f,g){e(this).each(function(h,j){e.preview=new c(e(this),f)});return this}})(jQuery);
View
1,114 jquery.preview.js
@@ -1,1114 +0,0 @@
-/*
- * Embedly Preview JQuery v0.0.2
- * =============================
- * This library allows you to easily create a status or url submisstion tool
- * utilizing Embedly's Preview API. For more information see:
- *
- * Embedly: http://embed.ly
- * Embedly Preview API: http://embed.ly/docs/endpoints/1/preview
- *
- * Requirements:
- * -------------
- * jquery-1.6 or higher
- *
- * Usage:
- * ------
- *
- *
- */
-
-(function($){
-function log(){
- if ($.preview !== undefined && $.preview.debug && window.console){
- console.log(Array.prototype.slice.call(arguments));
- }
-}
-/*!
- * linkify - v0.3 - 6/27/2009
- * http://benalman.com/code/test/js-linkify/
- *
- * Copyright (c) 2009 "Cowboy" Ben Alman
- * Licensed under the MIT license
- * http://benalman.com/about/license/
- *
- * Some regexps adapted from http://userscripts.org/scripts/review/7122
- */
-
-// Turn text into linkified html.
-//
-// var html = linkify( text, options );
-//
-// options:
-//
-// callback (Function) - default: undefined - if defined, this will be called
-// for each link- or non-link-chunk with two arguments, text and href. If the
-// chunk is non-link, href will be omitted.
-//
-// punct_regexp (RegExp | Boolean) - a RegExp that can be used to trim trailing
-// punctuation from links, instead of the default.
-//
-// This is a work in progress, please let me know if (and how) it fails!
-
-window.linkify = (function(){
- var
- SCHEME = "[a-z\\d.-]+://",
- IPV4 = "(?:(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.){3}(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])",
- HOSTNAME = "(?:(?:[^\\s!@#$%^&*()_=+[\\]{}\\\\|;:'\",.<>/?]+)\\.)+",
- TLD = "(?:ac|ad|aero|ae|af|ag|ai|al|am|an|ao|aq|arpa|ar|asia|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|biz|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|cat|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|coop|com|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|info|int|in|io|iq|ir|is|it|je|jm|jobs|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mobi|mo|mp|mq|mr|ms|mt|museum|mu|mv|mw|mx|my|mz|name|na|nc|net|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|travel|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|xn--0zwm56d|xn--11b5bs3a9aj6g|xn--80akhbyknj4f|xn--9t4b11yi5a|xn--deba0ad|xn--g6w251d|xn--hgbk6aj7f53bba|xn--hlcj6aya9esc7a|xn--jxalpdlp|xn--kgbechtv|xn--zckzah|ye|yt|yu|za|zm|zw)",
- HOST_OR_IP = "(?:" + HOSTNAME + TLD + "|" + IPV4 + ")",
- PATH = "(?:[;/][^#?<>\\s]*)?",
- QUERY_FRAG = "(?:\\?[^#<>\\s]*)?(?:#[^<>\\s]*)?",
- URI1 = "\\b" + SCHEME + "[^<>\\s]+",
- URI2 = "\\b" + HOST_OR_IP + PATH + QUERY_FRAG + "(?!\\w)",
-
- MAILTO = "mailto:",
- EMAIL = "(?:" + MAILTO + ")?[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@" + HOST_OR_IP + QUERY_FRAG + "(?!\\w)",
-
- URI_RE = new RegExp( "(?:" + URI1 + "|" + URI2 + "|" + EMAIL + ")", "ig" ),
- SCHEME_RE = new RegExp( "^" + SCHEME, "i" ),
-
- quotes = {
- "'": "`",
- '>': '<',
- ')': '(',
- ']': '[',
- '}': '{',
- '»': '«',
- '›': '‹'
- },
-
- default_options = {
- callback: function( text, href ) {
- return href ? '<a href="' + href + '" title="' + href + '">' + text + '<\/a>' : text;
- },
- punct_regexp: /(?:[!?.,:;'"]|(?:&|&amp;)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)$/
- };
-
- return function( txt, options ) {
- options = options || {};
-
- // Temp variables.
- var arr,
- i,
- link,
- href,
-
- // Output HTML.
- html = '',
-
- // Store text / link parts, in order, for re-combination.
- parts = [],
-
- // Used for keeping track of indices in the text.
- idx_prev,
- idx_last,
- idx,
- link_last,
-
- // Used for trimming trailing punctuation and quotes from links.
- matches_begin,
- matches_end,
- quote_begin,
- quote_end;
-
- // Initialize options.
- for ( i in default_options ) {
- if ( options[ i ] === undefined ) {
- options[ i ] = default_options[ i ];
- }
- }
-
- // Find links.
- while ( arr = URI_RE.exec( txt ) ) {
-
- link = arr[0];
- idx_last = URI_RE.lastIndex;
- idx = idx_last - link.length;
-
- // Not a link if preceded by certain characters.
- if ( /[\/:]/.test( txt.charAt( idx - 1 ) ) ) {
- continue;
- }
-
- // Trim trailing punctuation.
- do {
- // If no changes are made, we don't want to loop forever!
- link_last = link;
-
- quote_end = link.substr( -1 )
- quote_begin = quotes[ quote_end ];
-
- // Ending quote character?
- if ( quote_begin ) {
- matches_begin = link.match( new RegExp( '\\' + quote_begin + '(?!$)', 'g' ) );
- matches_end = link.match( new RegExp( '\\' + quote_end, 'g' ) );
-
- // If quotes are unbalanced, remove trailing quote character.
- if ( ( matches_begin ? matches_begin.length : 0 ) < ( matches_end ? matches_end.length : 0 ) ) {
- link = link.substr( 0, link.length - 1 );
- idx_last--;
- }
- }
-
- // Ending non-quote punctuation character?
- if ( options.punct_regexp ) {
- link = link.replace( options.punct_regexp, function(a){
- idx_last -= a.length;
- return '';
- });
- }
- } while ( link.length && link !== link_last );
-
- href = link;
-
- // Add appropriate protocol to naked links.
- if ( !SCHEME_RE.test( href ) ) {
- href = ( href.indexOf( '@' ) !== -1 ? ( !href.indexOf( MAILTO ) ? '' : MAILTO )
- : !href.indexOf( 'irc.' ) ? 'irc://'
- : !href.indexOf( 'ftp.' ) ? 'ftp://'
- : 'http://' )
- + href;
- }
-
- // Push preceding non-link text onto the array.
- if ( idx_prev != idx ) {
- parts.push([ txt.slice( idx_prev, idx ) ]);
- idx_prev = idx_last;
- }
-
- // Push massaged link onto the array
- parts.push([ link, href ]);
- };
-
- // Push remaining non-link text onto the array.
- parts.push([ txt.substr( idx_prev ) ]);
-
- // Process the array items.
- for ( i = 0; i < parts.length; i++ ) {
- html += options.callback.apply( window, parts[i] );
- }
-
- // In case of catastrophic failure, return the original text;
- return html || txt;
- };
-
-})();
-function Selector(form, selector) {
-
- //Base Selector
- var Selector = {
- selector : '.selector',
- type : 'small',
- template : null,
- elem : null,
- partials : {
- 'images_small' : [
- '<div class="thumbnail">',
- '<div class="controls">',
- '<a class="left" href="#">&#9664;</a>',
- '<a class="right" href="#">&#9654;</a>',
- '<a class="nothumb" href="#">&#10005;</a>',
- '</div>',
- '<div class="items">',
- '<ul class="images">',
- '{{#images}}',
- '<li><img src="{{url}}"/></li>',
- '{{/images}}',
- '</ul>',
- '</div>',
- '</div>'].join(''),
- 'images_large' : ['<div class="thumbnail">',
- '<a class="left" href="#">&#9664;</a>',
- '<div class="items">',
- '<ul class="images">',
- '{{#images}}',
- '<li><img src="{{url}}"/></li>',
- '{{/images}}',
- '</ul>',
- '</div>',
- '<a class="right" href="#">&#9654;</a>',
- '<a class="nothumb" href="#">&#10005;</a>',
- '</div>'].join(''),
- 'attributes' : [
- '<a class="title" href="#">{{title}}</a>',
- '<p><a class="description" href="#">{{description}}</a></p>'].join(''),
- 'title' : '<a class="title" href="#">{{title}}</a>',
- 'description' : '<p><a class="description" href="#">{{description}}</a></p>',
- 'favicon' : '<img class="favicon" src="{{favicon_url}}">'
- },
- templates : {
- 'small': [
- '<div class="selector small">',
- '{{>images_small}}',
- '<div class="attributes">',
- '{{>attributes}}',
- '<span class="meta">',
- '{{>favicon}}',
- '<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',
- '</span>',
- '</div>',
- '<div class="action"><a href="#" class="close">&#10005;</a></div>',
- '</div>'].join(''),
- 'large' : [
- '<div class="selector large">',
- '{{>title}}',
- '{{>images_large}}',
- '<div class="attributes">',
- '{{>description}}',
- '<span class="meta">',
- '{{>favicon}}',
- '<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',
- '</span>',
- '</div>',
- '</div>'].join(''),
- 'rich': {
- 'video' : [
- '<div class="selector rich">',
- '{{>title}}',
- '{{>object}}',
- '<div class="attributes">',
- '{{>description}}',
- '<span class="meta">',
- '{{>favicon}}',
- '<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',
- '</span>',
- '</div>',
- '</div>'].join(''),
- 'rich' : [
- '<div class="selector rich">',
- '{{>title}}',
- '{{>object}}',
- '<div class="attributes">',
- '{{>description}}',
- '<span class="meta">',
- '{{>favicon}}',
- '<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',
- '</span>',
- '</div>',
- '</div>'].join(''),
- 'photo' : [
- '<div class="selector rich">',
- '{{>title}}',
- '{{>object}}',
- '<div class="attributes">',
- '{{>description}}',
- '<span class="meta">',
- '{{>favicon}}',
- '<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',
- '</span>',
- '</div>',
- '</div>'].join(''),
- 'link' : [
- '<div class="selector rich">',
- '{{>images_small}}',
- '<div class="attributes">',
- '{{>attributes}}',
- '<span class="meta">',
- '{{>favicon}}',
- '<a class="provider" href="{{provider_url}}">{{provider_display}}</a>',
- '</span>',
- '</div>',
- '</div>'].join('')
- }
- },
-
- // If a developer wants complete control of the selector, they can
- // override the render function.
- render : function (obj) {
- // If the #selector ID is there then replace it with the template. Just
- // tells us where it should be on the page.
- var template = null;
-
- if (this.template !== null) {
- template = this.template;
- } else {
- template = this.templates[this.type];
- }
-
- // A template can be a dict of all the use cases.
- if (_.isObject(template)) {