<commit_before>module.exports = function(karma) {
  karma.configure({
    // base path, that will be used to resolve files and exclude
    basePath: '../..',

    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
        'lib/../build/belle/lib/jquery/jquery.min.js',
        'lib/angular/1.1.5/angular.js',
        'lib/angular/1.1.5/angular-cookies.min.js',
        'lib/angular/1.1.5/angular-mocks.js',
        'lib/angular/angular-ui-sortable.js',

        /*
        For angular 1.2:
         'lib/angular/1.2/angular.js',
         'lib/angular/1.2/angular-route.min.js',
         'lib/angular/1.2/angular-touch.min.js',
         'lib/angular/1.2/angular-cookies.min.js',
         'lib/angular/1.2/angular-animate.min.js',
         'lib/angular/1.2/angular-mocks.js',*/

         'lib/../build/belle/lib/underscore/underscore-min.js',
         'lib/../build/belle/lib/moment/moment-with-locales.js',
         'lib/umbraco/Extensions.js',
         'lib/../build/belle/lib/rgrove-lazyload/lazyload.js',
         'lib/../build/belle/lib/angular-local-storage/angular-local-storage.min.js',

         'test/config/app.unit.js',
         'src/common/mocks/umbraco.servervariables.js',

         'src/common/directives/*.js',
         'src/common/filters/*.js',
         'src/common/services/*.js',
         'src/common/security/*.js',
         'src/common/resources/*.js',
         'src/common/mocks/**/*.js',
         'src/views/**/*.controller.js',
         'test/unit/**/*.spec.js',
        {pattern: 'lib/**/*.js', watched: true, served: true, included: false}
    ],

    // list of files to exclude
    exclude: [],

    // use dolts reporter, as travis terminal does not support escaping sequences
    // possible values: 'dots', 'progress', 'junit', 'teamcity'
    // CLI --reporters progress
    reporters: ['progress'],

    // web server port
    // CLI --port 9876
    port: 9876,

    // cli runner port
    // CLI --runner-port 9100
    runnerPort: 9100,

    // enable / disable colors in the output (reporters and logs)
    // CLI --colors --no-colors
    colors: true,

    // level of logging
    // possible values: karma.LOG_DISABLE || karma.LOG_ERROR || karma.LOG_WARN || karma.LOG_INFO || karma.LOG_DEBUG
    // CLI --log-level debug
    logLevel: karma.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    // CLI --auto-watch --no-auto-watch
    autoWatch: false,

    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera
    // - Safari (only Mac)
    // - PhantomJS
    // - IE (only Windows)
    // CLI --browsers Chrome,Firefox,Safari
    browsers: ['PhantomJS'],

    // If browser does not capture in given timeout [ms], kill it
    // CLI --capture-timeout 5000
    captureTimeout: 5000,

    // Auto run tests on start (when browsers are captured) and exit
    // CLI --single-run --no-single-run
    singleRun: true,

    // report which specs are slower than 500ms
    // CLI --report-slower-than 500
    reportSlowerThan: 500,

    plugins: [
      'karma-jasmine',
      'karma-phantomjs-launcher'
    ]
  });
};<commit_msg>fixes karma testing config - now runs with "npm test" command instead<commit_after>module.exports = function(config) {

   config.set({

    // base path, that will be used to resolve files and exclude
    basePath: '../..',

    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [

        //libraries
        'lib-bower/jquery/jquery.min.js',
        'lib/angular/1.1.5/angular.js',
        'lib/angular/1.1.5/angular-cookies.min.js',
        'lib/angular/1.1.5/angular-mocks.js',
        'lib/angular/angular-ui-sortable.js',
        'lib-bower/underscore/underscore-min.js',
         'lib-bower/moment/moment-with-locales.js',
         'lib/umbraco/Extensions.js',
         'lib-bower/rgrove-lazyload/lazyload.js',
         'lib-bower//angular-local-storage/angular-local-storage.min.js',

         //app bootstrap and loader
         'test/config/app.unit.js',

         //application files
         'src/common/directives/*.js',
         'src/common/filters/*.js',
         'src/common/services/*.js',
         'src/common/security/*.js',
         'src/common/resources/*.js',
         'src/views/**/*.controller.js',

         //mocked data and routing
         'src/common/mocks/umbraco.servervariables.js',
         'src/common/mocks/**/*.js',

         //tests
         'test/unit/**/*.spec.js'
    ],

    // list of files to exclude
    exclude: [],

    // use dolts reporter, as travis terminal does not support escaping sequences
    // possible values: 'dots', 'progress', 'junit', 'teamcity'
    // CLI --reporters progress
    reporters: ['progress'],

    // web server port
    // CLI --port 9876
    port: 9876,

    // cli runner port
    // CLI --runner-port 9100
    runnerPort: 9100,

    // enable / disable colors in the output (reporters and logs)
    // CLI --colors --no-colors
    colors: true,

    // level of logging
    // possible values: karma.LOG_DISABLE || karma.LOG_ERROR || karma.LOG_WARN || karma.LOG_INFO || karma.LOG_DEBUG
    // CLI --log-level debug
    logLevel: config.LOG_WARN,

    // enable / disable watching file and executing tests whenever any file changes
    // CLI --auto-watch --no-auto-watch
    autoWatch: false,

    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera
    // - Safari (only Mac)
    // - PhantomJS
    // - IE (only Windows)
    // CLI --browsers Chrome,Firefox,Safari
    browsers: ['PhantomJS'],

    // If browser does not capture in given timeout [ms], kill it
    // CLI --capture-timeout 5000
    captureTimeout: 5000,

    // Auto run tests on start (when browsers are captured) and exit
    // CLI --single-run --no-single-run
    singleRun: true,

    // report which specs are slower than 500ms
    // CLI --report-slower-than 500
    reportSlowerThan: 500,

    plugins: [
      'karma-jasmine',
      'karma-phantomjs-launcher'
    ]
  });
};<|endoftext|>


<commit_before>/*
ngCss v0.5 (kk)
(c) 2014 Nick Campbell http://opensourcetaekwondo.com/ngcss
License: MIT
Thanks jscompress.com!
*/
(function(e,t){"use strict";function s(e){return e&&e===Object(e)}function o(e){return typeof e==="string"||e instanceof String}function u(e){return Object.prototype.toString.call(e)=="[object Function]"}function a(e,t,n){var r=XMLHttpRequest||ActiveXObject,i;try{i=new r("MSXML2.XMLHTTP.3.0")}catch(s){}if(u(n)){n={fn:n,arg:null}}if(i){i.onreadystatechange=function(){if(i.readyState===4){n.fn(i.status===200||i.status===0&&e.substr(0,7)==="file://",i.responseText,n.arg,i)}};i.open("GET",e,t);i.send()}else{n.fn(false,null,n.arg,null)}}function f(e,t,n){function r(){return"try{return(function(g,Object){return((1,eval)('Object')===g?function(c){return(1,eval)(c);}:(window.execScript?function(c){return window.execScript(c);}:null));})(Object,{});}catch(e){return null}"}function i(){var e,t=n.body||n.head||n.getElementsByTagName("head")[0],i=n.createElement("iframe");i.style.display="none";t.appendChild(i);e=i.contentWindow;e.document.write("<script>"+"window.$sandbox={"+"global: function(){"+r()+"}(),"+"local: function(s){return eval(s);}"+"};"+"parent=null;"+"</script>");e.document.close();return e}var s,o=i(),u=o.$sandbox.global||o.$sandbox.local;o.$scope=e;o.scope=e;delete o.$sandbox;for(s=0;s<t.length;s++){u(t[s])}return u}var n=e.module("ngCss",[]),r={},i={attrs:"",commented:true,async:true,prelink:false,script:false,live:false};n.filter("css",function(){function e(t,n){var r,i,o="";for(r in t){if(r!=="_selector"){i=t[r];r=r.replace(/([A-Z])/g,"-$1").toLowerCase();r=r.indexOf("-")===0?r.substr(1):r;if(s(i)){o+=e(i,n)}else{o+=r+":"+i+";"+n}}}return o}return function(t,n,r){var i=r?"\n":"";if(s(t)){return(n?(o(n)?n:t._selector)+" {":"")+i+e(t,i)+i+(n?"}":"")}else{return""}}});n.factory("ngCss",["$rootScope","$timeout",function(t,n){var s={};s.getScope=function(t,i){if(o(t)){t=document.getElementById(t)}n(function(){var n,s,o=e.element(t);if(o){if(r[o[0].id]){n=r[o[0].id].scope}if(!n){n=o.isolateScope();s=n?true:false;if(!s){n=o.scope()}}}i(n,s)})};s.defaults=function(t){i=e.extend(i,t);return e.extend({},i)};s.hookUpdateCss=function(e){t.$on("updateCss",function(){e()})};s.updateCss=function(){t.$broadcast("updateCss")};s.newId=function(e){var t=Math.floor(Math.random()*1e3);e=e||"ngCss";while(document.getElementById(e+t)){t=Math.floor(Math.random()*1e3)}return e+t};return s}]);n.directive("ngCss",["$interpolate","$timeout","ngCss",function(n,l,c){var h=n.startSymbol(),p=n.endSymbol(),d=new RegExp("/\\*"+h,"g"),v=new RegExp(p+"\\*/","g");return{restrict:"A",scope:{options:"=ngCss"},template:function(e,t){var n,i=!e.attr("ng-css"),s=e[0],o=e.prop("tagName").toLowerCase();s.id=s.id||c.newId();switch(o){case"style":{r[s.id]={css:e.html()||""};e.html("");break};case"link":{r[s.id]={};break};default:{o=t.style||"";if(o.indexOf(h)>-1){n=t.ngCss||"{}";if(n.indexOf("{")!==0){n="{ prelink: '"+n+"' }"}r[s.id]={style:t.style.replace(d,h).replace(v,p),option:t.ngCss,options:n};e.removeAttr("style")}e.removeAttr((i?"data-":"")+"ng-css")}}(r[s.id]||{}).dataPrefix=i},link:function(m,g,y){function N(){var t=function(e){if(e){m=e;r[w.id].scope=m;l(k)}else{k()}};if(T.prelink){if(u(T.prelink)){T.prelink(t,m,g,r[w.id].$link)}else{c.getScope(T.prelink,function(n){if(!n&&s(T.prelink)){e.extend(m,T.prelink);k()}else{t(n)}})}}else{k()}}function C(){var e=r[w.id];if(e.css){g.html(m.$eval(n(e.css)))}else{g.attr("style",m.$eval(n(e.style)))}}function k(){var e,n,i,s=r[w.id].css||"",o=(T.script+"").toLowerCase()==="local",u=function(e,t,n){i[n]=e?t:""};if(s){r[w.id].css=s.replace(S,"").replace(d,h).replace(v,p)}if(T.script&&(o||!r[w.id].evaler)){i=s.match(S);if(i&&i.length>0){for(e=0;e<i.length;e++){n=x.exec(i[e]||"");if(n&&n[1]){a(n[1],false,{fn:u,arg:e})}else{i[e]=i[e].replace(E,"")}}if(o){t(m,i)}else{r[w.id].evaler=f(m,i,document)}}}C();if(T.live){m.$watch(C)}else{c.hookUpdateCss(C)}}var b,w=g[0],E=/<[\/]?script.*?>/gi,S=/<script.*?>([\s\S]*?)<\/script>/gi,x=/<script.*?src=['"](.*?)['"].*?>/i,T=e.extend({},i,m.options);switch(g.prop("tagName").toLowerCase()){case"link":{a(w.href,T.async,function(t,n){var i;if(t){r[w.id].css=n;r[w.id].options=T;r[w.id].$link=g;i=e.element("<style type='text/css' id='"+(w.id||c.newId())+"'>"+n+"</style>");i.attr((r[w.id].dataPrefix?"data-":"")+"ng-css",g.attr("ngCss"));g.after(i);g=i;w.parentNode.removeChild(w);w=i[0];N()}else{throw"ngCss E1: Unable to load file: "+y.href+"\nServer Response: "+n}});break};case"style":{r[w.id].options=T;N();break};default:{if(r[w.id]){T=m.$eval(r[w.id].options);if(T.prelink){b=T.prelink.id||T.prelink;if(o(b)&&r[b]){T=e.extend({},r[b].options,T)}g.attr((r[w.id].dataPrefix?"data-":"")+"ng-css",r[w.id].option);N()}else{throw"ngCss E2: `prelink` is required for non-LINK/STYLE tags."}}}}}}}])})(angular,function($scope){var scope=$scope;while(arguments[1].length>0){eval(arguments[1].shift())}})
<commit_msg>v0.9 (kk)<commit_after>/*
ngCss v0.9 (kk)
(c) 2014-2015 Nick Campbell http://opensourcetaekwondo.com/ngcss
License: MIT
Thanks jscompress.com!
*/
!function(e,t,r,n,s,o,a,i){"use strict";var c={},u=Object.prototype.toString,l=/<script.*?>([\s\S]*?)<\/script>/gi,f={version:"v0.9",cache:c,config:{attr:"",scopeAlias:"scope"},scope:{resolve:function(e,t,r){var n=f.config.scopeAlias,s=f.scope.$({s:f.resolve(r(e.options.a),n)||t[n],go:!0},e);if(s.c)switch(s.s.toLowerCase()){case"local":case"usestrict":break;default:f.warn("Context cannot be used with `"+s.s+"`",e.dom)}return s},hook:function(e){return e},$:function(e,t){return f.is.fn(e.s)&&(e.s=f.callOptionFn(e.s,t)),f.is.obj(e.s)&&(e.s=f.is.jq(e.s)?e.s[0]:e.s,f.is.dom(e.s)?(e.s.id=e.s.id||f.newId(),e.s="#"+e.s.id):f.config.scopeAlias in e.s&&"context"in e.s?(e.c=e.s.context,e.s=e.s.scope):(e.c=e.s,e.s="local")),e=f.scope.hook(e),(f.is.obj(e.s)||f.is.fn(e.s))&&(e=f.scope.$(e,t)),e}},callOptionFn:function(e,t){return e(t.dom,t)},compile:function(e,r,n,s){function o(t){try{return n(t)}catch(r){return f.warn("Error evaluating `"+t+"` for",e,r),{}}}function a(e,t){e.hasAttribute=e.hasAttribute||f.hasAttribute;var r,n=f.config.attr,s=e.hasAttribute(n)?n:"data-"+n,o=e.getAttribute(s)||"",a={attr:s,a:o?0===o.indexOf("{")?o:"{"+f.config.scopeAlias+":'$'}".replace("$",o):"{}"};return t&&(r=t.match(b),r&&r[1]&&(a.c=r[1])),a}function i(e,t,n,s){var o="*"===n,i=s||e;c[i.id]={link:s||null,dom:e,tag:n,options:a(i,o?"":t),scripts:o?null:f.getScripts(t,i),css:(t||"").replace(l,"").replace(v,r.d1).replace(m,r.d2)}}function u(a,i){function u(e,t,r,n){var s=a.scripts||[],o=0;v=!0,s.length>0&&(r=(r||"").substr(0,1),o="l"===r||"u"===r?-1:r.length),a.evaler={parent:e,scope:t,context:g.c,$eval:n,run:o}}var l,g=f.scope.resolve(a,r,o),p=g.s,v=!1,m=!1;g.go&&(f.is.str(p)?a.evaler&&a.evaler.scope===p&&a.evaler.context===g.c?v=!0:"#"!==p.substr(0,1)?f.is.fn(f.evalFactory[p])?"sandbox"===p?u(null,p,p,f.evalFactory[p](f.iframeFactory("allow-scripts","")).global()):u(null,p,p,f.evalFactory[p](g.c)):i&&f.warn("Invalid evaler `"+p+"` for",a.dom):(l=c[p.substr(1)],l?u(l,p,l.evaler.scope,l.evaler.$eval):(l=t.getElementById(p.substr(1)),l?(m=!0,f.compile(l,r,n,function(e,t){f.is.obj(e)&&u(e,p,e.evaler.scope,e.evaler.$eval),s(a,d.concat(t))})):f.warn("Unknown parent `"+p+"` for",e))):i&&f.warn("Invalid scope `"+p+"` for",e,p)),v||u(),m||s(a,d)}var g,p=!1,d=[e],v=new RegExp("/\\*"+r.d1,"g"),m=new RegExp(r.d2+"\\*/","g"),b=new RegExp("^\\s*\\/\\*"+f.config.attr+"\\((\\{.*?\\})\\)\\*\\/","i");if(g=e.id=e.id||f.newId(),c[g])u(c[g],!0);else{switch(e.tagName.toLowerCase()){case"style":i(e,e.innerHTML,"s"),e.innerHTML="";break;case"link":p=!0,f.get(e.href,f.resolve(o(a(e).a),"async")||r.async,function(r,n){if(r){var o=t.createElement("style");i(o,n,"l",e),o.type="text/css",o.setAttribute(c[g].options.attr,c[g].options.a),e.parentNode.replaceChild(o,e),e=o,o.id=g,u(c[g])}else f.warn("Error retrieving `"+e.href+"` for",e,n),s(void 0,d)});break;default:i(e,e.getAttribute("style"),"*"),e.removeAttribute("style")}p||u(c[g])}},get:function(e,t,r){var n,s=XMLHttpRequest||ActiveXObject;try{n=new s("MSXML2.XMLHTTP.3.0")}catch(o){}f.is.fn(r)&&(r={fn:r,arg:null}),n?(n.onreadystatechange=function(){4===n.readyState&&r.fn(200===n.status||0===n.status&&"file://"===e.substr(0,7),n.responseText,r.arg,n)},n.open("GET",e,t),n.send()):r.fn(!1,null,r.arg,n)},getScripts:function(e,t){var r,n,s=(e||"").match(l)||[],o=/<[\/]?script.*?>/gi,a=/<script.*?src=['"](.*?)['"].*?>/i,i=function(e,r,n){s[n.i]=e?r:"",e||f.warn("Error retrieving `"+n.src+"` for",t,r)};for(n=0;n<s.length;n++)r=a.exec(s[n]),r&&r[1]?f.get(r[1],!1,{fn:i,arg:{i:n,src:r[1]}}):s[n]=s[n].replace(o,"");return s},hasAttribute:function(e){return"undefined"!=typeof this[e]},is:{str:function(e){return("string"==typeof e||e instanceof String)&&""!==e},fn:function(e){return"[object Function]"===u.call(e)},obj:function(e){return e&&e===Object(e)&&!f.is.fn(e)},arr:function(e){return"[object Array]"===u.call(e)},dom:function(e){return e&&f.is.str(e.tagName)&&f.is.fn(e.getAttribute)},jq:function(e){return e&&f.is.fn(e.replaceWith)&&f.is.dom(e[0])}},mixin:function(e,t,r){function n(e,t){var r,s,o="";for(r in e)e.hasOwnProperty(r)&&"_selector"!==r&&(s=e[r],r=r.replace(/([A-Z])/g,"-$1").toLowerCase(),r=0===r.indexOf("-")?r.substr(1):r,o+=f.is.obj(s)?n(s,t):r+":"+s+";"+t);return o}var s="",o=r?"\n":"";return f.is.obj(e)?s=(t?(f.is.str(t)?t:e._selector)+" {":"")+o+n(e,o)+o+(t?"}":""):f.is.str(e),s},newId:function(e){var r;e=e||f.config.attr+"_";do r=e+Math.random().toString(36).substr(2,5);while(t.getElementById(r));return r},resolve:function(e,t){var r,n;if(e=f.is.obj(e)?e:void 0,e&&f.is.str(t))for(r=t.split("."),n=0;n<r.length;n++){if(!(f.is.obj(e)&&r[n]in e)){e=void 0;break}e=e[r[n]]}return e},warn:function(e,t,r){var n=console||function(){};(n.warn||n.log||n)(f.config.attr+": "+e,t,r)}};f.evalFactory=s(e,t,f,o,a,i),n(t,r,f)}(window,document,angular,function(e,t,r){"use strict";function n(e){var t=e.replace(/([A-Z])/g,"-$1").toLowerCase();return 0===t.indexOf("-")?t.substr(1):t}var s="ngCss",o=r.cache,a=t.module(s,[]),i={script:"isolated",scope:"",async:!0,live:!1};r.config.attr=n(s),r.config.scopeAlias="script",a.filter("css",function(){return r.mixin}),a.factory(s,["$rootScope",function(n){function a(e){return r.is.obj(e)&&e.$root===n}function c(e){return e=t.extend({isolate:!1,parent:n,merge:null},e),t.extend(n.$new(e.isolate===!0,e.parent),e.merge)}function u(s,a){var i,c,u;try{r.is.str(s)&&"#"===s.substr(0,1)&&(s=e.getElementById(s.substr(1))),u=t.element(s),u&&u[0]&&(o[u[0].id]&&(i=o[u[0].id].foreignScope),i||(i=u.isolateScope(),c=i?!0:!1,c||(i=u.scope())))}catch(l){r.warn("Error collecting $scope for",s,l)}return i||a!==!0?i:n.$new(!0)}return{version:r.version,defaults:function(e){return i=t.extend(i,e),t.extend({},i)},newId:function(e){return r.newId(e||s)},scope:{$new:c,get:u,is:a,as:function(e,t){return a(e)?e:c({isolate:t===!0,merge:e})},outer:function(e){var t=u(e.parent());return t!==n?t:void 0}},updateCss:function(){n.$broadcast("updateCss")},updateCssListener:function(e){n.$on("updateCss",function(){e()})}}}]),a.directive(s,["$interpolate","$timeout",s,function(e,n,a){function c(e,n,o){function a(e){e&&(e.a&&!e.$a&&(e.$a=n.$eval(e.a)),e.c&&!e.$c&&(e.$c=n.$eval(e.c)))}r.compile(e.dom,i,function(e){return n.$eval(e)},function(n){var c,u=t.element(e.dom);"*"===n.tag&&u.attr(n.options.attr,n[s]),c=r.resolve(n,"evaler.parent.options")||{},a(c),a(n.options),o(t.extend({},i,c.$c,c.$a,n.options.$c,n.options.$a))})}var u=a.scope.$new({isolate:!0});return i.d1=e.startSymbol(),i.d2=e.endSymbol(),{restrict:"A",template:function(e,t){"{"!==t[s].substr(0,1)&&(delete t[s],delete t.$attr[s]),r.compile(e[0],i,function(e){return u.$eval(e)},function(t){"*"===t.tag&&(t[s]=e.attr(t.options.attr),e.removeAttr(t.options.attr))})},link:function(t,s){function i(){try{var n=t.$eval(e(g.css));"*"===g.tag?s.attr("style",n):s.html(n)}catch(o){r.warn("Error updating CSS for",g.dom,o)}}var u,l,f,g=o[s[0].id],p=a.scope.outer(s)||t;r.scope.hook=function(e){return e.go=e.s!==!1,e},n(function(){c(g,p,function(e){var n=r.is.fn(e.scope)?r.callOptionFn(e.scope,g):e.scope;f=g.scripts||[],u=r.resolve(g,"evaler.parent"),r.is.str(n)&&("#"===n.substr(0,1)?(t=a.scope.get(n),g.foreignScope=t):"isolated"===n&&(t=a.scope.$new({isolate:!0}),g.foreignScope=t)),a.scope.is(t)?(e.script!==!1&&0!==g.evaler.run&&(u&&r.is.arr(u.scripts)&&0!==u.evaler.run&&(f=u.scripts.concat(f),u.evaler.run--),l=g.evaler.$eval(f,{$scope:t,scope:t},!0),g.evaler.run--,l.errors.length>0&&r.warn("Error evaluating Javascript for",g.dom,l.errors)),i(),e.live?t.$watch(i):a.updateCssListener(i)):r.warn("Error collecting $scope for",s,e.scope)})})}}}])},function(e,t,r,n,s,o){"use strict";function a(e){var t="try{return(function(g,Object){return((1,eval)('Object')===g?function(){return(1,eval)(arguments[0]);}:(window.execScript?function(){return window.execScript(arguments[0]);}:undefined));})(Object,{});}catch(e){return undefined;}";return e?t:void(null===f&&(f=new Function(t)()))}function i(e,t,o,a){return function(i,c,u){var l,f=r.is.arr(i),g=r.is.obj(c),p={js:f?i:[i],results:[],errors:[]};switch(e){case n:case s:Object.keys||(Object.keys=function(e){if(e!==Object(e))throw new TypeError("Object.keys called on a non-object");var t,r=[];for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.push(t);return r}),a?e.call(o,p,0,g?{o:c,k:Object.keys(c),c:""}:null):e(p,0,g?{o:c,k:Object.keys(c),c:""}:null);break;default:if(t&&g)for(l in c)void 0===t[l]&&c.hasOwnProperty(l)&&(t[l]=c[l]);for(l=0;l<p.js.length;l++)try{p.results.push(a?e.call(o,p.js[l]):e(p.js[l]))}catch(d){p.results.push(void 0),p.errors.push({index:l,error:d,js:p.js[l]})}}return u?p:f?p.results:p.results[0]}}function c(e,n,s){var o=r.newId("sandbox");return e=null===e?"":' sandbox="'+(e?e:"allow-scripts")+'"',(s||t.body||t.head||t.getElementsByTagName("head")[0]).insertAdjacentHTML("afterbegin",'<iframe src="'+n+'" id="'+o+'" style="display:none;"'+e+"></iframe>"),t.getElementById(o)}function u(t,o,g){var p,d,v="eval",m=void 0!==o&&null!==o;switch(o=m?o:e,t){case"g":o===e?(a(),p=!f&&g.f?n:f,p&&(d=i(p,e))):r.is.fn(o[v])&&(p=o[v]("(function(){"+a(!0)+"})()"),p=!p&&g.f?function(){return o[v](arguments[0])}:p,p&&(d=g.r?p:i(p,o)));break;case"l":d=i(n,e,o,m);break;case"u":d=i(s,e,o,m);break;case"i":g=r.is.obj(g)?g:{},g.iframe=c(null,""),g.window=g.iframe.contentWindow,p=u("g",g.window,{f:1,r:1}),d=i(p,g.window);break;case"j":d=i(l)}return d}var l,f=null;return e.JSON&&e.JSON.parse?l=e.JSON.parse:e.jQuery&&e.jQuery.parseJSON&&(l=e.jQuery.parseJSON),r.iframeFactory=c,{$version:r.version,global:function(t,r){return u("g",r||e,{f:t})},local:n?function(e){return u("l",e)}:void 0,useStrict:s?function(e){return u("u",e)}:void 0,isolated:function(e){return u("i",null,e)},json:l?function(){return u("j")}:void 0,sandbox:o?o(e,r,{looper:i,iframe:c}):void 0}},function(){if(arguments[2])for(;arguments[2].k.length>0;)arguments[2].c=arguments[2].k.shift(),eval("var "+arguments[2].c+"=arguments[2].o[arguments[2].c];");for(;arguments[1]<arguments[0].js.length;){try{eval(arguments[0].js[arguments[1]])}catch(e){arguments[0].results.push(void 0),arguments[0].errors.push({index:arguments[1],error:e,js:arguments[0].js[arguments[1]]})}arguments[1]++}},function(){if(arguments[2])for(;arguments[2].k.length>0;)arguments[2].c=arguments[2].k.shift(),eval("var "+arguments[2].c+"=arguments[2].o[arguments[2].c];");!function(){"use strict";for(;arguments[1]<arguments[0].js.length;){try{eval(arguments[0].js[arguments[1]])}catch(e){arguments[0].results.push(void 0),arguments[0].errors.push({index:arguments[1],error:e,js:arguments[0].js[arguments[1]]})}arguments[1]++}}(arguments[0],0,arguments[2])},function(e,t,r){"use strict";function n(r,n){var s=arguments[3];if(!i){i=!0,e.addEventListener=e.addEventListener||function(t,r){e.attachEvent("on"+t,r)},e.addEventListener("message",function(r){var n;a=t.is.str(r.data),n=a?e.JSON.parse(r.data):r.data,"null"===r.origin&&o[n.id]&&(o[n.id](r.source,{results:n.r,errors:n.e,js:n.js},n.arg),delete o[n.id])},!1);try{e.postMessage({},"*")}catch(u){a=!0}}return function(i,u,l){var f=t.is.arr(i);return{then:function(t,g){var p={js:f?i:[i],id:c++,arg:g,type:r,context:n,inject:u};o[c]=function(e,r,n){e===s&&t(l?r:f?r.results:r.results[0],n)},s.postMessage(a?e.JSON.stringify(p):p,"*")}}}}function s(t){var s=t.contentWindow,o=e.postMessage&&-1===(t.getAttribute("sandbox")+"").indexOf("allow-same-origin"),a=o?n:r.looper;return{iframe:t,window:s,secure:o,global:function(e){var t=e?"isolated":"global";return a(o?t:s.$sandbox[t],s)},local:function(e){var t=1===arguments.length,r=t?"context":"local";return a(o?r:s.$sandbox[r],e||s,t,s)}}}var o=[],a=!1,i=!1,c=0;return function(e,t,n){switch(arguments.length){case 0:s(r.iframe("allow-scripts",""));break;case 1:s(e);break;case 2:case 3:s(r.iframe(e,t,n))}}});
<|endoftext|>


<commit_before>define([
    'require',
    '../lib/jquery'
], function(require) {
    var autosubmit = {
        initContent: function(root) {
            $(root).find('.auto-submit').each(function() {
                var $this = $(this),
                    $data = $this.data('auto-submit');
                if (!$data) {
                    $this.on("change", function(event) {
                        $this.submit();
                    });
                    $this.data('auto-submit', true);
                }
            });
        }
    };
    return autosubmit;
});
<commit_msg>filter events, submit 400ms after last keyup and for type=search on click<commit_after>define([
    'require',
    '../lib/jquery',
    '../lib/dist/underscore'
], function(require) {
    var autosubmit = {
        initContent: function(root) {
            $(root).find('.auto-submit').each(function() {
                var $this = $(this),
                    $data = $this.data('auto-submit');
                if (!$data) {
                    var submit = _.debounce(function(event) {
                        $this.submit();
                    }, 400);
                    $this.on("change", submit);
                    $this.find('input').on("keyup", submit);

                    // XXX: test whether on webkit and enable only if supported
                    // XXX: add code to check whether the click actually changed
                    // something
                    $this.find('input[type=search]').on("click", submit);

                    $this.data('auto-submit', true);
                }
            });
        }
    };
    return autosubmit;
});
<|endoftext|>


<commit_before>/*
	jQuery Coda-Slider v2.0 - http://www.ndoherty.biz/coda-slider
	Copyright (c) 2009 Niall Doherty
	This plugin available for use in all personal or commercial projects under both MIT and GPL licenses.
*/

$(function(){
	// Remove the coda-slider-no-js class from the body
	$("body").removeClass("coda-slider-no-js");
	// Preloader
	$(".coda-slider").children('.panel').hide().end().prepend('
Loading...

');
});

var sliderCount = 1;

$.fn.codaSlider = function(settings) {

	settings = $.extend({
		autoHeight: true,
		autoHeightEaseDuration: 1000,
		autoHeightEaseFunction: "easeInOutExpo",
		autoSlide: false,
		autoSlideInterval: 7000,
		autoSlideStopWhenClicked: true,
		crossLinking: true,
		dynamicArrows: true,
		dynamicArrowLeftText: "« left",
		dynamicArrowRightText: "right »",
		dynamicTabs: true,
		dynamicTabsAlign: "center",
		dynamicTabsPosition: "top",
		externalTriggerSelector: "a.xtrig",
		firstPanelToLoad: 1,
		panelTitleSelector: "h2.title",
		slideEaseDuration: 1000,
		slideEaseFunction: "easeInOutExpo"
	}, settings);

	return this.each(function(){

		// Uncomment the line below to test your preloader
		// alert("Testing preloader");

		var slider = $(this);

		// If we need arrows
		if (settings.dynamicArrows) {
			slider.parent().addClass("arrows");
			slider.before('
' + settings.dynamicArrowLeftText + '
');
			slider.after('
' + settings.dynamicArrowRightText + '
');
		};

		var panelWidth = slider.find(".panel").width();
		var panelCount = slider.find(".panel").size();
		var panelContainerWidth = panelWidth*panelCount;
		var navClicks = 0; // Used if autoSlideStopWhenClicked = true

		// Surround the collection of panel divs with a container div (wide enough for all panels to be lined up end-to-end)
		$('.panel', slider).wrapAll('

');
		// Specify the width of the container div (wide enough for all panels to be lined up end-to-end)
		$(".panel-container", slider).css({ width: panelContainerWidth });

		// Specify the current panel.
		// If the loaded URL has a hash (cross-linking), we're going to use that hash to give the slider a specific starting position...
		if (settings.crossLinking && location.hash && parseInt(location.hash.slice(1)) <= panelCount) {
			var currentPanel = parseInt(location.hash.slice(1));
			var offset = - (panelWidth*(currentPanel - 1));
			$('.panel-container', slider).css({ marginLeft: offset });
		// If that's not the case, check to see if we're supposed to load a panel other than Panel 1 initially...
		} else if (settings.firstPanelToLoad != 1 && settings.firstPanelToLoad <= panelCount) {
			var currentPanel = settings.firstPanelToLoad;
			var offset = - (panelWidth*(currentPanel - 1));
			$('.panel-container', slider).css({ marginLeft: offset });
		// Otherwise, we'll just set the current panel to 1...
		} else {
			var currentPanel = 1;
		};

		// Left arrow click
		$("#coda-nav-left-" + sliderCount + " a").click(function(){
			navClicks++;
			if (currentPanel == 1) {
				offset = - (panelWidth*(panelCount - 1));
				alterPanelHeight(panelCount - 1);
				currentPanel = panelCount;
				slider.siblings('.coda-nav').find('a.current').removeClass('current').parents('ul').find('li:last a').addClass('current');
			} else {
				currentPanel -= 1;
				alterPanelHeight(currentPanel - 1);
				offset = - (panelWidth*(currentPanel - 1));
				slider.siblings('.coda-nav').find('a.current').removeClass('current').parent().prev().find('a').addClass('current');
			};
			$('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
			if (settings.crossLinking) { location.hash = currentPanel }; // Change the URL hash (cross-linking)
			return false;
		});

		// Right arrow click
		$('#coda-nav-right-' + sliderCount + ' a').click(function(){
			navClicks++;
			if (currentPanel == panelCount) {
				offset = 0;
				currentPanel = 1;
				alterPanelHeight(0);
				slider.siblings('.coda-nav').find('a.current').removeClass('current').parents('ul').find('a:eq(0)').addClass('current');
			} else {
				offset = - (panelWidth*currentPanel);
				alterPanelHeight(currentPanel);
				currentPanel += 1;
				slider.siblings('.coda-nav').find('a.current').removeClass('current').parent().next().find('a').addClass('current');
			};
			$('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
			if (settings.crossLinking) { location.hash = currentPanel }; // Change the URL hash (cross-linking)
			return false;
		});

		// If we need a dynamic menu
		if (settings.dynamicTabs) {
			var dynamicTabs = '

';
			switch (settings.dynamicTabsPosition) {
				case "bottom":
					slider.parent().append(dynamicTabs);
					break;
				default:
					slider.parent().prepend(dynamicTabs);
					break;
			};
			ul = $('#coda-nav-' + sliderCount + ' ul');
			// Create the nav items
			$('.panel', slider).each(function(n) {
				ul.append('
' + $(this).find(settings.panelTitleSelector).text() + '
');
			});
			navContainerWidth = slider.width() + slider.siblings('.coda-nav-left').width() + slider.siblings('.coda-nav-right').width();
			ul.parent().css({ width: navContainerWidth });
			switch (settings.dynamicTabsAlign) {
				case "center":
					ul.css({ width: ($("li", ul).width() + 2) * panelCount });
					break;
				case "right":
					ul.css({ float: 'right' });
					break;
			};
		};

		// If we need a tabbed nav
		$('#coda-nav-' + sliderCount + ' a').each(function(z) {
			// What happens when a nav link is clicked
			$(this).bind("click", function() {
				navClicks++;
				$(this).addClass('current').parents('ul').find('a').not($(this)).removeClass('current');
				offset = - (panelWidth*z);
				alterPanelHeight(z);
				currentPanel = z + 1;
				$('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
				if (!settings.crossLinking) { return false }; // Don't change the URL hash unless cross-linking is specified
			});
		});

		// External triggers (anywhere on the page)
		$(settings.externalTriggerSelector).each(function() {
			// Make sure this only affects the targeted slider
			if (sliderCount == parseInt($(this).attr("rel").slice(12))) {
				$(this).bind("click", function() {
					navClicks++;
					targetPanel = parseInt($(this).attr("href").slice(1));
					offset = - (panelWidth*(targetPanel - 1));
					alterPanelHeight(targetPanel - 1);
					currentPanel = targetPanel;
					// Switch the current tab:
					slider.siblings('.coda-nav').find('a').removeClass('current').parents('ul').find('li:eq(' + (targetPanel - 1) + ') a').addClass('current');
					// Slide
					$('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
					if (!settings.crossLinking) { return false }; // Don't change the URL hash unless cross-linking is specified
				});
			};
		});

		// Specify which tab is initially set to "current". Depends on if the loaded URL had a hash or not (cross-linking).
		if (settings.crossLinking && location.hash && parseInt(location.hash.slice(1)) <= panelCount) {
			$("#coda-nav-" + sliderCount + " a:eq(" + (location.hash.slice(1) - 1) + ")").addClass("current");
		// If there's no cross-linking, check to see if we're supposed to load a panel other than Panel 1 initially...
		} else if (settings.firstPanelToLoad != 1 && settings.firstPanelToLoad <= panelCount) {
			$("#coda-nav-" + sliderCount + " a:eq(" + (settings.firstPanelToLoad - 1) + ")").addClass("current");
		// Otherwise we must be loading Panel 1, so make the first tab the current one.
		} else {
			$("#coda-nav-" + sliderCount + " a:eq(0)").addClass("current");
		};

		// Set the height of the first panel
		if (settings.autoHeight) {
			panelHeight = $('.panel:eq(' + (currentPanel - 1) + ')', slider).height();
			slider.css({ height: panelHeight });
		};

		// Trigger autoSlide
		if (settings.autoSlide) {
			slider.ready(function() {
				setTimeout(autoSlide,settings.autoSlideInterval);
			});
		};

		function alterPanelHeight(x) {
			if (settings.autoHeight) {
				panelHeight = $('.panel:eq(' + x + ')', slider).height()
				slider.animate({ height: panelHeight }, settings.autoHeightEaseDuration, settings.autoHeightEaseFunction);
			};
		};

		function autoSlide() {
			if (navClicks == 0 || !settings.autoSlideStopWhenClicked) {
				if (currentPanel == panelCount) {
					var offset = 0;
					currentPanel = 1;
				} else {
					var offset = - (panelWidth*currentPanel);
					currentPanel += 1;
				};
				alterPanelHeight(currentPanel - 1);
				// Switch the current tab:
				slider.siblings('.coda-nav').find('a').removeClass('current').parents('ul').find('li:eq(' + (currentPanel - 1) + ') a').addClass('current');
				// Slide:
				$('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
				setTimeout(autoSlide,settings.autoSlideInterval);
			};
		};

		// Kill the preloader
		$('.panel', slider).show().end().find("p.loading").remove();
		slider.removeClass("preload");

		sliderCount++;

	});
};<commit_msg>Added stop() before all animation() to prevent unnecessary queuing.<commit_after>/*
	jQuery Coda-Slider v2.0 - http://www.ndoherty.biz/coda-slider
	Copyright (c) 2009 Niall Doherty
	This plugin available for use in all personal or commercial projects under both MIT and GPL licenses.
*/

$(function(){
	// Remove the coda-slider-no-js class from the body
	$("body").removeClass("coda-slider-no-js");
	// Preloader
	$(".coda-slider").children('.panel').hide().end().prepend('
Loading...

');
});

var sliderCount = 1;

$.fn.codaSlider = function(settings) {

	settings = $.extend({
		autoHeight: true,
		autoHeightEaseDuration: 1000,
		autoHeightEaseFunction: "easeInOutExpo",
		autoSlide: false,
		autoSlideInterval: 7000,
		autoSlideStopWhenClicked: true,
		crossLinking: true,
		dynamicArrows: true,
		dynamicArrowLeftText: "« left",
		dynamicArrowRightText: "right »",
		dynamicTabs: true,
		dynamicTabsAlign: "center",
		dynamicTabsPosition: "top",
		externalTriggerSelector: "a.xtrig",
		firstPanelToLoad: 1,
		panelTitleSelector: "h2.title",
		slideEaseDuration: 1000,
		slideEaseFunction: "easeInOutExpo"
	}, settings);

	return this.each(function(){

		// Uncomment the line below to test your preloader
		// alert("Testing preloader");

		var slider = $(this);

		// If we need arrows
		if (settings.dynamicArrows) {
			slider.parent().addClass("arrows");
			slider.before('
' + settings.dynamicArrowLeftText + '
');
			slider.after('
' + settings.dynamicArrowRightText + '
');
		};

		var panelWidth = slider.find(".panel").width();
		var panelCount = slider.find(".panel").size();
		var panelContainerWidth = panelWidth*panelCount;
		var navClicks = 0; // Used if autoSlideStopWhenClicked = true

		// Surround the collection of panel divs with a container div (wide enough for all panels to be lined up end-to-end)
		$('.panel', slider).wrapAll('

');
		// Specify the width of the container div (wide enough for all panels to be lined up end-to-end)
		$(".panel-container", slider).css({ width: panelContainerWidth });

		// Specify the current panel.
		// If the loaded URL has a hash (cross-linking), we're going to use that hash to give the slider a specific starting position...
		if (settings.crossLinking && location.hash && parseInt(location.hash.slice(1)) <= panelCount) {
			var currentPanel = parseInt(location.hash.slice(1));
			var offset = - (panelWidth*(currentPanel - 1));
			$('.panel-container', slider).css({ marginLeft: offset });
		// If that's not the case, check to see if we're supposed to load a panel other than Panel 1 initially...
		} else if (settings.firstPanelToLoad != 1 && settings.firstPanelToLoad <= panelCount) {
			var currentPanel = settings.firstPanelToLoad;
			var offset = - (panelWidth*(currentPanel - 1));
			$('.panel-container', slider).css({ marginLeft: offset });
		// Otherwise, we'll just set the current panel to 1...
		} else {
			var currentPanel = 1;
		};

		// Left arrow click
		$("#coda-nav-left-" + sliderCount + " a").click(function(){
			navClicks++;
			if (currentPanel == 1) {
				offset = - (panelWidth*(panelCount - 1));
				alterPanelHeight(panelCount - 1);
				currentPanel = panelCount;
				slider.siblings('.coda-nav').find('a.current').removeClass('current').parents('ul').find('li:last a').addClass('current');
			} else {
				currentPanel -= 1;
				alterPanelHeight(currentPanel - 1);
				offset = - (panelWidth*(currentPanel - 1));
				slider.siblings('.coda-nav').find('a.current').removeClass('current').parent().prev().find('a').addClass('current');
			};
			$('.panel-container', slider).stop().animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
			if (settings.crossLinking) { location.hash = currentPanel }; // Change the URL hash (cross-linking)
			return false;
		});

		// Right arrow click
		$('#coda-nav-right-' + sliderCount + ' a').click(function(){
			navClicks++;
			if (currentPanel == panelCount) {
				offset = 0;
				currentPanel = 1;
				alterPanelHeight(0);
				slider.siblings('.coda-nav').find('a.current').removeClass('current').parents('ul').find('a:eq(0)').addClass('current');
			} else {
				offset = - (panelWidth*currentPanel);
				alterPanelHeight(currentPanel);
				currentPanel += 1;
				slider.siblings('.coda-nav').find('a.current').removeClass('current').parent().next().find('a').addClass('current');
			};
			$('.panel-container', slider).stop().animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
			if (settings.crossLinking) { location.hash = currentPanel }; // Change the URL hash (cross-linking)
			return false;
		});

		// If we need a dynamic menu
		if (settings.dynamicTabs) {
			var dynamicTabs = '

';
			switch (settings.dynamicTabsPosition) {
				case "bottom":
					slider.parent().append(dynamicTabs);
					break;
				default:
					slider.parent().prepend(dynamicTabs);
					break;
			};
			ul = $('#coda-nav-' + sliderCount + ' ul');
			// Create the nav items
			$('.panel', slider).each(function(n) {
				ul.append('
' + $(this).find(settings.panelTitleSelector).text() + '
');
			});
			navContainerWidth = slider.width() + slider.siblings('.coda-nav-left').width() + slider.siblings('.coda-nav-right').width();
			ul.parent().css({ width: navContainerWidth });
			switch (settings.dynamicTabsAlign) {
				case "center":
					ul.css({ width: ($("li", ul).width() + 2) * panelCount });
					break;
				case "right":
					ul.css({ float: 'right' });
					break;
			};
		};

		// If we need a tabbed nav
		$('#coda-nav-' + sliderCount + ' a').each(function(z) {
			// What happens when a nav link is clicked
			$(this).bind("click", function() {
				navClicks++;
				$(this).addClass('current').parents('ul').find('a').not($(this)).removeClass('current');
				offset = - (panelWidth*z);
				alterPanelHeight(z);
				currentPanel = z + 1;
				$('.panel-container', slider).stop().animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
				if (!settings.crossLinking) { return false }; // Don't change the URL hash unless cross-linking is specified
			});
		});

		// External triggers (anywhere on the page)
		$(settings.externalTriggerSelector).each(function() {
			// Make sure this only affects the targeted slider
			if (sliderCount == parseInt($(this).attr("rel").slice(12))) {
				$(this).bind("click", function() {
					navClicks++;
					targetPanel = parseInt($(this).attr("href").slice(1));
					offset = - (panelWidth*(targetPanel - 1));
					alterPanelHeight(targetPanel - 1);
					currentPanel = targetPanel;
					// Switch the current tab:
					slider.siblings('.coda-nav').find('a').removeClass('current').parents('ul').find('li:eq(' + (targetPanel - 1) + ') a').addClass('current');
					// Slide
					$('.panel-container', slider).stop().animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
					if (!settings.crossLinking) { return false }; // Don't change the URL hash unless cross-linking is specified
				});
			};
		});

		// Specify which tab is initially set to "current". Depends on if the loaded URL had a hash or not (cross-linking).
		if (settings.crossLinking && location.hash && parseInt(location.hash.slice(1)) <= panelCount) {
			$("#coda-nav-" + sliderCount + " a:eq(" + (location.hash.slice(1) - 1) + ")").addClass("current");
		// If there's no cross-linking, check to see if we're supposed to load a panel other than Panel 1 initially...
		} else if (settings.firstPanelToLoad != 1 && settings.firstPanelToLoad <= panelCount) {
			$("#coda-nav-" + sliderCount + " a:eq(" + (settings.firstPanelToLoad - 1) + ")").addClass("current");
		// Otherwise we must be loading Panel 1, so make the first tab the current one.
		} else {
			$("#coda-nav-" + sliderCount + " a:eq(0)").addClass("current");
		};

		// Set the height of the first panel
		if (settings.autoHeight) {
			panelHeight = $('.panel:eq(' + (currentPanel - 1) + ')', slider).height();
			slider.css({ height: panelHeight });
		};

		// Trigger autoSlide
		if (settings.autoSlide) {
			slider.ready(function() {
				setTimeout(autoSlide,settings.autoSlideInterval);
			});
		};

		function alterPanelHeight(x) {
			if (settings.autoHeight) {
				panelHeight = $('.panel:eq(' + x + ')', slider).height()
				slider.stop().animate({ height: panelHeight }, settings.autoHeightEaseDuration, settings.autoHeightEaseFunction);
			};
		};

		function autoSlide() {
			if (navClicks == 0 || !settings.autoSlideStopWhenClicked) {
				if (currentPanel == panelCount) {
					var offset = 0;
					currentPanel = 1;
				} else {
					var offset = - (panelWidth*currentPanel);
					currentPanel += 1;
				};
				alterPanelHeight(currentPanel - 1);
				// Switch the current tab:
				slider.siblings('.coda-nav').find('a').removeClass('current').parents('ul').find('li:eq(' + (currentPanel - 1) + ') a').addClass('current');
				// Slide:
				$('.panel-container', slider).stop().animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
				setTimeout(autoSlide,settings.autoSlideInterval);
			};
		};

		// Kill the preloader
		$('.panel', slider).show().end().find("p.loading").remove();
		slider.removeClass("preload");

		sliderCount++;

	});
};<|endoftext|>


<commit_before>(function(Browser) {

	Browser.Views = Browser.Views || {};
	Browser.Views.FancyBox = Browser.Views.FancyBox || {};

	Browser.Views.FancyBox.Website = Browser.Views._Fancybox.extend({

	initialize: function(){
		Browser.Views._Fancybox.prototype.initialize.call(this); //This is like calling super()
	},
	more : function(){

		//call parent MORE method to lay out metadata
			Browser.Views._Fancybox.prototype.more.call(this);

		if(this.model.get("title") == this.model.get("description")){
			$('#fancybox-media-container .description').hide();
		}

		return false;
	},
	less : function(){

			//call parent MORE method to lay out metadata
			Browser.Views._Fancybox.prototype.less.call(this);

		$('#fancybox-media-container .description').show();

		return false;
	},
	/* Pass in the element that the user clicked on from fancybox. */
	render: function(obj)
	{

		sessionStorage.setItem('currentItemId', this.model.id);

		//Call parent class to do captioning and metadata
		Browser.Views._Fancybox.prototype.render.call(this, obj); //This is like calling super()

		var parts=this.model.get("attribution_uri").split('http');

		//Fill in media-specific stuff
		var blanks = {
			original_src :"http"+parts[parts.length-1],
			src: this.model.get("attribution_uri"),
			type : this.model.get("type")
		};

		//use template to clone the database items into
		var template = _.template( this.getMediaTemplate() );

		//copy the cloned item into the el
		var mediaHTML =  template( blanks ) ;

		$(this.el).find('.fancybox-media-item').html(mediaHTML);
		$(this.el).find('.text-wrapper').hide();
		//set fancybox content
		obj.content = $(this.el);

		return this;
	},
	getMediaTemplate : function()
	{

		var html =	'
<%=type%>: <a href="<%=original_src%>" target="_blank"><%=original_src%>
'+
					'
'+
					'<iframe type="text/html" width="100%" height="400px" src="<%=src%>" frameborder="0">'+
					''+
					'
';

		return html;
	}

});

})(jda.module("browser"));<commit_msg>change website preview to use uri instead of attribution_uri<commit_after>(function(Browser) {

	Browser.Views = Browser.Views || {};
	Browser.Views.FancyBox = Browser.Views.FancyBox || {};

	Browser.Views.FancyBox.Website = Browser.Views._Fancybox.extend({

	initialize: function(){
		Browser.Views._Fancybox.prototype.initialize.call(this); //This is like calling super()
	},
	more : function(){

		//call parent MORE method to lay out metadata
			Browser.Views._Fancybox.prototype.more.call(this);

		if(this.model.get("title") == this.model.get("description")){
			$('#fancybox-media-container .description').hide();
		}

		return false;
	},
	less : function(){

			//call parent MORE method to lay out metadata
			Browser.Views._Fancybox.prototype.less.call(this);

		$('#fancybox-media-container .description').show();

		return false;
	},
	/* Pass in the element that the user clicked on from fancybox. */
	render: function(obj)
	{

		sessionStorage.setItem('currentItemId', this.model.id);

		//Call parent class to do captioning and metadata
		Browser.Views._Fancybox.prototype.render.call(this, obj); //This is like calling super()

		var parts=this.model.get("attribution_uri").split('http');

		//Fill in media-specific stuff
		var blanks = {
			original_src :"http"+parts[parts.length-1],
			src: this.model.get("uri"),
			type : this.model.get("type")
		};

		//use template to clone the database items into
		var template = _.template( this.getMediaTemplate() );

		//copy the cloned item into the el
		var mediaHTML =  template( blanks ) ;

		$(this.el).find('.fancybox-media-item').html(mediaHTML);
		$(this.el).find('.text-wrapper').hide();
		//set fancybox content
		obj.content = $(this.el);

		return this;
	},
	getMediaTemplate : function()
	{

		var html =	'
<%=type%>: <a href="<%=original_src%>" target="_blank"><%=original_src%>
'+
					'
'+
					'<iframe type="text/html" width="100%" height="400px" src="<%=src%>" frameborder="0">'+
					''+
					'
';

		return html;
	}

});

})(jda.module("browser"));<|endoftext|>


<commit_before>// Prototypes

String.prototype.format = function() {
	var args = arguments;
	return this.replace(/\{\{|\}\}|\{(\d+)\}/g, function(m, n) {
		if (m == "{{") {
			return "{";
		}
		if (m == "}}") {
			return "}";
		}
		return args[n];
	});
};

String.prototype.html = function() {
	return $('').text(this).html();
};

String.prototype.htmlWithLines = function() {
	var text = this.html();
	return text.replace(/\n/g, '
');
};

// Global functions

function loc () {
	var code = arguments[0];
	var text = l[code];
	if (text != null) {
		var params = []	;
		for (var i = 1 ; i < arguments.length ; i++) {
			params.push(arguments[i]);
		}
		return text.format (params);
	} else {
		return "##" + code + "##";
	}
}

// Application singleton

var Application = function () {

	function dialogAndSubmit (dialogId, dialogTitle, method, url, onSuccessFn) {
		dialog (
			dialogId,
			dialogTitle,
			function (closeFn) {
				submit (
					dialogId,
					method, url,
					function (data) {
						// Does something with the data
						onSuccessFn(data);
						// Closes the dialog
						closeFn();
					},
					function (message) {
				  		$('#' + dialogId + '-error').html(message.htmlWithLines());
				  		$('#' + dialogId + '-error').show();
				});
			});
	}

	/**
	 * Opens a dialog defined by the dialogId HTML fragment.
	 * @param dialogId ID of a HTML section
	 * @param dialogTitle Title of the dialog
	 * @param onSubmitFn (. => .) => . - Function to call when the submit button
	 * is triggered. The onSubmitFn is called with a function
	 * (no argument) which is responsible to close the dialog.
	 */
	function dialog (dialogId, dialogTitle, onSubmitFn) {
		// Sets the submit function
		$('#' + dialogId).unbind('submit');
		$('#' + dialogId).submit(function () {
			onSubmitFn(function () {
				$('#' + dialogId).dialog('close');
			});
			return false;
		});
		// Sets the cancel button (if any)
		$('#' + dialogId + '-cancel').unbind('click');
		$('#' + dialogId + '-cancel').click(function () {
			$('#' + dialogId).dialog('close');
		});
		// Shows the dialog
		$('#' + dialogId).dialog({
			title: dialogTitle,
			width: 450,
			modal: true
		});
	}

	function values (baseId) {
		var data = {};
		$('#' + baseId + ' input').each (function (index, field) {
			var name = field.getAttribute('name');
			var value = field.value;
			data[name] = value;
		});
		$('#' + baseId + ' textarea').each (function (index, field) {
			var name = field.getAttribute('name');
			var value = field.value;
			data[name] = value;
		});
		return data;
	}

	/**
	 * Submit a set of data defined in a form.
	 * @param baseId ID of the HTML form
	 * @param method HTTP method to use ('GET', 'POST'...)
	 * @param url URL to call
	 * @param successFn (JSON => .) Function called in case of success.
	 * @param errorMessageFn (String => .) Function called in case of error.
	 * @see #ajax
	 */
	function submit (baseId, method, url, successFn, errorMessageFn) {
		// Collects all fields values
		var data = values (baseId);
		// Call
		ajax (method, url, data, successFn, errorMessageFn);
	}

	function onAjaxError(jqXHR, textStatus, errorThrown, errorMessageFn) {
	  	if (errorMessageFn) {
	  		if (jqXHR.status == 500 && jqXHR.responseText && jqXHR.responseText != '') {
	  			errorMessageFn(jqXHR.responseText);
	  		} else {
	  			var message = getAjaxError(loc('client.error.general'), jqXHR, textStatus, errorThrown);
	  			errorMessageFn(message);
	  		}
	  	} else {
	  		Application.displayAjaxError (loc('client.error.general'), jqXHR, textStatus, errorThrown);
	  	}
	}

	/**
	 * @param method HTTP method to use ('GET', 'POST'...)
	 * @param url URL to call
	 * @param data Data to send as JSON
	 * @param successFn (JSON => .) Function called in case of success.
	 * @param errorMessageFn (String => .) Function called in case of error.
	 */
	function ajax (method, url, data, successFn, errorMessageFn) {
		$.ajax({
			type: method,
			url: url,
			contentType: 'application/json',
			data: JSON.stringify(data),
			dataType: 'json',
			success: function (data) {
				successFn(data);
			},
			error: function (jqXHR, textStatus, errorThrown) {
				onAjaxError(jqXHR, textStatus, errorThrown, errorMessageFn);
			}
		});
	}

	function ajaxGet (url, successFn, errorMessageFn) {
		$.ajax({
			type: 'GET',
			url: url,
			dataType: 'json',
			success: function (data) {
				successFn(data);
			},
			error: function (jqXHR, textStatus, errorThrown) {
				onAjaxError(jqXHR, textStatus, errorThrown, errorMessageFn);
			}
		});
	}

	function ajaxDelete (url, successFn, errorMessageFn) {
		$.ajax({
			type: 'DELETE',
			url: url,
			dataType: 'json',
			success: function (data) {
				successFn(data);
			},
			error: function (jqXHR, textStatus, errorThrown) {
				onAjaxError(jqXHR, textStatus, errorThrown, errorMessageFn);
			}
		});
	}

	function confirmAndCall (text, callback) {
		$('
{0}
'.format(text)).dialog({
			title: loc('general.confirm.title'),
			dialogClass: 'confirm-dialog',
			modal: true,
			buttons: {
				Ok: function () {
					$( this ).dialog( "close" );
					callback();
				},
				Cancel: function () {
					$( this ).dialog( "close" );
				}
			}
		});
	}

	function confirmIDAndCall (id, callback) {
		var text = document.getElementById(id).value;
		confirmAndCall(text, callback);
	}

	function displayError (text) {
		$('
{0}
'.format(text.htmlWithLines())).dialog({
			title: loc('client.error.title'),
			modal: true,
            buttons: {
                Ok: function() {
                    $( this ).dialog( "close" );
                }
            }
		});
	}

	function getAjaxError (message, jqXHR, textStatus, errorThrown) {
		return '{0}\n[{1}] {2}'.format(message, jqXHR.status, jqXHR.statusText);
	}

	function displayAjaxError (message, jqXHR, textStatus, errorThrown) {
		var text = getAjaxError(message, jqXHR, textStatus, errorThrown);
		displayError(text);
	}

	function changeLanguage (lang) {
		if (location.search.indexOf("language") > -1) {
	    	location.search = location.search.replace(/language=[a-z][a-z]/, "language=" + lang);
		} else if (location.search == "") {
			var url = location.href;
			if (url.substr(url.length - 1) == '?') {
				location.href += "language=" + lang;
			} else {
				location.href += "?language=" + lang;
			}
		} else {
			location.href += "&language=" + lang;
		}
	}

	function validate (selector, test) {
		if (test) {
			$(selector).removeClass("invalid");
			return true;
		} else {
			$(selector).addClass("invalid");
			return false;
		}
	}

	function loading (selector, loading) {
		$(selector).empty();
		if (loading) {
			$(selector).append('
{0}
'.format(loc('general.loading')));
		}
	}

	var templates = {};
	var offsetsAndCounts = {};

	function loadInit (id, templateFn) {
		// Registers the function
		templates["load-" + id] = templateFn;
		offsetsAndCounts[id] = {
		    offset: 0,
		    count: 10
		};
		// Initial load
		load (id, templateFn);
	}

	function reload (id, append) {
		// Gets the load function
		var templateFn = templates["load-" + id];
		// Reloads
		load (id, templateFn, append);
	}

	function loadMore (id) {
		// Gets the loading information
		var url = $('#' + id).attr('data-url');
		// Offset and count
		var offsetAndCount = offsetsAndCounts[id];
		// Adjust the offset
		offsetAndCount.offset += offsetAndCount.count;
		// Loads more
		reload(id, true);
	}

	function load (id, templateFn, append) {
		// Gets the loading information
		var url = $('#' + id).attr('data-url');
		var more = $('#' + id).attr('data-more');
		if (url) {
		    // Offset and count
		    var offsetAndCount = offsetsAndCounts[id];
		    if (more == 'true' && offsetAndCount) {
		        url += '&offset={0}&count={1}'.format(offsetAndCount.offset, offsetAndCount.count);
		    }
		    // Log
			console.log('Loading "{0}" into "{1}"'.format(url, id));
			// Starts loading
			loading("#" + id + '-loading', true);
	  		$('#' + id + '-error').hide();
			// Call
			ajaxGet (
				url,
				function (data) {
					// Loading done
					loading("#" + id + '-loading', false);
					// Fills the container
					templateFn(id + '-list', append, data);
				},
				function (message) {
			  		$('#' + id + '-error').html(message.htmlWithLines());
			  		$('#' + id + '-error').show();
					loading("#" + id + '-loading', false);
				});
		} else {
			throw 'No "data-url" is defined on element "{0}"'.format(id);
		}
	}

	function extractEntity (value) {
	    var pos = value.indexOf('/');
	    if (pos > 0) {
	        return value.substring(0, pos);
	    } else {
	        return value;
	    }
	}

	function deleteEntity (entity, id, backUrl) {
		var url = 'ui/manage/{0}/{1}'.format(entity, id);
		ajaxGet (
			url,
			function (o) {
				confirmAndCall(
					loc('{0}.delete.prompt'.format(extractEntity(entity)), o.name),
					function () {
						ajaxDelete (
							url,
							function () {
								location = backUrl;
							},
							displayError);
					});
			},
			displayError);
	}

	return {
		dialog: dialog,
		submit: submit,
		dialogAndSubmit: dialogAndSubmit,
		confirmAndCall: confirmAndCall,
		confirmIDAndCall: confirmIDAndCall,
		displayError: displayError,
		displayAjaxError: displayAjaxError,
		getAjaxError: getAjaxError,
		changeLanguage: changeLanguage,
		validateTextAsName: function (selector) {
			var value = $(selector).val();
			var trimmedValue = value.trim();
			return validate (selector, trimmedValue == value && trimmedValue != "");
		},
		validateTextAsTrimmed: function (selector) {
			var value = $(selector).val();
			var trimmedValue = value.trim();
			return validate (selector, trimmedValue == value);
		},
		validateConfirmation: function (source, confirmation) {
			var value = $(source).val();
			var confirmValue = $(confirmation).val();
			return validate (confirmation, confirmValue == value);
		},
		loading: loading,
		loadInit: loadInit,
		load: load,
		reload: reload,
		loadMore: loadMore,
		deleteEntity: deleteEntity,
		ajaxGet: ajaxGet
	};

} ();<commit_msg>Events: hides the More buttons when no more items are available<commit_after>// Prototypes

String.prototype.format = function() {
	var args = arguments;
	return this.replace(/\{\{|\}\}|\{(\d+)\}/g, function(m, n) {
		if (m == "{{") {
			return "{";
		}
		if (m == "}}") {
			return "}";
		}
		return args[n];
	});
};

String.prototype.html = function() {
	return $('').text(this).html();
};

String.prototype.htmlWithLines = function() {
	var text = this.html();
	return text.replace(/\n/g, '
');
};

// Global functions

function loc () {
	var code = arguments[0];
	var text = l[code];
	if (text != null) {
		var params = []	;
		for (var i = 1 ; i < arguments.length ; i++) {
			params.push(arguments[i]);
		}
		return text.format (params);
	} else {
		return "##" + code + "##";
	}
}

// Application singleton

var Application = function () {

	function dialogAndSubmit (dialogId, dialogTitle, method, url, onSuccessFn) {
		dialog (
			dialogId,
			dialogTitle,
			function (closeFn) {
				submit (
					dialogId,
					method, url,
					function (data) {
						// Does something with the data
						onSuccessFn(data);
						// Closes the dialog
						closeFn();
					},
					function (message) {
				  		$('#' + dialogId + '-error').html(message.htmlWithLines());
				  		$('#' + dialogId + '-error').show();
				});
			});
	}

	/**
	 * Opens a dialog defined by the dialogId HTML fragment.
	 * @param dialogId ID of a HTML section
	 * @param dialogTitle Title of the dialog
	 * @param onSubmitFn (. => .) => . - Function to call when the submit button
	 * is triggered. The onSubmitFn is called with a function
	 * (no argument) which is responsible to close the dialog.
	 */
	function dialog (dialogId, dialogTitle, onSubmitFn) {
		// Sets the submit function
		$('#' + dialogId).unbind('submit');
		$('#' + dialogId).submit(function () {
			onSubmitFn(function () {
				$('#' + dialogId).dialog('close');
			});
			return false;
		});
		// Sets the cancel button (if any)
		$('#' + dialogId + '-cancel').unbind('click');
		$('#' + dialogId + '-cancel').click(function () {
			$('#' + dialogId).dialog('close');
		});
		// Shows the dialog
		$('#' + dialogId).dialog({
			title: dialogTitle,
			width: 450,
			modal: true
		});
	}

	function values (baseId) {
		var data = {};
		$('#' + baseId + ' input').each (function (index, field) {
			var name = field.getAttribute('name');
			var value = field.value;
			data[name] = value;
		});
		$('#' + baseId + ' textarea').each (function (index, field) {
			var name = field.getAttribute('name');
			var value = field.value;
			data[name] = value;
		});
		return data;
	}

	/**
	 * Submit a set of data defined in a form.
	 * @param baseId ID of the HTML form
	 * @param method HTTP method to use ('GET', 'POST'...)
	 * @param url URL to call
	 * @param successFn (JSON => .) Function called in case of success.
	 * @param errorMessageFn (String => .) Function called in case of error.
	 * @see #ajax
	 */
	function submit (baseId, method, url, successFn, errorMessageFn) {
		// Collects all fields values
		var data = values (baseId);
		// Call
		ajax (method, url, data, successFn, errorMessageFn);
	}

	function onAjaxError(jqXHR, textStatus, errorThrown, errorMessageFn) {
	  	if (errorMessageFn) {
	  		if (jqXHR.status == 500 && jqXHR.responseText && jqXHR.responseText != '') {
	  			errorMessageFn(jqXHR.responseText);
	  		} else {
	  			var message = getAjaxError(loc('client.error.general'), jqXHR, textStatus, errorThrown);
	  			errorMessageFn(message);
	  		}
	  	} else {
	  		Application.displayAjaxError (loc('client.error.general'), jqXHR, textStatus, errorThrown);
	  	}
	}

	/**
	 * @param method HTTP method to use ('GET', 'POST'...)
	 * @param url URL to call
	 * @param data Data to send as JSON
	 * @param successFn (JSON => .) Function called in case of success.
	 * @param errorMessageFn (String => .) Function called in case of error.
	 */
	function ajax (method, url, data, successFn, errorMessageFn) {
		$.ajax({
			type: method,
			url: url,
			contentType: 'application/json',
			data: JSON.stringify(data),
			dataType: 'json',
			success: function (data) {
				successFn(data);
			},
			error: function (jqXHR, textStatus, errorThrown) {
				onAjaxError(jqXHR, textStatus, errorThrown, errorMessageFn);
			}
		});
	}

	function ajaxGet (url, successFn, errorMessageFn) {
		$.ajax({
			type: 'GET',
			url: url,
			dataType: 'json',
			success: function (data) {
				successFn(data);
			},
			error: function (jqXHR, textStatus, errorThrown) {
				onAjaxError(jqXHR, textStatus, errorThrown, errorMessageFn);
			}
		});
	}

	function ajaxDelete (url, successFn, errorMessageFn) {
		$.ajax({
			type: 'DELETE',
			url: url,
			dataType: 'json',
			success: function (data) {
				successFn(data);
			},
			error: function (jqXHR, textStatus, errorThrown) {
				onAjaxError(jqXHR, textStatus, errorThrown, errorMessageFn);
			}
		});
	}

	function confirmAndCall (text, callback) {
		$('
{0}
'.format(text)).dialog({
			title: loc('general.confirm.title'),
			dialogClass: 'confirm-dialog',
			modal: true,
			buttons: {
				Ok: function () {
					$( this ).dialog( "close" );
					callback();
				},
				Cancel: function () {
					$( this ).dialog( "close" );
				}
			}
		});
	}

	function confirmIDAndCall (id, callback) {
		var text = document.getElementById(id).value;
		confirmAndCall(text, callback);
	}

	function displayError (text) {
		$('
{0}
'.format(text.htmlWithLines())).dialog({
			title: loc('client.error.title'),
			modal: true,
            buttons: {
                Ok: function() {
                    $( this ).dialog( "close" );
                }
            }
		});
	}

	function getAjaxError (message, jqXHR, textStatus, errorThrown) {
		return '{0}\n[{1}] {2}'.format(message, jqXHR.status, jqXHR.statusText);
	}

	function displayAjaxError (message, jqXHR, textStatus, errorThrown) {
		var text = getAjaxError(message, jqXHR, textStatus, errorThrown);
		displayError(text);
	}

	function changeLanguage (lang) {
		if (location.search.indexOf("language") > -1) {
	    	location.search = location.search.replace(/language=[a-z][a-z]/, "language=" + lang);
		} else if (location.search == "") {
			var url = location.href;
			if (url.substr(url.length - 1) == '?') {
				location.href += "language=" + lang;
			} else {
				location.href += "?language=" + lang;
			}
		} else {
			location.href += "&language=" + lang;
		}
	}

	function validate (selector, test) {
		if (test) {
			$(selector).removeClass("invalid");
			return true;
		} else {
			$(selector).addClass("invalid");
			return false;
		}
	}

	function loading (selector, loading) {
		$(selector).empty();
		if (loading) {
			$(selector).append('
{0}
'.format(loc('general.loading')));
		}
	}

	var templates = {};
	var offsetsAndCounts = {};

	function loadInit (id, templateFn) {
		// Registers the function
		templates["load-" + id] = templateFn;
		offsetsAndCounts[id] = {
		    offset: 0,
		    count: 10
		};
		// Initial load
		load (id, templateFn);
	}

	function reload (id, append) {
		// Gets the load function
		var templateFn = templates["load-" + id];
		// Reloads
		load (id, templateFn, append);
	}

	function loadMore (id) {
		// Gets the loading information
		var url = $('#' + id).attr('data-url');
		// Offset and count
		var offsetAndCount = offsetsAndCounts[id];
		// Adjust the offset
		offsetAndCount.offset += offsetAndCount.count;
		// Loads more
		reload(id, true);
	}

	function load (id, templateFn, append) {
		// Gets the loading information
		var url = $('#' + id).attr('data-url');
		var more = $('#' + id).attr('data-more');
		if (url) {
		    // Offset and count
		    var offsetAndCount = offsetsAndCounts[id];
		    if (more == 'true' && offsetAndCount) {
		        url += '&offset={0}&count={1}'.format(offsetAndCount.offset, offsetAndCount.count);
		    }
		    // Log
			console.log('Loading "{0}" into "{1}"'.format(url, id));
			// Starts loading
			loading("#" + id + '-loading', true);
	  		$('#' + id + '-error').hide();
			// Call
			ajaxGet (
				url,
				function (data) {
					// Loading done
					loading("#" + id + '-loading', false);
					// Fills the container
					templateFn(id + '-list', append, data);
					// Adjust the more button
					if (more == 'true') {
					    var some = data.length && data.length > 0;
					    if (!some) {
					        // Disable the more button
					        $('#' + id + "-more").hide();
					    }
                    }
				},
				function (message) {
			  		$('#' + id + '-error').html(message.htmlWithLines());
			  		$('#' + id + '-error').show();
					loading("#" + id + '-loading', false);
				});
		} else {
			throw 'No "data-url" is defined on element "{0}"'.format(id);
		}
	}

	function extractEntity (value) {
	    var pos = value.indexOf('/');
	    if (pos > 0) {
	        return value.substring(0, pos);
	    } else {
	        return value;
	    }
	}

	function deleteEntity (entity, id, backUrl) {
		var url = 'ui/manage/{0}/{1}'.format(entity, id);
		ajaxGet (
			url,
			function (o) {
				confirmAndCall(
					loc('{0}.delete.prompt'.format(extractEntity(entity)), o.name),
					function () {
						ajaxDelete (
							url,
							function () {
								location = backUrl;
							},
							displayError);
					});
			},
			displayError);
	}

	return {
		dialog: dialog,
		submit: submit,
		dialogAndSubmit: dialogAndSubmit,
		confirmAndCall: confirmAndCall,
		confirmIDAndCall: confirmIDAndCall,
		displayError: displayError,
		displayAjaxError: displayAjaxError,
		getAjaxError: getAjaxError,
		changeLanguage: changeLanguage,
		validateTextAsName: function (selector) {
			var value = $(selector).val();
			var trimmedValue = value.trim();
			return validate (selector, trimmedValue == value && trimmedValue != "");
		},
		validateTextAsTrimmed: function (selector) {
			var value = $(selector).val();
			var trimmedValue = value.trim();
			return validate (selector, trimmedValue == value);
		},
		validateConfirmation: function (source, confirmation) {
			var value = $(source).val();
			var confirmValue = $(confirmation).val();
			return validate (confirmation, confirmValue == value);
		},
		loading: loading,
		loadInit: loadInit,
		load: load,
		reload: reload,
		loadMore: loadMore,
		deleteEntity: deleteEntity,
		ajaxGet: ajaxGet
	};

} ();<|endoftext|>


<commit_before>/* This is the javascript for the opt-in page. It sets/deletes
   a cookie which controls whether the flashproxy javascript
   code should run or disable itself. */

var COOKIE_NAME = "flashproxy";
/* max-age is not supported in IE. */
var COOKIE_LIFETIME = "Thu, 01 Jan 2020 00:00:00 GMT";

/* This wrapper will attach events correctly in older
   versions of IE. */
function add_event(elem, evt, handler) {
    if (elem.attachEvent)
        elem.attachEvent("on" + evt, handler);
    else
        elem.addEventListener(evt, handler);
}

function set_cookie_allowed() {
    document.cookie = COOKIE_NAME + "= ;path=/ ;expires=" + COOKIE_LIFETIME;
}

function set_cookie_disallowed() {
    document.cookie = COOKIE_NAME + "= ;path=/ ;expires=Thu, 01 Jan 1970 00:00:00 GMT";
}

add_event(window, "load", function () {

    function cookie_present() {
        var cookies = document.cookie.split(";");

        for (i in cookies) {
            var name = cookies[i].split("=")[0];

            while (name[0] === " ")
                name = name.substr(1);
            if (COOKIE_NAME === name)
                return true;
        }
        return false;
    }

    /* Updates the text telling the user what his current setting is.*/
    function update_setting_text() {
        var setting = document.getElementById("setting");
        var prefix = "
Your current setting is: ";

        if (cookie_present()) {
            setting.innerHTML = prefix + "use my browser as a proxy. " +
                                         "Click no below to change your setting.
";
        } else {
            setting.innerHTML = prefix + "do not use my browser as a proxy. " +
                                         "Click yes below to change your setting.
";
        }
    }

    if (navigator.cookieEnabled) {
        var buttons = document.getElementById("buttons");
        add_event(buttons, "click", update_setting_text);
        buttons.style.display = "block";
        update_setting_text();
    } else {
        document.getElementById("cookies_disabled").style.display = "block";
        /* Manually set the text here as otherwise it will refer to
           the buttons, which don't show if cookies are disabled. */
        document.getElementById("setting").innerHTML = "
Your current setting is: " +
                                                       "do not use my browser as a proxy.
";
    }
});
<commit_msg>Use boolean value for the cookie.<commit_after>/* This is the javascript for the opt-in page. It sets/deletes
   a cookie which controls whether the flashproxy javascript
   code should run or disable itself. */

var COOKIE_NAME = "flashproxy";
/* max-age is not supported in IE. */
var COOKIE_LIFETIME = "Thu, 01 Jan 2020 00:00:00 GMT";

/* This wrapper will attach events correctly in older
   versions of IE. */
function add_event(elem, evt, handler) {
    if (elem.attachEvent)
        elem.attachEvent("on" + evt, handler);
    else
        elem.addEventListener(evt, handler);
}

function set_cookie_allowed() {
    document.cookie = COOKIE_NAME + "=1;path=/ ;expires=" + COOKIE_LIFETIME;
}

function set_cookie_disallowed() {
    document.cookie = COOKIE_NAME + "=0;path=/ ;expires=" + COOKIE_LIFETIME;
}

add_event(window, "load", function () {

    function cookie_present() {
        var cookies = document.cookie.split(";");

        for (i in cookies) {
            var name = cookies[i].split("=")[0];

            while (name[0] === " ")
                name = name.substr(1);
            if (COOKIE_NAME === name)
                return true;
        }
        return false;
    }

    /* Updates the text telling the user what his current setting is.*/
    function update_setting_text() {
        var setting = document.getElementById("setting");
        var prefix = "
Your current setting is: ";

        if (cookie_present()) {
            setting.innerHTML = prefix + "use my browser as a proxy. " +
                                         "Click no below to change your setting.
";
        } else {
            setting.innerHTML = prefix + "do not use my browser as a proxy. " +
                                         "Click yes below to change your setting.
";
        }
    }

    if (navigator.cookieEnabled) {
        var buttons = document.getElementById("buttons");
        add_event(buttons, "click", update_setting_text);
        buttons.style.display = "block";
        update_setting_text();
    } else {
        document.getElementById("cookies_disabled").style.display = "block";
        /* Manually set the text here as otherwise it will refer to
           the buttons, which don't show if cookies are disabled. */
        document.getElementById("setting").innerHTML = "
Your current setting is: " +
                                                       "do not use my browser as a proxy.
";
    }
});
<|endoftext|>


<commit_before>import createSchema from 'olymp-graphql/server';
import createMail from 'olymp-mail/server';
import { authGraphQL, authCache, createAuthEngine } from 'olymp-auth/server';
import { pagesGraphQL } from 'olymp-pages/server';
import { cloudinaryGraphQL } from 'olymp-cloudinary/server';
import { googleGraphQL } from 'olymp-google/server';
/* import createSitemap from 'olymp-sitemap/server';*/
import createMonk from 'monk';
import { modules as colModules, directives } from 'olymp-collection/server';
import { get } from 'lodash';

const {
  APP,
  URL,
  MONGODB_URI,
  POSTMARK_KEY,
  POSTMARK_FROM,
  CLOUDINARY_URI,
  // FILESTACK_KEY,
  AUTH_SECRET,
  NODE_ENV,
  GOOGLE_MAPS_KEY,
  GOOGLE_CLIENT_EMAIL,
  GOOGLE_PRIVATE_KEY,
} = process.env;

export default (server, options) => {
  const monk = createMonk(MONGODB_URI);

  const schema = createSchema({ directives });
  const modules = {
    helloWorld: {
      queries: `
      helloWorld: String
    `,
      resolvers: {
        queries: {
          helloWorld: () => 'Hello World!',
        },
      },
    },
    ...get(options, 'modules', {}),
    ...colModules,
  };
  const mail = createMail(POSTMARK_KEY, {
    from: POSTMARK_FROM,
    url: URL,
  });

  const authEngine = createAuthEngine({ monk, mail, secret: AUTH_SECRET });
  server.use(authCache(authEngine));

  let cachedApp = null;
  server.use((req, res, next) => {
    req.mail = mail;
    req.monk = monk;
    req.schema = schema;
    req.authEngine = authEngine;
    req.app = cachedApp;
    next();
  });

  modules.auth = authGraphQL(options.auth);
  modules.pages = pagesGraphQL();
  modules.cloudinary = cloudinaryGraphQL(CLOUDINARY_URI);
  modules.google = googleGraphQL(
    GOOGLE_MAPS_KEY,
    GOOGLE_CLIENT_EMAIL,
    GOOGLE_PRIVATE_KEY
  );
  /*
  createSitemap(schema, options.sitemap);
  googleGraphQL(schema, GM_KEY, options.google);
  pagesGraphQL(schema, options.pages);
  cloudinaryGraphQL(schema, CLOUDINARY_URI, options.cloudinary);

  if (options.schemas) {
    options.schemas({ schema, mail, authEngine, server, monk });
  }

  let cachedApp = null;
  // Add GraphQL API
  server.post('/graphql', (req, res, next) => {
    if (cachedApp) {
      return schema.express(req, res, next);
    }
    monk
      .collection('apps')
      .findOne({ id: APP })
      .then((app) => {
        if (!app) {
          throw new Error('App not found');
        }
        cachedApp = app;
        // attach schemata
        // schema.addSchema();
        schema.express(req, res, next);
      })
      .catch(err => next(err));
  });*/
  server.post('/graphql', schema.express);
  if (NODE_ENV !== 'production') {
    server.get('/graphql', schema.graphi);
  }

  monk.collection('app').findOne({ id: APP }).then((app) => {
    if (!app) {
      throw new Error('App not found');
    }
    cachedApp = app;
    schema.apply(modules);
  });

  const shortId = require('shortid');
  /*monk.collection('item').find({ _type: 'einrichtung' }).then((items) => {
    // monk.collection('item').find({ _type: 'termin' }).then((items) => {
    items.forEach((item) => {
      item.color = item.farbe;
      delete item.farbe;
      item.description = item.willkommen;
      delete item.willkommen;
      delete item._id;
      monk.collection('item').insert({ ...item, _type: 'org' });
    });
  });*/
  /*// monk.collection('item').remove({ _type: 'article' });
  */
  /*monk.collection('item').find({ _type: 'termin' }).then((items) => {
      // monk.collection('item').find({ _type: 'termin' }).then((items) => {
      items.forEach((item) => {
          item.extract = item.extrakt;
          delete item.extrakt;
          item.image = item.bild;
          delete item.image;
          delete item._id;
          item.id = shortId.generate();
          if (item.art && item.art.indexOf('V') === 0) {
              monk.collection('item').insert({ ...item, _type: 'event' });
          } else {
              monk.collection('item').insert({ ...item, _type: 'news' });
          }
      });
  });*/
  /*monk.collection('item').find({ _type: 'termin' }).then((items) => {
    items.forEach((item) => {
      item.extract = item.extract;
      delete item.extract;
      item.image = item.image;
      delete item.image;
      if (item.type && item.type.indexOf('V') === 0) {
        monk.collection('item').update({ ...item, _type: 'event' });
      } else if (item.type && item.type.indexOf('V') === 0) {
        monk.collection('item').update({ ...item, _type: 'news' });
      }
    });
  });

  */
  /* monk.collection('page').find({}).then((items) => {
    items.forEach((item) => {
      monk.collection('item').insert({ ...item, _type: 'page', _appId: 'gzk' });
    });
  });
  monk.collection('file').find({}).then((items) => {
    items.forEach((item) => {
      monk.collection('item').insert({ ...item, _type: 'file', _appId: 'gzk' });
    });
  });*/
};

/* if (mail) mail({ to: 'bkniffler@me.com', subject: 'Hello!', markdown: `
Hallo
## kopo [Anmelden](http://google.de)
[Anmelden](http://google.de)
` }).then(x => x.json()).then(x => console.log(x)).catch(err => console.error(err));*/

/*
import { filestackGraphQL } from 'olymp-filestack/server';

if (FILESTACK_KEY) {
  filestackGraphQL(schema, FILESTACK_KEY, options.filestack);
}
*/
<commit_msg>server<commit_after>import createSchema from 'olymp-graphql/server';
import createMail from 'olymp-mail/server';
import { authGraphQL, authCache, createAuthEngine } from 'olymp-auth/server';
import { pagesGraphQL } from 'olymp-pages/server';
import { cloudinaryGraphQL } from 'olymp-cloudinary/server';
import { googleGraphQL } from 'olymp-google/server';
/* import createSitemap from 'olymp-sitemap/server';*/
import createMonk from 'monk';
import { modules as colModules, directives } from 'olymp-collection/server';
import { get } from 'lodash';

const {
  APP,
  URL,
  MONGODB_URI,
  POSTMARK_KEY,
  POSTMARK_FROM,
  CLOUDINARY_URI,
  // FILESTACK_KEY,
  AUTH_SECRET,
  NODE_ENV,
  GOOGLE_MAPS_KEY,
  GOOGLE_CLIENT_EMAIL,
  GOOGLE_PRIVATE_KEY,
} = process.env;

export default (server, options) => {
  const monk = createMonk(MONGODB_URI);

  const schema = createSchema({ directives });
  const modules = {
    helloWorld: {
      queries: `
      helloWorld: String
    `,
      resolvers: {
        queries: {
          helloWorld: () => 'Hello World!',
        },
      },
    },
    ...get(options, 'modules', {}),
    ...colModules,
  };
  const mail = createMail(POSTMARK_KEY, {
    from: POSTMARK_FROM,
    url: URL,
  });

  const authEngine = createAuthEngine({ monk, mail, secret: AUTH_SECRET });
  server.use(authCache(authEngine));

  let cachedApp = null;
  server.use((req, res, next) => {
    req.mail = mail;
    req.monk = monk;
    req.schema = schema;
    req.authEngine = authEngine;
    req.app = cachedApp;
    next();
  });

  modules.auth = authGraphQL(options.auth);
  modules.pages = pagesGraphQL();
  modules.cloudinary = cloudinaryGraphQL(CLOUDINARY_URI);
  modules.google = googleGraphQL(
    GOOGLE_MAPS_KEY,
    GOOGLE_CLIENT_EMAIL,
    GOOGLE_PRIVATE_KEY
  );
  /*
  createSitemap(schema, options.sitemap);
  googleGraphQL(schema, GM_KEY, options.google);
  pagesGraphQL(schema, options.pages);
  cloudinaryGraphQL(schema, CLOUDINARY_URI, options.cloudinary);

  if (options.schemas) {
    options.schemas({ schema, mail, authEngine, server, monk });
  }

  let cachedApp = null;
  // Add GraphQL API
  server.post('/graphql', (req, res, next) => {
    if (cachedApp) {
      return schema.express(req, res, next);
    }
    monk
      .collection('apps')
      .findOne({ id: APP })
      .then((app) => {
        if (!app) {
          throw new Error('App not found');
        }
        cachedApp = app;
        // attach schemata
        // schema.addSchema();
        schema.express(req, res, next);
      })
      .catch(err => next(err));
  });*/
  server.post('/graphql', schema.express);
  if (NODE_ENV !== 'production') {
    server.get('/graphql', schema.graphi);
  }

  monk.collection('app').findOne({ id: APP }).then((app) => {
    if (!app) {
      throw new Error('App not found');
    }
    cachedApp = app;
    schema.apply(modules);
  });

  const shortId = require('shortid');

  /*monk.collection('item').find({ _type: 'einrichtung' }).then((items) => {
    // monk.collection('item').find({ _type: 'termin' }).then((items) => {
    items.forEach((item) => {
      item.color = item.farbe;
      delete item.farbe;
      item.description = item.willkommen;
      delete item.willkommen;
      delete item._id;
      monk.collection('item').insert({ ...item, _type: 'org' });
    });
  });*/
  /*// monk.collection('item').remove({ _type: 'article' });
  */
  /*monk.collection('item').find({ _type: 'termin' }).then((items) => {
      // monk.collection('item').find({ _type: 'termin' }).then((items) => {
      items.forEach((item) => {
          item.extract = item.extrakt;
          delete item.extrakt;
          item.image = item.bild;
          delete item.image;
          delete item._id;
          item.id = shortId.generate();
          if (item.art && item.art.indexOf('V') === 0) {
              monk.collection('item').insert({ ...item, _type: 'event' });
          } else {
              monk.collection('item').insert({ ...item, _type: 'news' });
          }
      });
  });*/
  /*monk.collection('item').find({ _type: 'termin' }).then((items) => {
    items.forEach((item) => {
      item.extract = item.extract;
      delete item.extract;
      item.image = item.image;
      delete item.image;
      if (item.type && item.type.indexOf('V') === 0) {
        monk.collection('item').update({ ...item, _type: 'event' });
      } else if (item.type && item.type.indexOf('V') === 0) {
        monk.collection('item').update({ ...item, _type: 'news' });
      }
    });
  });

  */
  /* monk.collection('page').find({}).then((items) => {
    items.forEach((item) => {
      monk.collection('item').insert({ ...item, _type: 'page', _appId: 'gzk' });
    });
  });
  monk.collection('file').find({}).then((items) => {
    items.forEach((item) => {
      monk.collection('item').insert({ ...item, _type: 'file', _appId: 'gzk' });
    });
  });*/
};

/* if (mail) mail({ to: 'bkniffler@me.com', subject: 'Hello!', markdown: `
Hallo
## kopo [Anmelden](http://google.de)
[Anmelden](http://google.de)
` }).then(x => x.json()).then(x => console.log(x)).catch(err => console.error(err));*/

/*
import { filestackGraphQL } from 'olymp-filestack/server';

if (FILESTACK_KEY) {
  filestackGraphQL(schema, FILESTACK_KEY, options.filestack);
}
*/
<|endoftext|>


<commit_before>$(function() {
	StatusManager.getStatus();
	setInterval(StatusManager.getStatus, 4000);
	// Logger.getLastsLogs();

});

var StatusManager =
{
	inited : false,

	deleteStatus: function() {
		$('.status-container .status').remove();
	},

	addStatus: function(status) {

		var html = '
';
		html += '
';
		html += '
' + status.name + '
';
		html += '
';

		html += '
';
		html += '
' + status.hp + '% HP
';
		html += '
';

		html += '
';
		html += '
' + status.hp + '% EXP
';
		html += '
';

		if(status.isInGame == 'Yes') {
			html += '
';
		} else {
			html += '
';
		}

		html += '
Is in Game : ' + status.isInGame + '
';
		html += '
';

		if(status.status == 'Leveling') {
			html += '
';
		} else {
			html += '
';
		}

		html += '
' + status.status + '
';
		html += '
';

		html += '
';

		$('.status-container').append(html);
	},

	getStatus : function() {
	    $.ajax({
	       url : ajaxUrlStatus,
	       type : 'GET',
	       dataType : 'json',
	       success : function(json, statut){ // success est toujours en place, bien sûr !
				console.log(json);
				// console.log(Logger.inited);
				var i = 0;
				StatusManager.deleteStatus();
				for(status in json) {
					var curStatus = json[status];
					StatusManager.addStatus(curStatus);
				}

	       },

	       error : function(resultat, statut, erreur){

	       }

	    });

	}

};<commit_msg>1.0.4.3<commit_after>$(function() {
	StatusManager.getStatus();
	setInterval(StatusManager.getStatus, 4000);
	// Logger.getLastsLogs();

});

var StatusManager =
{
	inited : false,

	deleteStatus: function() {
		$('.status-container .status').remove();
	},

	addStatus: function(status) {

		var html = '
';
		html += '
';
		html += '
' + status.name + '
';
		html += '
';

		html += '
';
		html += '
' + status.hp + '% HP
';
		html += '
';

		html += '
';
		html += '
' + status.exp + '% EXP
';
		html += '
';

		if(status.isInGame == 'Yes') {
			html += '
';
		} else {
			html += '
';
		}

		html += '
Is in Game : ' + status.isInGame + '
';
		html += '
';

		if(status.status == 'Leveling') {
			html += '
';
		} else {
			html += '
';
		}

		html += '
' + status.status + '
';
		html += '
';

		html += '
';

		$('.status-container').append(html);
	},

	getStatus : function() {
	    $.ajax({
	       url : ajaxUrlStatus,
	       type : 'GET',
	       dataType : 'json',
	       success : function(json, statut){ // success est toujours en place, bien sûr !
				console.log(json);
				// console.log(Logger.inited);
				var i = 0;
				StatusManager.deleteStatus();
				for(status in json) {
					var curStatus = json[status];
					StatusManager.addStatus(curStatus);
				}

	       },

	       error : function(resultat, statut, erreur){

	       }

	    });

	}

};<|endoftext|>


<commit_before>/**
 * Created by pmeijer on 3/26/2014.
 */
define(['plugin/PluginConfig',
        'plugin/PluginBase',],
    function (PluginConfig, PluginBase) {
    'use strict';

    var ChildrenConfigPlugin = function () {
        // Call base class's constructor
        PluginBase.call(this);
    };

    ChildrenConfigPlugin.prototype = Object.create(PluginBase.prototype);

    ChildrenConfigPlugin.prototype.constructor = ChildrenConfigPlugin;

    ChildrenConfigPlugin.prototype.getName = function () {
        return "Children Config";
    };

    ChildrenConfigPlugin.prototype.getConfigStructure = function () {
        var configStructure = [
            {
                "name": "logChildrenNames",
                "displayName": "Log Children Names",
                "description": '',
                "value": true, // this is the 'default config'
                "valueType": "boolean",
                "readOnly": true
            },{
                "name": "logLevel",
                "displayName": "Logger level",
                "description": '',
                "value": "info",
                "valueType": "string",
                "valueItems": [
                    "debug",
                    "info",
                    "warn",
                    "error"
                ],
                "readOnly": false
            },{
                "name": "maxChildrenToLog",
                "displayName": "Maximum children to log",
                "description": 'Set this parameter to blabla',
                "value": 4,
                "min": 1,
                "valueType": "number",
                "readOnly": false
            },{
                "name": "whatIsYourName",
                "displayName": "Plugin owner",
                "description": '',
                "readOnly": true,
                "value": 'Patrik',
                "valueType": "string"
            }
        ];

        return configStructure;
    };

    ChildrenConfigPlugin.prototype.main = function (callback) {
        var core = this.core,
            activeNode = this.activeNode,
            self = this;

        // Example how to use FS
        self.fs.addFile('log.txt', 'hello');

        if (!activeNode) {
            callback('activeNode is not defined', this.result);
            return;
        }

        // TODO: check model

        self.logger.info('Current configuration');

        var currentConfig = this.getCurrentConfig();
        self.logger.info(currentConfig.logChildrenNames);
        self.logger.info(currentConfig.logLevel);
        self.logger.info(currentConfig.maxChildrenToLog);
        self.logger.info(currentConfig.whatIsYourName);

        core.loadChildren(activeNode, function (err, childNodes) {
            var i;
            self.logger.info(core.getAttribute(activeNode, 'name') + ' has children');

            for (i = 0; i < childNodes.length; i += 1) {

                self.createMessage(childNodes[i], 'Message text ' + i + ' element');

                self.logger.info('  ' + core.getAttribute(childNodes[i], 'name'));
            }

            if (callback) {
                // TODO: we need a function to set/update success
                self.result.success = true;

                self.fs.addFile('pluginResult.json', JSON.stringify(self.result.serialize()));
                self.fs.saveArtifact();
                callback(null, self.result);
            }
        });
    };

    return ChildrenConfigPlugin;
});
<commit_msg>Update configuration structure.<commit_after>/**
 * Created by pmeijer on 3/26/2014.
 */
define(['plugin/PluginConfig',
        'plugin/PluginBase'],
    function (PluginConfig, PluginBase) {
    'use strict';

    var ChildrenConfigPlugin = function () {
        // Call base class's constructor
        PluginBase.call(this);
    };

    ChildrenConfigPlugin.prototype = Object.create(PluginBase.prototype);

    ChildrenConfigPlugin.prototype.constructor = ChildrenConfigPlugin;

    ChildrenConfigPlugin.prototype.getName = function () {
        return "Children Config";
    };

    ChildrenConfigPlugin.prototype.getConfigStructure = function () {
        var configStructure = [
            {
                "name": "logChildrenNames",
                "displayName": "Log Children Names",
                "description": '',
                "value": true, // this is the 'default config'
                "valueType": "boolean",
                "readOnly": false
            },{
                "name": "logLevel",
                "displayName": "Logger level",
                "description": '',
                "value": "info",
                "valueType": "string",
                "valueItems": [
                    "debug",
                    "info",
                    "warn",
                    "error"
                ],
                "readOnly": false
            },{
                "name": "maxChildrenToLog",
                "displayName": "Maximum children to log",
                "description": 'Set this parameter to blabla',
                "value": 4,
                "minValue": 1,
                "valueType": "number",
                "readOnly": false
            },{
                "name": "whatIsYourName",
                "displayName": "Plugin owner",
                "description": '',
                "readOnly": false,
                "value": 'Patrik',
                "valueType": "string"
            },{
                "name": "itemColor",
                "displayName": "Color",
                "description": 'The color of the item on the screen',
                "readOnly": false,
                "value": '#FF0000',
                "valueType": "string"
            }
        ];

        return configStructure;
    };

    ChildrenConfigPlugin.prototype.main = function (callback) {
        var core = this.core,
            activeNode = this.activeNode,
            self = this;

        // Example how to use FS
        self.fs.addFile('log.txt', 'hello');

        if (!activeNode) {
            callback('activeNode is not defined', this.result);
            return;
        }

        // TODO: check model

        self.logger.info('Current configuration');

        var currentConfig = this.getCurrentConfig();
        self.logger.info(currentConfig.logChildrenNames);
        self.logger.info(currentConfig.logLevel);
        self.logger.info(currentConfig.maxChildrenToLog);
        self.logger.info(currentConfig.whatIsYourName);

        core.loadChildren(activeNode, function (err, childNodes) {
            var i;
            self.logger.info(core.getAttribute(activeNode, 'name') + ' has children');

            for (i = 0; i < childNodes.length; i += 1) {

                self.createMessage(childNodes[i], 'Message text ' + i + ' element');

                self.logger.info('  ' + core.getAttribute(childNodes[i], 'name'));
            }

            if (callback) {
                // TODO: we need a function to set/update success
                self.result.success = true;

                self.fs.addFile('pluginResult.json', JSON.stringify(self.result.serialize()));
                self.fs.saveArtifact();
                callback(null, self.result);
            }
        });
    };

    return ChildrenConfigPlugin;
});
<|endoftext|>


<commit_before>const _ = require('lodash');
const countries = require('../../../config/countries');

module.exports = {
  'what-to-do': {
    legend: {
      value: 'What to you want to do?',
      className: 'visuallyhidden'
    },
    options: [
      {value: 'First', label: 'Apply for a first British passport'},
      {value: 'Change', label: 'Make a change to a current British passport (including a change of name)'},
      {value: 'Renew', label: 'Renew a British passport'},
      {value: 'Replace', label: 'Replace a lost or stolen British passport'}
    ],
    validate: [
      'required',
      {
        type:'equal',
        arguments:['Renew'], /* if the arguments are NOT selected */
        redirect:'https://passportapplication.service.gov.uk/ips-olc/'
      }
    ]
  },
'apply-uk': {
  legend: {
    value: 'Are you applying from the UK?',
    className: 'visuallyhidden'
  },
  options: [
    { value: true, label: 'Yes' },
    { value: false, label: 'No', toggle: 'application-country', child: 'select' }
  ],
  formatter: ['boolean'],
  validate: [
    'required'
  ],
  className: 'inline'
},
'application-country': {
  options: [{ value: '', label: ' ' }].concat(_.map(countries, function (c) {
    return {
      value: c.id,
      label: c.name,
      attributes: [
        {
          attribute: 'data-synonyms', value: Array.isArray(c.altName) ? c.altName.join(',') : c.altName
        }
      ]
    }
  })),
  validate: [
    'required'
  ],
  dependent: {
    field: 'apply-uk',
    value: false
  },
  className: 'typeahead'
},
  'age-day': {
    labelClassName: 'form-label',
    formatter: 'removehyphens',
      validate: [
          'numeric',
          'required'
      ]
  },
  'age-year': {
    labelClassName: 'form-label',
    formatter: 'removehyphens',
      validate: [
          'numeric',
          'required'
      ]
  },
  'age-month': {
      labelClassName: 'form-label',
      formatter: 'removehyphens',
      validate: [
          'numeric',
          'required'
      ]
  }
};
<commit_msg>Redirecting to gov.uk overseas page if a user selects No on the question if they are applying from the UK<commit_after>const _ = require('lodash');
const countries = require('../../../config/countries');

module.exports = {
  'what-to-do': {
    legend: {
      value: 'What to you want to do?',
      className: 'visuallyhidden'
    },
    options: [
      {value: 'First', label: 'Apply for a first British passport'},
      {value: 'Change', label: 'Make a change to a current British passport (including a change of name)'},
      {value: 'Renew', label: 'Renew a British passport'},
      {value: 'Replace', label: 'Replace a lost or stolen British passport'}
    ],
    validate: [
      'required',
      {
        type:'equal',
        arguments:['Renew'], /* if the arguments are NOT selected */
        redirect:'https://passportapplication.service.gov.uk/ips-olc/'
      }
    ]
  },
'apply-uk-temp': {
  legend: {
    value: 'Are you applying from the UK?',
    className: 'visuallyhidden'
  },
  options: [
    {value: 'Yes', label: 'Yes'},
    {value: 'No', label: 'No'}
  ],
  validate: [
    'required',
    {
      type:'equal',
      arguments:['Yes'], /* if Yes is selected */
      redirect:'https://www.gov.uk/overseas-passports'
    }
  ],
  className: 'inline'
},
  'age-day': {
    labelClassName: 'form-label',
    formatter: 'removehyphens',
      validate: [
          'numeric',
          'required'
      ]
  },
  'age-year': {
    labelClassName: 'form-label',
    formatter: 'removehyphens',
      validate: [
          'numeric',
          'required'
      ]
  },
  'age-month': {
      labelClassName: 'form-label',
      formatter: 'removehyphens',
      validate: [
          'numeric',
          'required'
      ]
  }
};
<|endoftext|>