Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First jasmine tests, and selector choice

  • Loading branch information...
commit 56206fece62d21a88ea35101987d9ac14a59cf60 1 parent 4ec1116
Chris Joel & Michael Sofaer authored
View
3  Gemfile
@@ -0,0 +1,3 @@
+source :rubygems
+
+gem "jasmine"
View
35 Gemfile.lock
@@ -0,0 +1,35 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ childprocess (0.2.3)
+ ffi (~> 1.0.6)
+ diff-lcs (1.1.3)
+ ffi (1.0.11)
+ jasmine (1.1.2)
+ jasmine-core (>= 1.1.0)
+ rack (>= 1.1)
+ rspec (>= 1.3.1)
+ selenium-webdriver (>= 0.1.3)
+ jasmine-core (1.1.0)
+ multi_json (1.0.4)
+ rack (1.3.5)
+ rspec (2.7.0)
+ rspec-core (~> 2.7.0)
+ rspec-expectations (~> 2.7.0)
+ rspec-mocks (~> 2.7.0)
+ rspec-core (2.7.1)
+ rspec-expectations (2.7.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.7.0)
+ rubyzip (0.9.5)
+ selenium-webdriver (2.15.0)
+ childprocess (>= 0.2.1)
+ ffi (~> 1.0.9)
+ multi_json (~> 1.0.4)
+ rubyzip
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ jasmine
View
9 Rakefile
@@ -0,0 +1,9 @@
+
+begin
+ require 'jasmine'
+ load 'jasmine/tasks/jasmine.rake'
+rescue LoadError
+ task :jasmine do
+ abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine"
+ end
+end
View
50 public/javascripts/cloudflare.js
@@ -0,0 +1,50 @@
+var n=void 0,I=null;
+(function(k,l){function Aa(){for(var a=!1,b=arguments.length;b>=-1&&!a;b--){var c=b>=0?arguments[b]:"/";typeof c==="string"&&c&&(a=c.charAt(0)==="/")}}function Ba(a){a=H(a).path.split("/");return a[a.length-1].split(".").pop()}function Ca(a,b){a=H(K(a));b=H(K(b?b:k.location.href));return a.protocol===b.protocol&&a.host===b.host&&a.port===b.port}function K(a,b){function c(a){a.port=a.port||a.protocol&&(a.protocol==="https"&&"443"||a.protocol==="http"&&"80"||"")}var d=H(a),e=b?H(b):H(k.location.href),
+j={};d.path=d.path?d.path.substr(0,1)==="/"?d.path:e.path.split("/").slice(0,-1).join("/")+(d.path?"/"+d.path:""):e.path;c(d);c(e);for(var G in d)j[G]=G==="hash"?d[G]:d[G]||e[G];return V(j)}function V(a){return(a.protocol&&a.protocol+"://")+(a.auth&&a.auth+"@")+(a.host&&a.host)+(a.port&&":"+a.port)+(a.path&&a.path)+(a.query&&"?"+a.query)+(a.hash&&"#"+a.hash)}function H(a){var a=(a||"").match(/^(?!mailto\:)(?!javascript\:)(([^\:\/]+):)?((\/\/)(([^\:\@\/]*\:[^@]*)\@)?([^\#\:\?\$\/]*))?(\:([0-9]+))?(\/?[^\?\#]*)?(\??([^#]*))?(\#?(.*))?$/)||
+[],b=k.location.protocol,c={};c.protocol=a[2]||(a[4]?b&&b.substr(0,b.length-1):"");c.auth=a[5]||"";c.host=a[7]||"";c.port=a[9]||"";c.path=a[10]||"";c.query=a[12]||"";c.hash=a[14]||"";c.toString=function(){return V(c)};return c}function v(){}function W(){return Math.round(Math.random()*X()).toString(16)}function X(){return(new Date).getTime()}function Da(a){return!!a&&(a instanceof Array||typeof a==="object"&&a.hasOwnProperty("length")&&!a.propertyIsEnumerable("length"))}function Ea(a){return/String/.test(ia(a))}
+function ia(a){return Object.prototype.toString.call(a)}function Fa(a,b){for(var c=[],d;d=b.exec(a);)c.push(a.substr(0,d.index)),a=a.substr(d.index+d[0].length);c.push(a);return c}function Ga(a){"preventDefault"in a?a.preventDefault():a.returnValue=!1}function Ha(a){try{return Array.prototype.slice.call(a)}catch(b){}for(var c=0,d=[];c<a.length;d.push(a[c++]));return d}function N(a,b,c,d){Y?a.removeEventListener(b,c,d):a.detachEvent("on"+b,c)}function A(a,b,c,d){Y?a.addEventListener(b,c,d):a.attachEvent("on"+
+b,c)}function Ia(a,b){"dataset"in a?delete a.dataset[b]:ja(a,"data-"+b)}function Ja(a,b,c){"dataset"in a?a.dataset[b]=c:L(a,"data-"+b,c)}function Ka(a,b){return"dataset"in a?a.dataset[b]:ka(a,"data-"+b)}function ja(a,b){"removeAttribute"in a?a.removeAttribute(b):delete a.attributes[b]}function L(a,b,c){"setAttribute"in a?a.setAttribute(b,c):a.attributes[b]=c}function ka(a,b){return"getAttribute"in a?a.getAttribute(b):a.attributes[b]}function la(a,b,c){if(f.verbose)try{console.h()}catch(d){typeof stackTrace!==
+"undefined"?stackTrace(z,a):z(a,b|O,!1)}c!==!1&&p.log(a,b|O)}function Z(a,b,c){if(f.verbose)try{console.info(a)}catch(d){r(a,b|P,!1)}c!==!1&&p.log(a,b|P)}function z(a,b,c){if(f.verbose)try{console.error("[ CLOUDFLARE ] "+a)}catch(d){r(a,b|Q,!1)}c!==!1&&p.log(a,b|Q)}function r(a,b,c){if(f.verbose)try{console.log("[ CLOUDFLARE ] "+a)}catch(d){}c!==!1&&p.log(a,b|1)}function La(a){a=a.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1");return(a=l.cookie.match(RegExp("(?:^|;)\\s?"+a+"=(.*?)(?:;|$)","i")))&&unescape(a[1])}
+function Ma(a,b,c){if(c){var d=new Date;d.setDate(d.getDate()+c)}l.cookie=a+"="+escape(b)+(c?";expires="+d.toUTCString():"")}function Na(a,b){for(var c=0,d=a.length;c<d;c++)if(ma(b,a[c])!=-1)return a[c];return I}function $(a){var b=[];s(a,function(){b.push($)});return b}function na(a){var b=[];s(a,function(a,d){b.push(d)});return b}function ma(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0,d=a.length;c<d;c++)if(b==a[c])return c;return-1}function oa(a){var b=Array.prototype.slice.call(arguments,
+1);s(b,function(b){s(b,function(b,c){a[c]=b})});return a}function Oa(a,b,c){if(a.map)return a.map(b,c);else{var d=[];s(a,function(a,j,G){a=b.call(c,a,j,G);typeof a!=="undefined"&&d.push(a)});return d}}function aa(a,b,c){if(a.filter)return a.filter(b,c);else{var d=[];s(a,function(a,j,G){b.call(c,a,j,G)&&d.push(a)});return d}}function s(a,b,c,d){if(typeof a!=="undefined"&&typeof b!=="undefined")if(a.forEach)a.forEach(b,c);else if("length"in a)for(var d=0,e;e=a[d];d++){if(b.call(c,e,d,a)===!1)break}else for(e in a){if((d||
+a.hasOwnProperty(e))&&b.call(c,a[e],e,a)===!1)break}else r("Warning: 'forEach' received undefined list or callback in arguments!")}var f={},J=k.setTimeout,Pa=k.setInterval,Qa=k.clearInterval,R=k.encodeURIComponent,S=k.parseInt,M=String.prototype.substring,ba=function(){if("MessageChannel"in k){var a=new MessageChannel,b=[];a.port1.onmessage=function(){b.shift()()};return function(c){b.push(c);a.port2.postMessage("")}}return function(a){J(a,0)}}();f.paths={};f.paths.cloudflare="//ajax.cloudflare.com/cdn-cgi/nexp/";
+f.verbose=1;var D=function(){var a=k.localStorage,b=(k.globalStorage||{})[k.location.host.split(":")[0]],c=k.sessionStorage,d=function(){var d=[];a&&d.push(a);b&&d.push(b);c&&d.push(c);return d}(),e={};s("key,getItem,setItem,removeItem,clear,toString".split(","),function(a){e[a]=function(){for(var b=arguments,c=!1,m=0;m<d.length;m++)try{c=d[m][a].apply(d[m],b);break}catch(f){}e.length=m<d.length?d[m].length:0;return c}});return e}(),p={};p.log=function(a,b){var c={};c.message=a;c.category=b;p.history.push(c)};
+p.replay=function(){var a=arguments.length?typeof arguments[0]!=="number"?arguments[0]:p.filter.apply(this,arguments):p.history;s(a,function(a){J(function(){var c=a.message,d=a.category;try{if(d&Q)z(c,d,!1);else if(a.a&P)Z(c,d,!1);else if(a.a&ca){var e=c.expression,j=c.message;try{console.b(e,j)}catch(f){z("Assertion failure: "+j,d|ca,!1)}}else a.a&O?z(c.stack,d,!1):r(c,d,!1)}catch(k){}},0)})};p.step=function(a){var b=p.step.position||0,a=Math.max(a,0)||10;p.e(p.history.slice(b,Math.min(b+a,p.history.length)));
+p.step.position=b+a<p.history.length?b+a:0};p.history=[];p.filter=function(){var a=Array.prototype.slice.call(arguments);return aa(p.history,function(b){var c=!1;b.a&&s(a,function(a){return!(c=b.a&a)});return c})};var P=2,Q=4,ca=8,O=16,y=function(a){function b(a){return a===n||a===I?a:a.valueOf()}function c(a,b){var c=Object;c[a]||(c[a]=b);return c[a]}function d(a){return a}function e(){function b(Ra){if(c)return d=l(Ra),ea.call(c,function(b,c){a(function(){d.promiseSend.apply(d,c)})},n),c=n,d}var c=
+[],d,h=B(e.prototype),g=B(j.prototype);g.promiseSend=function(){var b=x.call(arguments);c?c.push(b):a(function(){d.promiseSend.apply(d,b)})};g.valueOf=function(){return c?g:d.valueOf()};h.promise=C(g);h.resolve=b;h.reject=function(a){return b(m(a))};return h}function j(a,b,c){b===n&&(b=function(a){return m("Promise does not support operation: "+a)});var h=B(j.prototype);h.promiseSend=function(c,h){var g=x.call(arguments,2),da;try{da=a[c]?a[c].apply(a,g):b.apply(a,[c].concat(g))}catch(w){da=m(w)}return(h||
+d)(da)};c&&(h.valueOf=c);return C(h)}function f(a){return a&&typeof a.promiseSend==="function"}function k(a){a=b(a);return a===n||a===I?!1:!!a.promiseRejected}function m(a){return j({when:function(b){return b?b(a):m(a)}},function(){return m(a)},function(){var b=B(m.prototype);b.promiseRejected=!0;b.reason=a;return b})}function l(a){if(f(a))return a;if(a&&typeof a.then==="function"){var b=e();a.then(b.resolve,b.reject);return b.promise}return j({when:function(){return a},get:function(b){return a[b]},
+put:function(b,c){return a[b]=c},del:function(b){return delete a[b]},post:function(b,c){return a[b].apply(a,c)},apply:function(b,c){return a.apply(b,c)},viewInfo:function(){for(var b=a,c={},h={};b;)Object.getOwnPropertyNames(b).forEach(function(a){c[a]||(c[a]=typeof b[a])}),b=Object.getPrototypeOf(b);h.type=typeof a;h.properties=c;return h},keys:function(){return T(a)}},n,function(){return a})}function i(a,c){a=l(a);return c?j({viewInfo:function(){return c}},function(b){var c=x.call(arguments);return q.apply(n,
+[a].concat(c))},function(){return b(a)}):q(a,"viewInfo")}function u(b,c,h){function d(a){try{return c?c(a):a}catch(b){return m(b)}}function g(a){try{return h?h(a):m(a)}catch(b){return m(b)}}var w=e(),i=!1;a(function(){l(b).promiseSend("when",function(a){i||(i=!0,w.resolve(l(a).promiseSend("when",d,g)))},function(a){i||(i=!0,w.resolve(g(a)))})});return w.promise}function o(a){return function(b){var c=x.call(arguments,1);return q.apply(n,[b,a].concat(c))}}function q(b,c){var h=e(),d=x.call(arguments,
+2),b=l(b);a(function(){b.promiseSend.apply(b,[c,h.resolve].concat(d))});return h.promise}function p(a){return u(a,function(a){var b=a.length;if(b===0)return l($);var c=e();ea.call(a,function(h,d,g){u(d,function(h){a[g]=h;--b===0&&c.resolve(a)}).fail(c.reject)},n);return c.promise})}function h(a){return function(){var b=e();x.call(arguments);s(a,this,b).fail(b.reject);return b.promise}}function w(a){if(arguments.length>1)var b=Array.prototype.slice.call(arguments,1),a=a.bind.apply(a,b);return function(){var b=
+e(),c=x.call(arguments);c.push(b.node());r(a,this,c).fail(b.reject);return b.promise}}var g={},C=c("freeze",d),B=c("create",function(a){function b(){}b.prototype=a;return new b}),T=c("keys",function(a){var b=[],c;for(c in a)b.push(c);return b}),ea=Array.prototype.reduce||function(a,b){var c=0,h=this.length;if(arguments.length==1){do{if(c in this){b=this[c++];break}if(++c>=h)throw new TypeError;}while(1)}for(;c<h;c++)c in this&&(b=a(b,this[c],c));return b},x=Array.prototype.slice;g.nextTick=a;g.defer=
+e;e.prototype.node=function(){var a=this;return function(b,c){b?a.reject(b):arguments.length>2?a.resolve(Array.prototype.slice.call(arguments,1)):a.resolve(c)}};g.makePromise=j;j.prototype.then=function(a,b){return u(this,a,b)};ea.call("when,spread,send,get,put,del,post,invoke,keys,apply,call,all,wait,join,fail,fin,view,viewInfo,timeout,delay,end".split(","),function(a,b){j.prototype[b]=function(){return g[b].apply(g,[this].concat(x.call(arguments)))}},n);j.prototype.toSource=function(){return this.toString()};
+j.prototype.toString=function(){return"[object Promise]"};C(j.prototype);g.isPromise=f;g.isResolved=function(a){return!f(b(a))};g.isFulfilled=function(a){return!f(b(a))&&!k(a)};g.isRejected=k;g.reject=m;var pa={constructor:{}};pa.constructor.value=m;m.prototype=B(j.prototype,pa);g.ref=l;g.master=function(a){return j({isDef:function(){}},function(b){var c=x.call(arguments);return q.apply(n,[a].concat(c))},function(){return b(a)})};g.viewInfo=i;g.view=function(a){return i(a).when(function(b){var c;
+c=b.type==="function"?function(){return r(a,n,arguments)}:{};var h=b.properties||{};Object.keys(h).forEach(function(b){h[b]==="function"&&(c[b]=function(){return qa(a,b,arguments)})});return l(c)})};g.when=u;g.spread=function(a,b,c){return u(a,function(a){return b.apply(n,a)},c)};g.async=function(a){return function(){function b(a,g){var w;try{w=c[a](g)}catch(i){return Object.prototype.toString.call(i)==="[object StopIteration]"?i.value:m(i)}return u(w,h,d)}var c=a.apply(this,arguments),h=b.bind(b,
+"send"),d=b.bind(b,"throw");return h()}};g.Method=o;g.send=q;g.get=o("get");g.put=o("put");g.del=o("del");var qa=g.post=o("post");g.invoke=function(a,b){var c=x.call(arguments,2);return qa(a,b,c)};var r=g.apply=o("apply"),s=g.call=function(a,b){var c=x.call(arguments,2);return r(a,b,c)};g.keys=o("keys");g.all=p;g.wait=function(a){return p(arguments).get(0)};g.join=function(){var a=x.call(arguments),b=a.pop();return p(a).spread(b)};g.fail=function(a,b){return u(a,n,b)};g.fin=function(a,b){return u(a,
+function(a){return u(b(),function(){return a})},function(a){return u(b(),function(){return m(a)})})};g.end=function(b){u(b,n,function(b){a(function(){throw b;})})};g.timeout=function(a,b){var c=e();u(a,c.resolve,c.reject);J(function(){c.reject("Timed out")},b);return c.promise};g.delay=function(a,b){arguments.length<2&&(b=a,a=n);var c=e();J(function(){c.resolve(a)},b);return c.promise};g.wrap=h;g.wcall=function(a){var b=x.call(arguments,1);return h(a).apply(n,b)};g.node=w;g.ncall=function(a,b){var c=
+x.call(arguments,2);return w(a).apply(b,c)};return g}(ba),fa=y.ref,Sa=y.reject,ra=y.when,E=y.defer,Ta=y.ref,sa=y.isRejected,Ua=y.isResolved,F=k.navigator.userAgent,U=function(){for(var a=3,b=l.createElement("div"),c=b.getElementsByTagName("i");b.innerHTML="<\!--[if gt IE "+ ++a+"]><i></i><![endif]--\>",c[0];);return a>4?a:n}(),Va=Number((F.match(/Firefox\/([0-9]+\.[0-9]+)/)||[0,0])[1])||n,Wa=Number((F.match(/Chrome\/([0-9]+\.[0-9]+)/)||[0,0])[1])||n,Xa=Number((F.match(/Version\/([0-9]+\.[0-9]+)\sSafari\//)||
+[0,0])[1])||n,ta=Number((F.match(/Opera\/.*\sVersion\/([0-9]+\.[0-9]+)|Opera\/([0-9]+\.[0-9]+)/)||[]).slice(1).join(""))||n,Ya=F.indexOf("AppleWebKit")!==-1||n,Za=F.indexOf("Macintosh")!==-1||n,$a=F.indexOf("Windows")!==-1||n,ua=!!l.createElement.call,ab=!!l.write.call,bb=!(!k.attachEvent||!k.attachEvent.call),Y=!!k.addEventListener,va=l.__defineSetter__&&l.__defineGetter__&&"moz"||Object.defineProperty&&Object.getOwnPropertyDescriptor&&"ie"||!1,cb=typeof l.createElement("span").textContent!=="undefined",
+db="localStorage"in k||"globalStorage"in k,ga=function(){var a=l.createElement;return function(b){return ua?a.apply(l,arguments):a(b)}}(),eb=function(){var a="textContent"in l.documentElement.firstChild;return function(b){return a?b.textContent:b.innerText||""}}(),fb=function(){var a=E();U<9?A(l,"readystatechange",function(){"readyState"in l&&l.readyState==="complete"&&a.resolve(event)},!0):A(l,"DOMContentLoaded",function(b){a.resolve(b)},!0);return a.promise}(),wa=function(){try{var a=E();A(k,"load",
+function(b){a.resolve(b)},!0);return a.promise}catch(b){alert("here too!")}}(),xa=function(){var a=l.write,b=!0;wa.then(function(){b=!1});return function(c){b&&(ab?a.apply(l,arguments):a(c))}}(),gb=function(){function a(a,c,d,e){function j(a){return function(){var b=arguments;try{return a.apply(this,b)}catch(c){r("Warning: failed to modify getter / setter for property "+b[1]+". "+c.message)}}}this.c=j(a)||v;this.d=j(c)||v;this.f=j(d)||v;this.g=j(e)||v}switch(va){case "moz":return new a(function(a,
+c){return a.__lookupGetter__(c)},function(a,c){return a.__lookupSetter__(c)},function(a,c,d){a.__defineGetter__(c,d)},function(a,c,d){a.__defineSetter__(c,d)});case "ie":return new a(function(a,c){return Object.getOwnPropertyDescriptor(a,c).get},function(a,c){return Object.getOwnPropertyDescriptor(a,c).set},function(a,c,d){Object.defineProperty(a,c,{get:d})},function(a,c,d){Object.defineProperty(a,c,{set:d})});default:return new a}}(),ha=function(){return U<9||Xa<3.3||ta<9.3?function(a){var b=ga("script"),
+c=W(),d="__eval#"+c,c="__result#"+c,e=l.getElementsByTagName("head")[0];CloudFlare[d]=a;b.type="text/javascript";b.text="CloudFlare['"+c+"']=eval(CloudFlare['"+d+"']);";e.insertBefore(b,e.firstChild);e.removeChild(b);a=CloudFlare[c];delete CloudFlare[d];delete CloudFlare[c];return a}:function(a){return function(){return(0,eval)(a)}.call(k)}}(),ya=function(){var a=["Microsoft.XMLHTTP","MSXML2.XMLHTTP.3.0","MSXML3.XMLHTTP","MSXML2.XMLHTTP.6.0"];return function(b){function c(){var a=q.responseText;Qa(h);
+d();u(a)}function d(){var a;a:{if(p)try{var b=q.responseText,c=b.length,h,e;if(g<c&&(b=M.call(b,g),c=b.indexOf("|"),c>-1&&(c=S(M.call(b,25,c)),C&&B.length===C.length-1&&(c-=2),c<=b.length)))if(g+=c,b=b.substr(0,c),e=b.match(RegExp("s*--"+w+"\r\nBag: (.+)\r\n"))){h={};h.contents=M.call(b,e[0].length);h.meta=e[1].split("|");if(C)h.url=C[h.meta[2]],B.push(h);else{h=h.contents;for(C={length:0};e=h.match(/\s*\d*:(.*)\s*/);)h=M.call(h,e[0].length),C[S(e[0].split(":")[0])]=e[1],C.length++}a=!0;break a}else o("Failed to match a chunk header while parsing scripts. This is potentially fatal!")}catch(f){z("Warning: problem during chunk parsing. "+
+f.message)}a=!1}a&&(B.length&&i(B[B.length-1]),d())}var e=b.headers||{},j=b.method||"get",f=j!=="get"?b.data+"\r\n":function(){var a=[],c=b.data,h;for(h in c)if(c[h]instanceof Array)for(var d=0;d<c[h].length;d++)a.push(R(h)+"[]="+R(c[h][d]));else a.push(R(h)+"="+R(c[h]));return a.join("&").replace(/%20/g,"+")}(),l=b.url+(j==="get"&&f.length?"?"+f:""),m=b.async!==!1,p=b.multipart||!1,i=b.progress||v,u=b.complete||v,o=b.error||v,q;a:if("XMLHttpRequest"in k)q=new XMLHttpRequest;else{for(;a.length;)try{q=
+new ActiveXObject(a[a.length-1]);break a}catch(s){a.pop()}q=n}var h=I,w=I,g=0,C=I,B=[];q.onreadystatechange=function(){try{var a=q.readyState,b=function(){var a=q.getResponseHeader("Content-Type")||"",b=a.indexOf("boundary=");try{q.getResponseHeader("PE-TS")}catch(c){o("Failed to get timestamp header from server. "+c.message)}b>-1&&(w=M.call(a,b).replace(/"/g,"").split("=")[1])},g;try{g=q.status}catch(i){}if(g&&g>399)q.onreadystatechange=v,o(g);else if(a===3&&!h)try{b(),w&&(h=Pa(d,25))}catch(e){r("Warning: error handling transport at ready state 3. "+
+e.message)}else a===4&&(w||b(),c())}catch(f){o("Uncaught exception while attempting to contact the cloud: "+f.message),q.onreadystatechange=v}};q.open(j,l,m);for(var T in e)q.setRequestHeader(T,e[T]);q.send(f?f:n)}}(),za=function(){function a(a){b=a.shiftKey}var b=!1;A(l,"keydown",a);A(l,"keyup",a);A(k,"unload",function(){b&&D.clear()});return function(a,b){var e=!f.byc,j=f.atok,l=f.bag||"/cdn-cgi/pe/bag",k=!1,m=na(a);e&&(m=aa(m,function(b){var d="CLOUDFLARE::"+b,e=D.getItem(d);if(e)try{return e=
+JSON.parse(e),a[b](e.contents,e.meta[3]),!1}catch(f){z("Stored item with key "+d+" was corrupt. Purging..."),D.removeItem(d)}return!0}));m.length?function(){var e=arguments.callee,i=m.splice(0,16),f={};data={};headers={};f.data={};f.data.r=(k=i.length===1)?i.concat(i):i;f.headers={};f.headers["PE-Token"]=j;f.url=l;f.multipart=!0;f.error=function(e){z("Error retrieving items from the cloud. Status code: "+e);s(i,function(b){a[b](e,n)});b()};f.progress=function(b){var d=b.meta[4].toLowerCase().indexOf("text/html")===
+-1&&S(b.meta[3])<400;if(k!==1)if(k=k&&1,d){d="CLOUDFLARE::"+b.url;try{D.setItem(d,JSON.stringify(b))}catch(e){z("Failed to store item "+d+". "+e.message)}a[b.url](b.contents,b.meta[3])}else a[b.url]("",b.meta[3])};f.complete=function(){m.length?e():b()};ya(f)}():b()}}();(function(){function a(a){typeof a==="function"?ba(function(){a(b,c)}):s(a,function(a,b){f[b]=a})}function b(a,b){return d(a,"bag"in f&&!f.bag?j:F).then(function(a){return b?b.apply(b,a):fa()})}function c(){var a=arguments.length,
+c=a>1&&typeof arguments[0]==="string"&&arguments[0]||"",d=a>1&&arguments[a-2]!==c&&arguments[a-2]||[],e=typeof arguments[a-1]==="function"&&arguments[a-1],f=E();t(c)?f.reject(Error('Module "'+name+'" is already defined.')):e?(c?o[c]=f:q.push(f),b(d,function(){var a;r(c?'Defining "'+c+'" as a module.':"Defining an anonymous module.");try{a=e.apply(i,arguments)}catch(b){f.reject(b)}a&&f.resolve(a)})):f.reject(Error('Module "'+name+'" did not provide an intializer.'));return f.promise}function d(a,b){var c=
+E(),d=[],e,a=a||[];a.length?(s(a,function(a){var c=e;e=ra(b(a).then(function(a){return a},function(b){z('Required module "'+a+'" was rejected. '+b.message)}),function(a){ra(c,function(){d.push(a)})})}),e.then(function(){c.resolve(d)})):c.resolve(d);return c.promise}function e(a){var b=E(),c;t(a)?b.resolve(o[a].promise):(r('Writing "'+a+'" into the DOM as a blocking module.'),c="cfjs_block_"+W(),v(c).then(function(){b.resolve(m(a))},function(c){b.reject(Error('Written script for module "'+a+'" did not load properly. '+
+c.message))}),xa('<script id="'+c+'" onload="CloudFlare.__'+c+'_load()" onerror="CloudFlare.__'+c+'_error()" onreadystatechange="CloudFlare.__'+c+'_readystatechange()" type="text/javascript" src="'+y(a)+'"><\/script>'));return b.promise}function j(a){var b=E(),c=ga("script"),d=l.getElementsByTagName("head")[0];t(a)?b.resolve(o[a].promise):(r('Attempting to resolve module "'+a+'" with asynchronous script insertion.'),v(c).then(function(){b.resolve(m(a))},function(c){b.reject(Error('Inserted script for module "'+
+a+'" did not load properly. '+c.message))}),L(c,"type","text/javascript"),L(c,"src",y(a)),L(c,"async","true"),d.insertBefore(c,d.firstChild));return b.promise}function v(a){function b(){d();f.reject(Error("The module script dispatched an error event during load."))}function c(){e&&(a=l.getElementById(e));if(!("readyState"in a)||a.readyState==="loaded"||a.readyState==="complete")d(),f.resolve()}function d(){e?(delete i["__"+e+"_load"],delete i["__"+e+"_readystatechange"],delete i["__"+e+"_error"]):
+(N(a,"load",c),N(a,"readystatechange",c),N(a,"error",b))}var e=typeof a==="string"&&a,f=E();J(function(){f.reject(Error("The module script timed out during load."))},1E4);e?(i["__"+e+"_load"]=c,i["__"+e+"_readystatechange"]=c,i["__"+e+"_error"]=b):(A(a,"load",c),A(a,"readystatechange",c),A(a,"error",b));return f.promise}function t(a){return a in o&&!sa(o[a])}function m(a){var b=E(),c=!(a.split("/")[0]in f.paths);c&&!t(a)&&q.length&&(o[a]=q.pop());t(a)?b.resolve(o[a].promise):c?(r('Warning: "'+a+'" does not appear to define a module.'),
+o[a]=b,b.resolve()):b.reject(Error('Module "'+a+'" was not properly defined.'));return b.promise}function y(a){var b;return(b=f.paths[a.split("/")[0]])&&typeof b==="string"?K(b+(b.substr(b.length-1)!=="/"?"/":"")+a+".js"+(f.bustCache?"?"+X():"")):K(a)}var i={},u=k.CloudFlare||{},o={},q=[],F=function(){var a=[],b={},c=0;return function(d){var e=E();t(d)?e.resolve(o[d].promise):(a.push(d),b[d]=e,r('Queueing "'+d+'" to be resolved by the cloud.'),c=c||J(function(){var d={};r('The following queued modules are being looked up: "'+
+a.join('", "')+'."');s(a,function(a){var c=y(a);t(a)&&!sa(o[a])&&!Ua(o[a])||(d[c]=d[c]||function(c,d){d=S(d);if(c){r('Executing code related to "'+a+'" that was received from the cloud.');try{ha(c),b[a].resolve(m(a))}catch(e){b[a].reject(e)}}else d>499&&d<801?b[a].resolve(j(a)):b[a].reject(Error('Code for module "'+a+'" retrieved from the cloud came back with status '+d+"."))})});c=0;a=[];za(d,function(){r("A correspondance with the cloud has concluded.")})},50));return e.promise}}();u&&u.length&&
+s(u,a);!f.apps&&!f.bag&&(f.bag=0);i.defer=E;i.promise=fa;i.ref=Ta;i.reject=Sa;i.require=b;i.require.paths=f.paths;i.define=c;i.define.amd={};i.block=function(a,b){return d(a,e).then(function(a){return b?b.apply(b,a):fa()})};i.push=a;A(k,"load",function(){i.block=i.require},!0);i.debug={};i.debug.log=p;i.debug.module={};i.debug.module.clear=function(){o={}};i.debug.module.remove=function(a){delete o[a]};i.debug.module.resolve=function(a){return y(a)};i.debug.module.exists=function(a){return a in o};
+i.debug.module.list=function(){for(var a in o)r(a)};i.debug.eval=function(a){return ha(a)};i.debug.cache={};i.debug.cache.clear=function(){D.clear()};i.debug.cache.show=function(a){var b;switch(typeof a){default:case "undefined":for(a=0;a<D.length;a++)b=D.key(a),b.indexOf("CLOUDFLARE")===0&&r(a+") "+b);break;case "number":b=D.key(a);case "string":return JSON.parse(D.getItem(b||a))}};k.location.toString().indexOf("silent=1")!==-1&&(f.verbose=!1);k.CloudFlare=i})();var t=CloudFlare.define,hb=CloudFlare.require,
+y=CloudFlare.block;t("cloudflare/console",function(){var a={};a.log=typeof r!=="undefined"?r:v;a.error=typeof z!=="undefined"?z:v;a.info=typeof Z!=="undefined"?Z:v;a.trace=typeof la!=="undeinfed"?la:v;a.LOG=1;a.INFO=P;a.ERROR=Q;a.ASSERT=ca;a.TRACE=O;a.EXECUTION=32;a.PARSER=64;a.HACK=128;a.WARNING=256;return a});t("cloudflare/iterator",function(){var a={};a.forEach=s;a.map=Oa;a.filter=aa;a.extend=oa;a.indexOf=ma;a.keys=na;a.values=$;a.firstInBoth=Na;return a});t("cloudflare/dom",function(){var a={};
+a.userAgent=F;a.internetExplorer=U;a.chrome=Wa;a.opera=ta;a.firefox=Va;a.webkit=Ya;a.macintosh=Za;a.windows=$a;a.hasCreateElementCallApply=ua;a.hasAttachEventCallApply=bb;a.hasStandardEvents=Y;a.hasDefineSetterGetter=va;a.hasTextContent=cb;a.hasStorage=db;a.getAttribute=ka;a.setAttribute=L;a.removeAttribute=ja;a.getData=Ka;a.setData=Ja;a.removeData=Ia;a.addEventListener=A;a.removeEventListener=N;a.createElement=ga;a.textContent=eb;a.nodeListToArray=Ha;a.onLoad=wa;a.onReady=fb;a.write=xa;a.preventDefault=
+Ga;return a});t("cloudflare/user",function(){var a={};a.getCookie=La;a.setCookie=Ma;a.storage=D;return a});t("cloudflare/path",function(){var a={};a.parseURL=H;a.stringifyURL=V;a.parseExtension=Ba;a.resolveFullURL=K;a.resolvePath=Aa;a.sameOrigin=Ca;return a});t("cloudflare/utility",function(){var a={};a.accessors=gb;a.split=Fa;a.getClass=ia;a.isString=Ea;a.isArray=Da;a.now=X;a.uid=W;a.globalEval=ha;a.nextTick=ba;a.noop=v;return a});t("cloudflare/loader",function(){var a={};a.load=za;a.ajax=ya;return a});
+t("cloudflare/config",function(){return oa({},f)});t("cloudflare",function(){return CloudFlare});U<7?y(["cloudflare/json"]):t("cloudflare/json",function(){return JSON});if(f.apps){var ib={highlight:1,punchtab:1,usrvc:1,prnc:1};s(f.apps,function(a,b){ib[b]&&(b==="highlight"?b="cloudflare/highlight":f.paths[b]="//ajax.cloudflare.com/cdn-cgi/nexp/apps/",t(b+"/config",function(){return a}),hb([b]))})}delete f.paths.apps;f.owl&&CloudFlare.require(["cloudflare/owl"],function(a){a.watch()});f.mirage&&CloudFlare.require(["cloudflare/mirage"],
+function(a){a.activate()})})(window,document,typeof window.__CF!="undefined"&&window.__CF.DJS||typeof window.DJS=="object"&&window.DJS.length&&window.DJS||[]);
View
17 public/javascripts/stop_sopa.js
@@ -0,0 +1,17 @@
+CloudFlare.define(
+ "stop_sopa",
+ ["cloudflare/jquery1.7"],
+ function($) {
+
+ var selector = "header, h1";
+
+ return {
+
+ targetSelector: function(value) {
+
+ if(value) selector = value;
+ else return selector;
+ }
+ }
+ }
+);
View
12 spec/javascripts/helpers/SpecHelper.js
@@ -0,0 +1,12 @@
+beforeEach(function() {
+ this.sopa = null;
+ var self = this;
+
+ var promise = CloudFlare.require(["stop_sopa"], function(sopa){
+ self.sopa = sopa;
+ })
+
+ waitsFor(function(){
+ return this.sopa !== null;
+ })
+});
View
9 spec/javascripts/stop_sopa_spec.js
@@ -0,0 +1,9 @@
+describe("#targetSelector", function() {
+ it("should default to something reasonable", function(){
+ expect(this.sopa.targetSelector()).toBe("header, h1")
+ })
+ it("should be configurable", function(){
+ this.sopa.targetSelector("p, h2")
+ expect(this.sopa.targetSelector()).toBe("p, h2")
+ })
+});
View
74 spec/javascripts/support/jasmine.yml
@@ -0,0 +1,74 @@
+# src_files
+#
+# Return an array of filepaths relative to src_dir to include before jasmine specs.
+# Default: []
+#
+# EXAMPLE:
+#
+# src_files:
+# - lib/source1.js
+# - lib/source2.js
+# - dist/**/*.js
+#
+src_files:
+ - public/javascripts/cloudflare.js
+ - public/javascripts/**/*.js
+
+# stylesheets
+#
+# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
+# Default: []
+#
+# EXAMPLE:
+#
+# stylesheets:
+# - css/style.css
+# - stylesheets/*.css
+#
+stylesheets:
+
+# helpers
+#
+# Return an array of filepaths relative to spec_dir to include before jasmine specs.
+# Default: ["helpers/**/*.js"]
+#
+# EXAMPLE:
+#
+# helpers:
+# - helpers/**/*.js
+#
+helpers:
+
+# spec_files
+#
+# Return an array of filepaths relative to spec_dir to include.
+# Default: ["**/*[sS]pec.js"]
+#
+# EXAMPLE:
+#
+# spec_files:
+# - **/*[sS]pec.js
+#
+spec_files:
+
+# src_dir
+#
+# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
+# Default: project root
+#
+# EXAMPLE:
+#
+# src_dir: public
+#
+src_dir:
+
+# spec_dir
+#
+# Spec directory path. Your spec_files must be returned relative to this path.
+# Default: spec/javascripts
+#
+# EXAMPLE:
+#
+# spec_dir: spec/javascripts
+#
+spec_dir:
View
23 spec/javascripts/support/jasmine_config.rb
@@ -0,0 +1,23 @@
+module Jasmine
+ class Config
+
+ # Add your overrides or custom config code here
+
+ end
+end
+
+
+# Note - this is necessary for rspec2, which has removed the backtrace
+module Jasmine
+ class SpecBuilder
+ def declare_spec(parent, spec)
+ me = self
+ example_name = spec["name"]
+ @spec_ids << spec["id"]
+ backtrace = @example_locations[parent.description + " " + example_name]
+ parent.it example_name, {} do
+ me.report_spec(spec["id"])
+ end
+ end
+ end
+end
View
32 spec/javascripts/support/jasmine_runner.rb
@@ -0,0 +1,32 @@
+$:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
+
+require 'rubygems'
+require 'jasmine'
+jasmine_config_overrides = File.expand_path(File.join(File.dirname(__FILE__), 'jasmine_config.rb'))
+require jasmine_config_overrides if File.exist?(jasmine_config_overrides)
+if Jasmine::Dependencies.rspec2?
+ require 'rspec'
+else
+ require 'spec'
+end
+
+jasmine_config = Jasmine::Config.new
+spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
+
+should_stop = false
+
+if Jasmine::Dependencies.rspec2?
+ RSpec.configuration.after(:suite) do
+ spec_builder.stop if should_stop
+ end
+else
+ Spec::Runner.configure do |config|
+ config.after(:suite) do
+ spec_builder.stop if should_stop
+ end
+ end
+end
+
+spec_builder.start
+should_stop = true
+spec_builder.declare_suites
Please sign in to comment.
Something went wrong with that request. Please try again.