Commit a06a76c3 authored by Romain Courteaud's avatar Romain Courteaud

Demo of presentation editor.

parent e0b99ed4
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>ERP5</title>
<link rel="stylesheet" href="../lib/jquery/jquerymobile.css">
<!-- renderjs -->
<script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/uritemplate.min.js" type="text/javascript"></script>
<script src="../lib/stateless.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="../lib/jio.js" type="text/javascript"></script>
<script src="../lib/jquery/jquery.js" type="text/javascript"></script>
<script src="../lib/jquery/jquerymobile.js" type="text/javascript"></script>
<!-- custom script -->
<script src="../js/gadget_index_url.js" type="text/javascript"></script>
<style type='text/css'>
iframe {
width: 100%;
margin: 0;
padding: 0;
}
form {
display: inline-block;
}
</style>
</head>
<body>
<header data-role="header" data-position="fixed">
<h2 data-i18n="header.tasks">
Files
</h2>
<a href="#" id="home">
Home
</a>
<a id="newdoc">
New File
</a>
</header>
<article id="mainarticle">
</article>
</body>
</html>
/*global window, rJS, StatelessJS, RSVP, alert, console, XMLHttpRequest */
/*jslint maxlen:120, nomen: true */
(function(location, rJS, $) {
"use strict";
$.mobile.ajaxEnabled = false;
$.mobile.linkBindingEnabled = false;
$.mobile.hashListeningEnabled = false;
$.mobile.pushStateEnabled = false;
function generateUuid() {
function S4() {
return ("0000" + Math.floor(Math.random() * 65536).toString(16)).slice(-4);
}
return S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4();
}
var app = StatelessJS.App(), root_gadget, // XXX Hardcoded gadget
// gadget_url = "http://git.erp5.org/gitweb/officejs.git/blob_plain/" +
// "refs/heads/jqs:/src/gadget/bootstrap-wysiwyg.html",
// gadget_url = "http://192.168.242.82:8001/src/gadget/jqs.html",
gadget_url = "http://git.erp5.org/gitweb/renderjs.git/blob_plain/" + "refs/heads/presentation:/examples/officejs/presentation-editor/index.html?js=1", // XXX Hardcoded storage
jio_storage = jIO.createJIO({
type: "local",
username: gadget_url,
application_name: gadget_url
});
///////////////////////////////////////////////
// Default view
///////////////////////////////////////////////
app.add_url_rule("default", "#", function() {
location.replace(app.url_for("display_list", "GET"));
});
///////////////////////////////////////////////
// Display erp5 site
///////////////////////////////////////////////
app.add_url_rule("display_list", "#/filelist/", function() {
return RSVP.Queue().push(function() {
return jio_storage.allDocs();
}).push(function(response) {
var element = document.getElementById("mainarticle"), list, entry, link, data = response.data, i;
// XXX Clear content
document.getElementById("mainarticle").innerHTML = "";
if (data.total_rows === 0) {
element.textContent = "No results found.";
} else {
list = document.createElement("ul");
list.setAttribute("data-role", "listview");
for (i = 0; i < data.total_rows; i += 1) {
entry = document.createElement("li");
link = document.createElement("a");
link.textContent = data.rows[i].id;
link.href = app.url_for("display_file", "GET", {
id: data.rows[i].id
});
entry.appendChild(link);
list.appendChild(entry);
}
element.appendChild(list);
$(element).enhanceWithin();
}
});
});
app.add_url_rule("display_file", "#/document/{id}", function(options) {
var id = options.id, gadget;
return new RSVP.Queue().push(function() {
// XXX Clear content
document.getElementById("mainarticle").innerHTML = "";
return RSVP.all([ // Load the content
jio_storage.get({
_id: id
}), // Load the gadget
root_gadget.declareGadget(gadget_url, {
sandbox: "iframe",
element: document.getElementById("mainarticle")
}) ]);
}).push(function(result_list) {
var doc = result_list[0];
gadget = result_list[1];
// XXX Howto make it fullscreen?
gadget.element.getElementsByTagName("iframe")[0].style.height = window.innerHeight - 150 + "px";
if (doc.data.content !== "") {
return gadget.setContent(doc.data.content);
}
}).push(function() {
var form1 = document.createElement("form"), form2 = document.createElement("form");
form1.id = "save";
form2.id = "delete";
// XXX Add save button
form1.innerHTML = "<input data-role='button' data-inline='true' type='submit' value='Save' />";
form2.innerHTML = "<input data-role='button' data-inline='true' type='submit' value='Delete' />";
document.getElementById("mainarticle").appendChild(form1);
document.getElementById("mainarticle").appendChild(form2);
$(document.getElementById("mainarticle")).enhanceWithin();
return RSVP.all([ StatelessJS.loopEventListener(document.getElementById("save"), "submit", true, function(evt) {
evt.stopPropagation();
evt.preventDefault();
return gadget.getContent().then(function(content) {
return jio_storage.put({
_id: id,
content: content
});
});
}), // XXX No need to loop
StatelessJS.loopEventListener(document.getElementById("delete"), "submit", true, function(evt) {
evt.stopPropagation();
evt.preventDefault();
return jio_storage.remove({
_id: id
}).then(function() {
location.replace(app.url_for("display_list", "GET"));
});
}) ]);
});
});
app.add_url_rule("new_file", "#/new/", function() {
var new_id = generateUuid();
document.getElementById("mainarticle").focus();
return new RSVP.Queue().push(function() {
return jio_storage.post({
_id: new_id,
// XXX
content: ""
});
}).push(function() {
location.replace(app.url_for("display_file", "GET", {
id: new_id
}));
});
});
rJS(window).ready(function(gadget) {
root_gadget = gadget;
// XXX Make it autoreload
document.getElementById("newdoc").href = app.url_for("new_file", "GET");
// XXX Remove focus from newfile link
// http://perishablepress.com/
// unobtrusive-javascript-remove-link-focus-dotted-border-outlines/
var i;
for (i in document.links) {
if (document.links.hasOwnProperty(i)) {
document.links[i].onfocus = document.links[i].blur;
}
}
StatelessJS.run(app).fail(function(e) {
if (e.constructor === XMLHttpRequest) {
console.warn(e);
e = {
readyState: e.readyState,
status: e.status,
statusText: e.statusText,
response_headers: e.getAllResponseHeaders()
};
}
if (e.constructor === Array || e.constructor === String || e.constructor === Object) {
try {
e = JSON.stringify(e);
} catch (exception) {
console.log(exception);
}
}
console.warn(e);
document.getElementsByTagName("body")[0].textContent = e;
});
});
})(window.location, rJS, jQuery);
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
!function(){var a,b;!function(){var c={},d={};a=function(a,b,d){c[a]={deps:b,callback:d}},b=function(a){if(d[a])return d[a];d[a]={};var e=c[a];if(!e)throw new Error("Module '"+a+"' not found.");for(var f,g=e.deps,h=e.callback,i=[],j=0,k=g.length;k>j;j++)"exports"===g[j]?i.push(f={}):i.push(b(g[j]));var l=h.apply(this,i);return d[a]=f||l}}(),a("rsvp/all",["rsvp/promise","exports"],function(a,b){"use strict";function c(a,b){function c(){for(var a,c=0;c<b.length;c++)a=b[c],a&&"function"==typeof a.then&&"function"==typeof a.cancel&&a.cancel()}if("[object Array]"!==Object.prototype.toString.call(b))throw new TypeError("You must pass an array to all.");return new f(function(d,e,f){function g(a){return function(b){h(a,b)}}function h(a,b){l[a]=b,--m===n&&(0===n?d(l):(d(b),c()))}function i(a){return function(b){f({index:a,value:b})}}function j(a){e(a),c()}var k,l=[],m=b.length,n=b.length-a;0===m&&(1===a?d():d([]));for(var o=0;o<b.length;o++)k=b[o],k&&"function"==typeof k.then?k.then(g(o),j,i(o)):h(o,k)},c)}function d(a){return c(a.length,a)}function e(a){return c(1,a)}var f=a.Promise;b.all=d,b.any=e}),a("rsvp/async",["exports"],function(a){"use strict";function b(){return function(a,b){process.nextTick(function(){a(b)})}}function c(){return function(a,b){setImmediate(function(){a(b)})}}function d(){var a=[],b=new h(function(){var b=a.slice();a=[],b.forEach(function(a){var b=a[0],c=a[1];b(c)})}),c=document.createElement("div");return b.observe(c,{attributes:!0}),window.addEventListener("unload",function(){b.disconnect(),b=null},!1),function(b,d){a.push([b,d]),c.setAttribute("drainQueue","drainQueue")}}function e(){return function(a,b){i.setTimeout(function(){a(b)},1)}}var f,g="undefined"!=typeof window?window:{},h=g.MutationObserver||g.WebKitMutationObserver,i="undefined"!=typeof global?global:this;f="function"==typeof setImmediate?c():"undefined"!=typeof process&&"[object process]"==={}.toString.call(process)?b():h?d():e(),a.async=f}),a("rsvp/cancellation_error",["exports"],function(a){"use strict";function b(a){if(this.name="cancel",void 0!==a&&"string"!=typeof a)throw new TypeError("You must pass a string.");this.message=a||"Default Message"}b.prototype=new Error,b.prototype.constructor=b,a.CancellationError=b}),a("rsvp/config",["rsvp/async","exports"],function(a,b){"use strict";var c=a.async,d={};d.async=c,b.config=d}),a("rsvp/defer",["rsvp/promise","exports"],function(a,b){"use strict";function c(){var a={resolve:void 0,reject:void 0,promise:void 0};return a.promise=new d(function(b,c){a.resolve=b,a.reject=c}),a}var d=a.Promise;b.defer=c}),a("rsvp/events",["exports"],function(a){"use strict";var b=function(a,b){this.type=a;for(var c in b)b.hasOwnProperty(c)&&(this[c]=b[c])},c=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c][0]===b)return c;return-1},d=function(a){var b=a._promiseCallbacks;return b||(b=a._promiseCallbacks={}),b},e={mixin:function(a){return a.on=this.on,a.off=this.off,a.trigger=this.trigger,a},on:function(a,b,e){var f,g,h=d(this);for(a=a.split(/\s+/),e=e||this;g=a.shift();)f=h[g],f||(f=h[g]=[]),-1===c(f,b)&&f.push([b,e])},off:function(a,b){var e,f,g,h=d(this);for(a=a.split(/\s+/);f=a.shift();)b?(e=h[f],g=c(e,b),-1!==g&&e.splice(g,1)):h[f]=[]},trigger:function(a,c){var e,f,g,h,i,j=d(this);if(e=j[a])for(var k=0;k<e.length;k++)f=e[k],g=f[0],h=f[1],"object"!=typeof c&&(c={detail:c}),i=new b(a,c),g.call(h,i)}};a.EventTarget=e}),a("rsvp/hash",["rsvp/defer","exports"],function(a,b){"use strict";function c(a){var b=0;for(var c in a)b++;return b}function d(a){var b={},d=e(),f=c(a);0===f&&d.resolve({});var g=function(a){return function(b){h(a,b)}},h=function(a,c){b[a]=c,0===--f&&d.resolve(b)},i=function(a){d.reject(a)};for(var j in a)a[j]&&"function"==typeof a[j].then?a[j].then(g(j),i):h(j,a[j]);return d.promise}var e=a.defer;b.hash=d}),a("rsvp/node",["rsvp/promise","rsvp/all","exports"],function(a,b,c){"use strict";function d(a,b){return function(c,d){c?b(c):arguments.length>2?a(Array.prototype.slice.call(arguments,1)):a(d)}}function e(a){return function(){var b,c,e=Array.prototype.slice.call(arguments),h=this,i=new f(function(a,d){b=a,c=d});return g(e).then(function(e){e.push(d(b,c));try{a.apply(h,e)}catch(f){c(f)}}),i}}var f=a.Promise,g=b.all;c.denodeify=e}),a("rsvp/promise",["rsvp/config","rsvp/events","rsvp/cancellation_error","exports"],function(a,b,c,d){"use strict";function e(a){return f(a)||"object"==typeof a&&null!==a}function f(a){return"function"==typeof a}function g(a){m.onerror&&m.onerror(a.detail)}function h(a,b){a===b?j(a,b):i(a,b)||j(a,b)}function i(a,b){var c,d=null;try{if(a===b)throw new TypeError("A promises callback cannot return that same promise.");if(e(b)&&(d=b.then,f(d)))return a.on("promise:cancelled",function(){f(b.cancel)&&b.cancel()}),d.call(b,function(d){return c?!0:(c=!0,b!==d?h(a,d):j(a,d),void 0)},function(b){return c?!0:(c=!0,k(a,b),void 0)}),!0}catch(g){return k(a,g),!0}return!1}function j(a,b){m.async(function(){a.isFulfilled||a.isRejected||(a.trigger("promise:resolved",{detail:b}),a.isFulfilled=!0,a.fulfillmentValue=b)})}function k(a,b){m.async(function(){a.isFulfilled||a.isRejected||(a.trigger("promise:failed",{detail:b}),a.isRejected=!0,a.rejectedReason=b)})}function l(a,b){m.async(function(){a.trigger("promise:notified",{detail:b})})}var m=a.config,n=b.EventTarget,o=c.CancellationError,p=function(a,b){var c=this,d=!1;if("function"!=typeof a)throw new TypeError("You must pass a resolver function as the sole argument to the promise constructor");if(void 0!==b&&"function"!=typeof b)throw new TypeError("You can only pass a canceller function as the second argument to the promise constructor");if(!(c instanceof p))return new p(a,b);var e=function(a){d||(d=!0,h(c,a))},f=function(a){d||(d=!0,k(c,a))},i=function(a){d||l(c,a)};this.on("promise:failed",function(a){this.trigger("error",{detail:a.detail})},this),this.on("error",g),this.cancel=function(){if(!d){if(void 0!==b)try{b()}catch(a){return f(a),void 0}f(new o)}};try{a(e,f,i)}catch(j){f(j)}},q=function(a,b,c,d){var e,g,j,l,m=f(c);if(!b.isFulfilled&&!b.isRejected){if(m)try{e=c(d.detail),j=!0}catch(n){l=!0,g=n}else e=d.detail,j=!0;i(b,e)||(m&&j?h(b,e):l?k(b,g):"resolve"===a?h(b,e):"reject"===a&&k(b,e))}},r=function(a,b,c){var d;if("function"==typeof b){try{d=b(c.detail)}catch(e){return}l(a,d)}else l(a,c.detail)};p.prototype={constructor:p,isRejected:void 0,isFulfilled:void 0,rejectedReason:void 0,fulfillmentValue:void 0,then:function(a,b,c){this.off("error",g);var d=new this.constructor(function(){},function(){d.trigger("promise:cancelled",{})});return this.isFulfilled&&m.async(function(b){q("resolve",d,a,{detail:b.fulfillmentValue})},this),this.isRejected&&m.async(function(a){q("reject",d,b,{detail:a.rejectedReason})},this),this.on("promise:resolved",function(b){q("resolve",d,a,b)}),this.on("promise:failed",function(a){q("reject",d,b,a)}),this.on("promise:notified",function(a){r(d,c,a)}),d},fail:function(a){return this.then(null,a)},always:function(a){return this.then(a,a)}},n.mixin(p.prototype),d.Promise=p}),a("rsvp/queue",["rsvp/promise","rsvp/timeout","exports"],function(a,b,c){"use strict";function d(a){if(this.name="resolved",void 0!==a&&"string"!=typeof a)throw new TypeError("You must pass a string.");this.message=a||"Default Message"}var e=a.Promise,f=b.delay;d.prototype=new Error,d.prototype.constructor=d;var g=function(){function a(){for(var a=0;2>a;a++)k[a].cancel()}var b,c,h,i,j=this,k=[];return this instanceof g?(b=new e(function(a,b){c=function(b){return i?void 0:(j.isFulfilled=!0,j.fulfillmentValue=b,i=!0,a(b))},h=function(a){return i?void 0:(j.isRejected=!0,j.rejectedReason=a,i=!0,b(a))}},a),k.push(f()),k.push(k[0].then(function(){k.splice(0,2),0===k.length&&c()})),j.cancel=function(){i||(i=!0,b.cancel(),b.fail(function(a){j.isRejected=!0,j.rejectedReason=a}))},j.then=function(){return b.then.apply(b,arguments)},j.push=function(a,b){var e,f=k[k.length-1];if(i)throw new d;return e=f.then(a,b),k.push(e),k.push(e.then(function(a){return k.splice(0,2),0!==k.length?a:(c(a),void 0)},function(a){if(k.splice(0,2),0!==k.length)throw a;h(a)})),this},void 0):new g};g.prototype=Object.create(e.prototype),g.prototype.constructor=g,c.Queue=g,c.ResolvedQueueError=d}),a("rsvp/reject",["rsvp/promise","exports"],function(a,b){"use strict";function c(a){return new d(function(b,c){c(a)})}var d=a.Promise;b.reject=c}),a("rsvp/resolve",["rsvp/promise","exports"],function(a,b){"use strict";function c(a){return new d(function(b,c){if("object"==typeof a&&null!==a){var d=a.then;if(void 0!==d&&"function"==typeof d)return d.apply(a,[b,c])}return b(a)},function(){void 0!==a&&void 0!==a.cancel&&a.cancel()})}var d=a.Promise;b.resolve=c}),a("rsvp/rethrow",["exports"],function(a){"use strict";function b(a){throw c.setTimeout(function(){throw a}),a}var c="undefined"==typeof global?this:global;a.rethrow=b}),a("rsvp/timeout",["rsvp/promise","exports"],function(a,b){"use strict";function c(a,b,c){function d(d,e){g=setTimeout(function(){b?e(c):d(c)},a)}function e(){clearTimeout(g)}var g;return new f(d,e)}function d(a,b){return c(a,!1,b)}function e(a){return c(a,!0,"Timed out after "+a+" ms")}var f=a.Promise;f.prototype.delay=function(a){return this.then(function(b){return d(a,b)})},b.delay=d,b.timeout=e}),a("rsvp",["rsvp/events","rsvp/cancellation_error","rsvp/promise","rsvp/node","rsvp/all","rsvp/queue","rsvp/timeout","rsvp/hash","rsvp/rethrow","rsvp/defer","rsvp/config","rsvp/resolve","rsvp/reject","exports"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){"use strict";function o(a,b){C[a]=b}var p=a.EventTarget,q=b.CancellationError,r=c.Promise,s=d.denodeify,t=e.all,u=e.any,v=f.Queue,w=f.ResolvedQueueError,x=g.delay,y=g.timeout,z=h.hash,A=i.rethrow,B=j.defer,C=k.config,D=l.resolve,E=m.reject;n.CancellationError=q,n.Promise=r,n.EventTarget=p,n.all=t,n.any=u,n.Queue=v,n.ResolvedQueueError=w,n.delay=x,n.timeout=y,n.hash=z,n.rethrow=A,n.defer=B,n.denodeify=s,n.configure=o,n.resolve=D,n.reject=E}),window.RSVP=b("rsvp")}(window);
\ No newline at end of file
!function(a){if("object"==typeof exports)module.exports=a();else if("function"==typeof define&&define.amd)define(a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.true=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a){window.StatelessJS={Rule:a("./statelessjs/rule.js"),Map:a("./statelessjs/map.js"),App:a("./statelessjs/app.js"),promiseEventListener:a("./statelessjs/promiseEventListener.js"),loopEventListener:a("./statelessjs/loopEventListener.js"),run:a("./statelessjs/run.js")}},{"./statelessjs/app.js":2,"./statelessjs/loopEventListener.js":3,"./statelessjs/map.js":4,"./statelessjs/promiseEventListener.js":5,"./statelessjs/rule.js":8,"./statelessjs/run.js":9}],2:[function(a,b){b.exports=function(a,b,c){"use strict";var d=function(){var a=this;return a instanceof d?(a._url_map=new b,void(a._view_functions={})):new d};return d.prototype={constructor:d,add_url_rule:function(a,b,d,e){if(void 0===d)this._url_map.add(new c(b,a,{build_only:!0,methods:e}));else if(void 0!==d){if(this._url_map.add(new c(b,a,{methods:e})),this._view_functions.hasOwnProperty(a))throw new Error("Already defined endpoint "+a);this._view_functions[a]=d}},url_for:function(a,b,c){return this._url_map.build(a,b,c)},dispatch:function(a,b,c){void 0===c&&(c="GET");var d=this._url_map.match(a,c);if(d===!1)throw new Error("404 not found "+c+" "+a);return this._view_functions[d.endpoint](d.options,b)}},d}(location,a("./map.js"),a("./rule.js"))},{"./map.js":4,"./rule.js":8}],3:[function(a,b){var c=a("rsvp");b.exports=function(a,b,d,e){"use strict";function f(){void 0!==j&&"function"==typeof j.cancel&&j.cancel()}function g(){void 0!==i&&a.removeEventListener(b,i,d),f()}function h(h,k){i=function(a){a.stopPropagation(),a.preventDefault(),f(),j=(new c.Queue).push(function(){return e(a)}).push(void 0,function(a){a instanceof c.CancellationError||(g(),k(a))})},a.addEventListener(b,i,d)}var i,j;return new c.Promise(h,g)}},{rsvp:"OMm+mN"}],4:[function(a,b){b.exports=function(){"use strict";var a=function(b){var c,d=this;if(!(d instanceof a))return new a;if(d._rule_list=[],void 0!==b)for(c=0;c<b.length;c+=1)d.add(b[c])};return a.prototype={constructor:a,add:function(a){this._rule_list.push(a)},match:function(a,b){var c,d;for(void 0===b&&(b="GET"),c=0;c<this._rule_list.length;c+=1)if(this._rule_list[c]._methods[b]===!0&&(d=this._rule_list[c].match(a),d!==!1))return{endpoint:this._rule_list[c]._endpoint,options:d};return!1},build:function(a,b,c){var d;for(void 0===b&&(b="GET"),d=0;d<this._rule_list.length;d+=1)if(this._rule_list[d]._methods[b]===!0&&this._rule_list[d]._endpoint===a)return this._rule_list[d].build(c);throw new Error("Not view matching to "+b+" "+a)}},a}()},{}],5:[function(a,b){var c=a("rsvp");b.exports=function(a,b,d){"use strict";function e(){a.removeEventListener(b,g,d)}function f(c){g=function(a){return e(),a.stopPropagation(),a.preventDefault(),c(a),!1},a.addEventListener(b,g,d)}var g;return new c.Promise(f,e)}},{rsvp:"OMm+mN"}],"OMm+mN":[function(a,b){b.exports=window.RSVP},{}],rsvp:[function(a,b){b.exports=a("OMm+mN")},{}],8:[function(a,b){var c=a("uritemplate");b.exports=function(){"use strict";var a=function(b,c,d){var e,f=this,g=["GET"];if(!(f instanceof a))return new a(b,c,d);if("string"!=typeof b)throw new TypeError("You must pass a uri template string as first argument");for(f._uri_template_text=b,f._endpoint=c,void 0!==d&&(f._build_only=d.build_only,void 0!==d.methods&&(g=d.methods)),f._methods={},e=0;e<g.length;e+=1)f._methods[g[e]]=!0};return a.prototype={constructor:a,compile:function(){this._uri_template=c.parse(this._uri_template_text)},build:function(a){return void 0===this._uri_template&&this.compile(),void 0===a&&(a={}),this._uri_template.expand(a)},match:function(a){return void 0===this._uri_template&&this.compile(),this._build_only?!1:this._uri_template.extract(a)}},a}()},{uritemplate:"RRVr+t"}],9:[function(a,b){var c=a("rsvp"),d=a("./promiseEventListener.js"),e=a("./loopEventListener.js");b.exports=function(){"use strict";function a(a){var b;throw b=a instanceof Error?a.toString():a instanceof XMLHttpRequest?a.toString()+" "+a.status+" "+a.getAllResponseHeaders()+" "+a.statusText:JSON.stringify(a),console.warn(b),a}function b(b){var d=b.newURL.split("#")[1];return d=void 0===d?"":d.split("?")[0],(new c.Queue).push(function(){return i.dispatch("#"+d)}).push(void 0,function(b){return b instanceof c.CancellationError?void 0:a(b)})}function f(){return c.all([b({newURL:window.location.toString()}),e(window,"hashchange",!1,b)])}function g(){return c.Promise(function(a){h=function(b){if(m)throw new Error("One application is already started");return i=b,m=!0,a(),j}})}var h,i,j,k,l,m=!1;return l=d(document,"DOMContentLoaded",!1),k=g(),j=c.Queue().push(function(){return c.all([l,k])}).push(f).push(a,a),h}()},{"./loopEventListener.js":3,"./promiseEventListener.js":5,rsvp:"OMm+mN"}],uritemplate:[function(a,b){b.exports=a("RRVr+t")},{}],"RRVr+t":[function(a,b){b.exports=window.UriTemplate},{}]},{},[1])(1)});
\ No newline at end of file
!function(e){"use strict";function t(e){var n;if(null===e||void 0===e)return!1;if(r.isArray(e))return e.length>0;if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return!0;for(n in e)if(e.hasOwnProperty(n)&&t(e[n]))return!0;return!1}var n=function(){function e(e){this.options=e}return e.prototype.toString=function(){return JSON&&JSON.stringify?JSON.stringify(this.options):this.options},e}(),r=function(){function e(e){return"[object Array]"===Object.prototype.toString.apply(e)}function t(e){return"[object String]"===Object.prototype.toString.apply(e)}function n(e){return"[object Number]"===Object.prototype.toString.apply(e)}function r(e){return"[object Boolean]"===Object.prototype.toString.apply(e)}function i(e,t){var n,r="",i=!0;for(n=0;n<e.length;n+=1)i?i=!1:r+=t,r+=e[n];return r}function o(e,t){for(var n=[],r=0;r<e.length;r+=1)n.push(t(e[r]));return n}function s(e,t){for(var n=[],r=0;r<e.length;r+=1)t(e[r])&&n.push(e[r]);return n}function a(e){if("object"!=typeof e||null===e)return e;Object.freeze(e);var t,n;for(n in e)e.hasOwnProperty(n)&&(t=e[n],"object"==typeof t&&u(t));return e}function u(e){return"function"==typeof Object.freeze?a(e):e}return{isArray:e,isString:t,isNumber:n,isBoolean:r,join:i,map:o,filter:s,deepFreeze:u}}(),i=function(){function e(e){return e>="a"&&"z">=e||e>="A"&&"Z">=e}function t(e){return e>="0"&&"9">=e}function n(e){return t(e)||e>="a"&&"f">=e||e>="A"&&"F">=e}return{isAlpha:e,isDigit:t,isHexDigit:n}}(),o=function(){function e(e){var t,n,r="",i=s.encode(e);for(n=0;n<i.length;n+=1)t=i.charCodeAt(n),r+="%"+(16>t?"0":"")+t.toString(16).toUpperCase();return r}function t(e,t){return"%"===e.charAt(t)&&i.isHexDigit(e.charAt(t+1))&&i.isHexDigit(e.charAt(t+2))}function n(e,t){return parseInt(e.substr(t,2),16)}function r(e){if(!t(e,0))return!1;var r=n(e,1),i=s.numBytes(r);if(0===i)return!1;for(var o=1;i>o;o+=1)if(!t(e,3*o)||!s.isValidFollowingCharCode(n(e,3*o+1)))return!1;return!0}function o(e,r){var i=e.charAt(r);if(!t(e,r))return i;var o=n(e,r+1),a=s.numBytes(o);if(0===a)return i;for(var u=1;a>u;u+=1)if(!t(e,r+3*u)||!s.isValidFollowingCharCode(n(e,r+3*u+1)))return i;return e.substr(r,3*a)}var s={encode:function(e){return unescape(encodeURIComponent(e))},numBytes:function(e){return 127>=e?1:e>=194&&223>=e?2:e>=224&&239>=e?3:e>=240&&244>=e?4:0},isValidFollowingCharCode:function(e){return e>=128&&191>=e}};return{encodeCharacter:e,isPctEncoded:r,pctCharAt:o}}(),s=function(){function e(e){return i.isAlpha(e)||i.isDigit(e)||"_"===e||o.isPctEncoded(e)}function t(e){return i.isAlpha(e)||i.isDigit(e)||"-"===e||"."===e||"_"===e||"~"===e}function n(e){return":"===e||"/"===e||"?"===e||"#"===e||"["===e||"]"===e||"@"===e||"!"===e||"$"===e||"&"===e||"("===e||")"===e||"*"===e||"+"===e||","===e||";"===e||"="===e||"'"===e}return{isVarchar:e,isUnreserved:t,isReserved:n}}(),a=function(){function e(e,t){var n,r="",i="";for(("number"==typeof e||"boolean"==typeof e)&&(e=e.toString()),n=0;n<e.length;n+=i.length)i=e.charAt(n),r+=s.isUnreserved(i)||t&&s.isReserved(i)?i:o.encodeCharacter(i);return r}function t(t){return e(t,!0)}function n(e,t){var n=o.pctCharAt(e,t);return n.length>1?n:s.isReserved(n)||s.isUnreserved(n)?n:o.encodeCharacter(n)}function r(e){var t,n="",r="";for(t=0;t<e.length;t+=r.length)r=o.pctCharAt(e,t),n+=r.length>1?r:s.isReserved(r)||s.isUnreserved(r)?r:o.encodeCharacter(r);return n}return{encode:e,encodePassReserved:t,encodeLiteral:r,encodeLiteralCharacter:n}}(),u=function(){function e(e){t[e]={symbol:e,separator:"?"===e?"&":""===e||"+"===e||"#"===e?",":e,named:";"===e||"&"===e||"?"===e,ifEmpty:"&"===e||"?"===e?"=":"",first:"+"===e?"":e,encode:"+"===e||"#"===e?a.encodePassReserved:a.encode,toString:function(){return this.symbol}}}var t={};return e(""),e("+"),e("#"),e("."),e("/"),e(";"),e("?"),e("&"),{valueOf:function(e){return t[e]?t[e]:"=,!@|".indexOf(e)>=0?null:t[""]}}}(),p=function(){function e(e){this.literal=a.encodeLiteral(e)}return e.prototype.expand=function(){return this.literal},e.prototype.toString=e.prototype.expand,e}(),f=function(){function e(e){function t(){var t=e.substring(h,p);if(0===t.length)throw new n({expressionText:e,message:"a varname must be specified",position:p});c={varname:t,exploded:!1,maxLength:null},h=null}function r(){if(d===p)throw new n({expressionText:e,message:"after a ':' you have to specify the length",position:p});c.maxLength=parseInt(e.substring(d,p),10),d=null}var a,p,f=[],c=null,h=null,d=null,g="";for(a=function(t){var r=u.valueOf(t);if(null===r)throw new n({expressionText:e,message:"illegal use of reserved operator",position:p,operator:t});return r}(e.charAt(0)),p=a.symbol.length,h=p;p<e.length;p+=g.length){if(g=o.pctCharAt(e,p),null!==h){if("."===g){if(h===p)throw new n({expressionText:e,message:"a varname MUST NOT start with a dot",position:p});continue}if(s.isVarchar(g))continue;t()}if(null!==d){if(p===d&&"0"===g)throw new n({expressionText:e,message:"A :prefix must not start with digit 0",position:p});if(i.isDigit(g)){if(p-d>=4)throw new n({expressionText:e,message:"A :prefix must have max 4 digits",position:p});continue}r()}if(":"!==g)if("*"!==g){if(","!==g)throw new n({expressionText:e,message:"illegal character",character:g,position:p});f.push(c),c=null,h=p+1}else{if(null===c)throw new n({expressionText:e,message:"exploded without varspec",position:p});if(c.exploded)throw new n({expressionText:e,message:"exploded twice",position:p});if(c.maxLength)throw new n({expressionText:e,message:"an explode (*) MUST NOT follow to a prefix",position:p});c.exploded=!0}else{if(null!==c.maxLength)throw new n({expressionText:e,message:"only one :maxLength is allowed per varspec",position:p});if(c.exploded)throw new n({expressionText:e,message:"an exploeded varspec MUST NOT be varspeced",position:p});d=p+1}}return null!==h&&t(),null!==d&&r(),f.push(c),new l(e,a,f)}function t(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function r(r){var i,o,s,a=[],u=null,f="",l=!0,h=0;for(i=0;i<r.length;i+=1)if(o=r.charAt(i),null===h){if(null===u)throw new Error("reached unreachable code");if("{"===o)throw new n({templateText:r,message:"brace already opened",position:i});if("}"===o){if(u+1===i)throw new n({templateText:r,message:"empty braces",position:u});try{s=e(r.substring(u+1,i))}catch(d){if(d.prototype===n.prototype)throw new n({templateText:r,message:d.options.message,position:u+d.options.position,details:d.options});throw d}a.push(s),0===s.operator.symbol.length?f+="([^/]+)":l=!1,u=null,h=i+1}}else{if("}"===o)throw new n({templateText:r,message:"unopened brace closed",position:i});"{"===o&&(i>h&&(s=new p(r.substring(h,i)),a.push(s),f+=t(s.literal)),h=null,u=i)}if(null!==u)throw new n({templateText:r,message:"unclosed brace",position:u});return h<r.length&&(s=new p(r.substring(h)),a.push(s),f+=t(s.literal)),l===!1&&(f=void 0),new c(r,a,f)}return r}(),l=function(){function e(e){return JSON&&JSON.stringify?JSON.stringify(e):e}function n(e){if(!t(e))return!0;if(r.isString(e))return""===e;if(r.isNumber(e)||r.isBoolean(e))return!1;if(r.isArray(e))return 0===e.length;for(var n in e)if(e.hasOwnProperty(n))return!1;return!0}function i(e){var t,n=[];for(t in e)e.hasOwnProperty(t)&&n.push({name:t,value:e[t]});return n}function o(e,t,n){this.templateText=e,this.operator=t,this.varspecs=n}function s(e,t,n){var r="";if(n=n.toString(),t.named){if(r+=a.encodeLiteral(e.varname),""===n)return r+=t.ifEmpty;r+="="}return null!==e.maxLength&&(n=n.substr(0,e.maxLength)),r+=t.encode(n)}function u(e){return t(e.value)}function p(e,o,s){var p=[],f="";if(o.named){if(f+=a.encodeLiteral(e.varname),n(s))return f+=o.ifEmpty;f+="="}return r.isArray(s)?(p=s,p=r.filter(p,t),p=r.map(p,o.encode),f+=r.join(p,",")):(p=i(s),p=r.filter(p,u),p=r.map(p,function(e){return o.encode(e.name)+","+o.encode(e.value)}),f+=r.join(p,",")),f}function f(e,o,s){var p=r.isArray(s),f=[];return p?(f=s,f=r.filter(f,t),f=r.map(f,function(t){var r=a.encodeLiteral(e.varname);return r+=n(t)?o.ifEmpty:"="+o.encode(t)})):(f=i(s),f=r.filter(f,u),f=r.map(f,function(e){var t=a.encodeLiteral(e.name);return t+=n(e.value)?o.ifEmpty:"="+o.encode(e.value)})),r.join(f,o.separator)}function l(e,n){var o=[],s="";return r.isArray(n)?(o=n,o=r.filter(o,t),o=r.map(o,e.encode),s+=r.join(o,e.separator)):(o=i(n),o=r.filter(o,function(e){return t(e.value)}),o=r.map(o,function(t){return e.encode(t.name)+"="+e.encode(t.value)}),s+=r.join(o,e.separator)),s}return o.prototype.toString=function(){return this.templateText},o.prototype.expand=function(i){var o,a,u,c,h=[],d=!1,g=this.operator;for(o=0;o<this.varspecs.length;o+=1)if(a=this.varspecs[o],u=i[a.varname],null!==u&&void 0!==u)if(a.exploded&&(d=!0),c=r.isArray(u),"string"==typeof u||"number"==typeof u||"boolean"==typeof u)h.push(s(a,g,u));else{if(a.maxLength&&t(u))throw new Error("Prefix modifiers are not applicable to variables that have composite values. You tried to expand "+this+" with "+e(u));a.exploded?t(u)&&(g.named?h.push(f(a,g,u)):h.push(l(g,u))):(g.named||!n(u))&&h.push(p(a,g,u))}return 0===h.length?"":g.first+r.join(h,g.separator)},o}(),c=function(){function e(e,t,n){this.templateText=e,this.expressions=t,void 0!==n&&(this.regexp=new RegExp("^"+n+"$")),r.deepFreeze(this)}return e.prototype.toString=function(){return this.templateText},e.prototype.expand=function(e){var t,n="";for(t=0;t<this.expressions.length;t+=1)n+=this.expressions[t].expand(e);return n},e.prototype.extract=function(e){var t,n,r,i,o=1,s=!0,a={};if(void 0!==this.regexp&&this.regexp.test(e)){for(i=this.regexp.exec(e),t=0;t<this.expressions.length;t+=1)n=this.expressions[t],void 0===n.literal&&(void 0!==n.operator&&0===n.operator.symbol.length&&1===n.varspecs.length?(r=n.varspecs[0],r.exploded===!1&&null===r.maxLength?-1===i[o].indexOf(",")?(a[r.varname]=decodeURIComponent(i[o]),o+=1):s=!1:s=!1):s=!1);if(s)return a}return!1},e.parse=f,e.UriTemplateError=n,e}();e(c)}(function(e){"use strict";"undefined"!=typeof module?module.exports=e:"function"==typeof define?define([],function(){return e}):"undefined"!=typeof window?window.UriTemplate=e:global.UriTemplate=e});
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment