0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/lib/static/main.js

1348 lines
39 KiB
JavaScript
Raw Normal View History

2014-05-07 11:27:51 -05:00
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2014-12-10 01:30:02 -05:00
var templater = require("handlebars/runtime")["default"].template;module.exports = templater({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, lambda=this.lambda;
return "<div class=\"entry\" data-name=\""
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "\" data-version=\""
+ escapeExpression(((helper = (helper = helpers.version || (depth0 != null ? depth0.version : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"version","hash":{},"data":data}) : helper)))
+ "\">\n <div class=\"row\">\n <div class=\"col-md-8 col-sm-8\">\n <h4 class=\"title\">\n <a class='name icon-angle-right red' href='javascript:void(0)'>"
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "</a>\n <small class='version'>v"
+ escapeExpression(((helper = (helper = helpers.version || (depth0 != null ? depth0.version : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"version","hash":{},"data":data}) : helper)))
2014-11-17 13:18:07 -05:00
+ "</small>\n </h4>\n </div>\n <div class=\"col-md-4 col-sm-4\">\n <div class=\"author pull-right\">\n <small>By: "
2014-12-10 01:30:02 -05:00
+ escapeExpression(lambda(((stack1 = (depth0 != null ? depth0._npmUser : depth0)) != null ? stack1.name : stack1), depth0))
+ "</small>\n </div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-md-12\">\n <p class=\"description\">"
+ escapeExpression(((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"description","hash":{},"data":data}) : helper)))
2014-11-17 13:18:07 -05:00
+ "</p>\n </div>\n </div>\n</div>\n";
2014-12-10 01:30:02 -05:00
},"useData":true});
2014-11-04 09:47:03 -05:00
},{"handlebars/runtime":12}],2:[function(require,module,exports){
/* ========================================================================
* Bootstrap: modal.js v3.3.0
* http://getbootstrap.com/javascript/#modals
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// MODAL CLASS DEFINITION
// ======================
var Modal = function (element, options) {
this.options = options
this.$body = $(document.body)
this.$element = $(element)
this.$backdrop =
this.isShown = null
this.scrollbarWidth = 0
if (this.options.remote) {
this.$element
.find('.modal-content')
.load(this.options.remote, $.proxy(function () {
this.$element.trigger('loaded.bs.modal')
}, this))
}
}
Modal.VERSION = '3.3.0'
Modal.TRANSITION_DURATION = 300
Modal.BACKDROP_TRANSITION_DURATION = 150
Modal.DEFAULTS = {
backdrop: true,
keyboard: true,
show: true
}
Modal.prototype.toggle = function (_relatedTarget) {
return this.isShown ? this.hide() : this.show(_relatedTarget)
}
Modal.prototype.show = function (_relatedTarget) {
var that = this
var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
this.$element.trigger(e)
if (this.isShown || e.isDefaultPrevented()) return
this.isShown = true
this.checkScrollbar()
this.$body.addClass('modal-open')
this.setScrollbar()
this.escape()
this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
this.backdrop(function () {
var transition = $.support.transition && that.$element.hasClass('fade')
if (!that.$element.parent().length) {
that.$element.appendTo(that.$body) // don't move modals dom position
}
that.$element
.show()
.scrollTop(0)
if (transition) {
that.$element[0].offsetWidth // force reflow
}
that.$element
.addClass('in')
.attr('aria-hidden', false)
that.enforceFocus()
var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
transition ?
that.$element.find('.modal-dialog') // wait for modal to slide in
.one('bsTransitionEnd', function () {
that.$element.trigger('focus').trigger(e)
})
.emulateTransitionEnd(Modal.TRANSITION_DURATION) :
that.$element.trigger('focus').trigger(e)
})
}
Modal.prototype.hide = function (e) {
if (e) e.preventDefault()
e = $.Event('hide.bs.modal')
this.$element.trigger(e)
if (!this.isShown || e.isDefaultPrevented()) return
this.isShown = false
this.escape()
$(document).off('focusin.bs.modal')
this.$element
.removeClass('in')
.attr('aria-hidden', true)
.off('click.dismiss.bs.modal')
$.support.transition && this.$element.hasClass('fade') ?
this.$element
.one('bsTransitionEnd', $.proxy(this.hideModal, this))
.emulateTransitionEnd(Modal.TRANSITION_DURATION) :
this.hideModal()
}
Modal.prototype.enforceFocus = function () {
$(document)
.off('focusin.bs.modal') // guard against infinite focus loop
.on('focusin.bs.modal', $.proxy(function (e) {
if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
this.$element.trigger('focus')
}
}, this))
}
Modal.prototype.escape = function () {
if (this.isShown && this.options.keyboard) {
this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) {
e.which == 27 && this.hide()
}, this))
} else if (!this.isShown) {
this.$element.off('keydown.dismiss.bs.modal')
}
}
Modal.prototype.hideModal = function () {
var that = this
this.$element.hide()
this.backdrop(function () {
that.$body.removeClass('modal-open')
that.resetScrollbar()
that.$element.trigger('hidden.bs.modal')
})
}
Modal.prototype.removeBackdrop = function () {
this.$backdrop && this.$backdrop.remove()
this.$backdrop = null
}
Modal.prototype.backdrop = function (callback) {
var that = this
var animate = this.$element.hasClass('fade') ? 'fade' : ''
if (this.isShown && this.options.backdrop) {
var doAnimate = $.support.transition && animate
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
.prependTo(this.$element)
.on('click.dismiss.bs.modal', $.proxy(function (e) {
if (e.target !== e.currentTarget) return
this.options.backdrop == 'static'
? this.$element[0].focus.call(this.$element[0])
: this.hide.call(this)
}, this))
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
this.$backdrop.addClass('in')
if (!callback) return
doAnimate ?
this.$backdrop
.one('bsTransitionEnd', callback)
.emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
callback()
} else if (!this.isShown && this.$backdrop) {
this.$backdrop.removeClass('in')
var callbackRemove = function () {
that.removeBackdrop()
callback && callback()
}
$.support.transition && this.$element.hasClass('fade') ?
this.$backdrop
.one('bsTransitionEnd', callbackRemove)
.emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
callbackRemove()
} else if (callback) {
callback()
}
}
Modal.prototype.checkScrollbar = function () {
this.scrollbarWidth = this.measureScrollbar()
}
Modal.prototype.setScrollbar = function () {
var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
}
Modal.prototype.resetScrollbar = function () {
this.$body.css('padding-right', '')
}
Modal.prototype.measureScrollbar = function () { // thx walsh
if (document.body.clientWidth >= window.innerWidth) return 0
var scrollDiv = document.createElement('div')
scrollDiv.className = 'modal-scrollbar-measure'
this.$body.append(scrollDiv)
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
this.$body[0].removeChild(scrollDiv)
return scrollbarWidth
}
// MODAL PLUGIN DEFINITION
// =======================
function Plugin(option, _relatedTarget) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.modal')
var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
if (typeof option == 'string') data[option](_relatedTarget)
else if (options.show) data.show(_relatedTarget)
})
}
var old = $.fn.modal
$.fn.modal = Plugin
$.fn.modal.Constructor = Modal
// MODAL NO CONFLICT
// =================
$.fn.modal.noConflict = function () {
$.fn.modal = old
return this
}
// MODAL DATA-API
// ==============
$(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
var $this = $(this)
var href = $this.attr('href')
var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
if ($this.is('a')) e.preventDefault()
$target.one('show.bs.modal', function (showEvent) {
if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
$target.one('hidden.bs.modal', function () {
$this.is(':visible') && $this.trigger('focus')
})
})
Plugin.call($target, option, this)
})
}(jQuery);
},{}],3:[function(require,module,exports){
2014-11-17 13:18:07 -05:00
var $ = require('unopinionate').selector
var onClick = require('onclick')
var transitionComplete = require('transition-complete')
2014-05-07 14:28:10 -05:00
2014-05-07 14:56:48 -05:00
$(function() {
2014-11-17 13:18:07 -05:00
onClick('.entry .name', function() {
var $this = $(this)
var $entry = $this.closest('.entry')
if ($entry.hasClass('open')) {
// Close entry
$entry
.height($entry.outerHeight())
.removeClass('open')
setTimeout(function() {
$entry.css('height', $entry.attr('data-height') + 'px')
}, 0)
transitionComplete(function() {
$entry.find('.readme').remove()
$entry.css('height', 'auto')
})
} else {
// Open entry
$('.entry.open').each(function() {
// Close open entries
var $entry = $(this)
$entry
.height($entry.outerHeight())
.removeClass('open')
setTimeout(function() {
$entry.css('height', $entry.attr('data-height') + 'px')
}, 0)
transitionComplete(function() {
$entry.find('.readme').remove()
$entry.css('height', 'auto')
})
})
// Add the open class
$entry.addClass('open')
// Explicitly set heights for transitions
var height = $entry.outerHeight()
$entry
.attr('data-height', height)
.css('height', height)
// Get the data
$.ajax({
url: '-/readme/'
+ encodeURIComponent($entry.attr('data-name')) + '/'
+ encodeURIComponent($entry.attr('data-version')),
dataType: 'text',
success: function(html) {
var $readme = $("<div class='readme'>")
.html(html)
.appendTo($entry)
$entry.height(height + $readme.outerHeight())
transitionComplete(function() {
$entry.css('height', 'auto')
})
}
})
}
})
})
2014-05-08 15:41:59 -05:00
2014-11-04 09:47:03 -05:00
},{"onclick":13,"transition-complete":15,"unopinionate":16}],4:[function(require,module,exports){
// twitter bootstrap stuff;
// not in static 'cause I want it to be bundled with the rest of javascripts
require('./bootstrap-modal')
// our own files
require('./search')
require('./entry')
2014-11-17 13:18:07 -05:00
var $ = require('unopinionate').selector
$(document).on('click', '.js-userLogoutBtn', function() {
2014-11-17 13:18:07 -05:00
$('#userLogoutForm').submit()
return false
2014-11-04 09:47:03 -05:00
})
2014-11-17 13:18:07 -05:00
},{"./bootstrap-modal":2,"./entry":3,"./search":5,"unopinionate":16}],5:[function(require,module,exports){
var $ = require('unopinionate').selector
var template = require('../entry.hbs')
var onScroll = require('onscroll')
2014-05-07 13:08:29 -05:00
$(function() {
2014-11-17 13:18:07 -05:00
;(function(window, document) {
var $form = $('#search-form')
var $input = $form.find('input')
var $body = $('body')
var $clear = $form.find('.clear')
var $searchResults = $('#search-results')
var $pkgListing = $('#all-packages')
var $searchBtn = $('.js-search-btn')
var request
var currentResults
var toggle = function(validQuery) {
$searchResults.toggleClass('show', validQuery)
$pkgListing.toggleClass('hide', validQuery)
$searchBtn.find('i').toggleClass('icon-cancel', validQuery)
$searchBtn.find('i').toggleClass('icon-search', !validQuery)
}
2014-05-07 16:51:03 -05:00
2014-11-17 13:18:07 -05:00
$form.bind('submit keyup', function(e) {
var q, qBool
2014-11-17 13:18:07 -05:00
e.preventDefault()
2014-11-17 13:18:07 -05:00
q = $input.val()
qBool = (q !== '')
2014-11-17 13:18:07 -05:00
toggle(qBool)
2014-11-17 13:18:07 -05:00
if (!qBool) {
if (request && typeof request.abort === 'function') {
request.abort()
}
2014-11-17 13:18:07 -05:00
currentResults = null
$searchResults.html('')
return
}
2014-11-17 13:18:07 -05:00
if (request && typeof request.abort === 'function') {
request.abort()
}
2014-05-07 13:08:29 -05:00
2014-11-17 13:18:07 -05:00
if (!currentResults) {
$searchResults.html(
"<img class='search-ajax' src='-/static/ajax.gif' alt='Spinner'/>")
}
2014-05-08 14:47:24 -05:00
2014-11-17 13:18:07 -05:00
request = $.getJSON('-/search/' + q, function( results ) {
currentResults = results
2014-05-08 14:47:24 -05:00
2014-11-17 13:18:07 -05:00
if (results.length > 0) {
var html = ''
2014-05-07 13:08:29 -05:00
2014-11-17 13:18:07 -05:00
$.each(results, function(i, entry) {
html += template(entry)
})
2014-05-07 13:08:29 -05:00
2014-11-17 13:18:07 -05:00
$searchResults.html(html)
} else {
$searchResults.html(
"<div class='no-results'><big>No Results</big></div>")
}
})
})
2014-05-07 13:26:44 -05:00
2014-11-17 13:18:07 -05:00
$(document).on('click', '.icon-cancel', function(e) {
e.preventDefault()
$input.val('')
$form.keyup()
})
2014-11-17 13:18:07 -05:00
})(window, window.document)
})
2014-05-07 13:08:29 -05:00
2014-11-04 09:47:03 -05:00
},{"../entry.hbs":1,"onscroll":14,"unopinionate":16}],6:[function(require,module,exports){
2014-05-07 13:08:29 -05:00
"use strict";
/*globals Handlebars: true */
var base = require("./handlebars/base");
// Each of these augment the Handlebars object. No need to setup here.
// (This is done to easily share code between commonjs and browse envs)
var SafeString = require("./handlebars/safe-string")["default"];
var Exception = require("./handlebars/exception")["default"];
var Utils = require("./handlebars/utils");
var runtime = require("./handlebars/runtime");
// For compatibility and usage outside of module systems, make the Handlebars object a namespace
var create = function() {
var hb = new base.HandlebarsEnvironment();
Utils.extend(hb, base);
hb.SafeString = SafeString;
hb.Exception = Exception;
hb.Utils = Utils;
2014-12-10 01:30:02 -05:00
hb.escapeExpression = Utils.escapeExpression;
2014-05-07 13:08:29 -05:00
hb.VM = runtime;
hb.template = function(spec) {
return runtime.template(spec, hb);
};
return hb;
};
var Handlebars = create();
Handlebars.create = create;
2014-12-10 01:30:02 -05:00
Handlebars['default'] = Handlebars;
2014-05-07 13:08:29 -05:00
exports["default"] = Handlebars;
2014-11-04 09:47:03 -05:00
},{"./handlebars/base":7,"./handlebars/exception":8,"./handlebars/runtime":9,"./handlebars/safe-string":10,"./handlebars/utils":11}],7:[function(require,module,exports){
2014-05-07 13:08:29 -05:00
"use strict";
var Utils = require("./utils");
var Exception = require("./exception")["default"];
2014-12-10 01:30:02 -05:00
var VERSION = "2.0.0";
exports.VERSION = VERSION;var COMPILER_REVISION = 6;
2014-05-07 13:08:29 -05:00
exports.COMPILER_REVISION = COMPILER_REVISION;
var REVISION_CHANGES = {
1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it
2: '== 1.0.0-rc.3',
3: '== 1.0.0-rc.4',
2014-12-10 01:30:02 -05:00
4: '== 1.x.x',
5: '== 2.0.0-alpha.x',
6: '>= 2.0.0-beta.1'
2014-05-07 13:08:29 -05:00
};
exports.REVISION_CHANGES = REVISION_CHANGES;
var isArray = Utils.isArray,
isFunction = Utils.isFunction,
toString = Utils.toString,
objectType = '[object Object]';
function HandlebarsEnvironment(helpers, partials) {
this.helpers = helpers || {};
this.partials = partials || {};
registerDefaultHelpers(this);
}
exports.HandlebarsEnvironment = HandlebarsEnvironment;HandlebarsEnvironment.prototype = {
constructor: HandlebarsEnvironment,
logger: logger,
log: log,
2014-12-10 01:30:02 -05:00
registerHelper: function(name, fn) {
2014-05-07 13:08:29 -05:00
if (toString.call(name) === objectType) {
2014-12-10 01:30:02 -05:00
if (fn) { throw new Exception('Arg not supported with multiple helpers'); }
2014-05-07 13:08:29 -05:00
Utils.extend(this.helpers, name);
} else {
this.helpers[name] = fn;
}
},
2014-12-10 01:30:02 -05:00
unregisterHelper: function(name) {
delete this.helpers[name];
},
2014-05-07 13:08:29 -05:00
2014-12-10 01:30:02 -05:00
registerPartial: function(name, partial) {
2014-05-07 13:08:29 -05:00
if (toString.call(name) === objectType) {
Utils.extend(this.partials, name);
} else {
2014-12-10 01:30:02 -05:00
this.partials[name] = partial;
2014-05-07 13:08:29 -05:00
}
2014-12-10 01:30:02 -05:00
},
unregisterPartial: function(name) {
delete this.partials[name];
2014-05-07 13:08:29 -05:00
}
};
function registerDefaultHelpers(instance) {
2014-12-10 01:30:02 -05:00
instance.registerHelper('helperMissing', function(/* [args, ]options */) {
if(arguments.length === 1) {
// A missing field in a {{foo}} constuct.
2014-05-07 13:08:29 -05:00
return undefined;
} else {
2014-12-10 01:30:02 -05:00
// Someone is actually trying to call something, blow up.
throw new Exception("Missing helper: '" + arguments[arguments.length-1].name + "'");
2014-05-07 13:08:29 -05:00
}
});
instance.registerHelper('blockHelperMissing', function(context, options) {
2014-12-10 01:30:02 -05:00
var inverse = options.inverse,
fn = options.fn;
2014-05-07 13:08:29 -05:00
if(context === true) {
return fn(this);
} else if(context === false || context == null) {
return inverse(this);
} else if (isArray(context)) {
if(context.length > 0) {
2014-12-10 01:30:02 -05:00
if (options.ids) {
options.ids = [options.name];
}
2014-05-07 13:08:29 -05:00
return instance.helpers.each(context, options);
} else {
return inverse(this);
}
} else {
2014-12-10 01:30:02 -05:00
if (options.data && options.ids) {
var data = createFrame(options.data);
data.contextPath = Utils.appendContextPath(options.data.contextPath, options.name);
options = {data: data};
}
return fn(context, options);
2014-05-07 13:08:29 -05:00
}
});
instance.registerHelper('each', function(context, options) {
2014-12-10 01:30:02 -05:00
if (!options) {
throw new Exception('Must pass iterator to #each');
}
2014-05-07 13:08:29 -05:00
var fn = options.fn, inverse = options.inverse;
var i = 0, ret = "", data;
2014-12-10 01:30:02 -05:00
var contextPath;
if (options.data && options.ids) {
contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]) + '.';
}
2014-05-07 13:08:29 -05:00
if (isFunction(context)) { context = context.call(this); }
if (options.data) {
data = createFrame(options.data);
}
if(context && typeof context === 'object') {
if (isArray(context)) {
for(var j = context.length; i<j; i++) {
if (data) {
data.index = i;
data.first = (i === 0);
data.last = (i === (context.length-1));
2014-12-10 01:30:02 -05:00
if (contextPath) {
data.contextPath = contextPath + i;
}
2014-05-07 13:08:29 -05:00
}
ret = ret + fn(context[i], { data: data });
}
} else {
for(var key in context) {
if(context.hasOwnProperty(key)) {
2014-12-10 01:30:02 -05:00
if(data) {
data.key = key;
2014-05-07 13:08:29 -05:00
data.index = i;
data.first = (i === 0);
2014-12-10 01:30:02 -05:00
if (contextPath) {
data.contextPath = contextPath + key;
}
2014-05-07 13:08:29 -05:00
}
ret = ret + fn(context[key], {data: data});
i++;
}
}
}
}
if(i === 0){
ret = inverse(this);
}
return ret;
});
instance.registerHelper('if', function(conditional, options) {
if (isFunction(conditional)) { conditional = conditional.call(this); }
// Default behavior is to render the positive path if the value is truthy and not empty.
// The `includeZero` option may be set to treat the condtional as purely not empty based on the
// behavior of isEmpty. Effectively this determines if 0 is handled by the positive path or negative.
if ((!options.hash.includeZero && !conditional) || Utils.isEmpty(conditional)) {
return options.inverse(this);
} else {
return options.fn(this);
}
});
instance.registerHelper('unless', function(conditional, options) {
return instance.helpers['if'].call(this, conditional, {fn: options.inverse, inverse: options.fn, hash: options.hash});
});
instance.registerHelper('with', function(context, options) {
if (isFunction(context)) { context = context.call(this); }
2014-12-10 01:30:02 -05:00
var fn = options.fn;
if (!Utils.isEmpty(context)) {
if (options.data && options.ids) {
var data = createFrame(options.data);
data.contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]);
options = {data:data};
}
return fn(context, options);
} else {
return options.inverse(this);
}
2014-05-07 13:08:29 -05:00
});
2014-12-10 01:30:02 -05:00
instance.registerHelper('log', function(message, options) {
2014-05-07 13:08:29 -05:00
var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;
2014-12-10 01:30:02 -05:00
instance.log(level, message);
});
instance.registerHelper('lookup', function(obj, field) {
return obj && obj[field];
2014-05-07 13:08:29 -05:00
});
}
var logger = {
methodMap: { 0: 'debug', 1: 'info', 2: 'warn', 3: 'error' },
// State enum
DEBUG: 0,
INFO: 1,
WARN: 2,
ERROR: 3,
level: 3,
// can be overridden in the host environment
2014-12-10 01:30:02 -05:00
log: function(level, message) {
2014-05-07 13:08:29 -05:00
if (logger.level <= level) {
var method = logger.methodMap[level];
if (typeof console !== 'undefined' && console[method]) {
2014-12-10 01:30:02 -05:00
console[method].call(console, message);
2014-05-07 13:08:29 -05:00
}
}
}
};
exports.logger = logger;
2014-12-10 01:30:02 -05:00
var log = logger.log;
exports.log = log;
var createFrame = function(object) {
var frame = Utils.extend({}, object);
frame._parent = object;
return frame;
2014-05-07 13:08:29 -05:00
};
exports.createFrame = createFrame;
2014-11-04 09:47:03 -05:00
},{"./exception":8,"./utils":11}],8:[function(require,module,exports){
2014-05-07 13:08:29 -05:00
"use strict";
var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
function Exception(message, node) {
var line;
if (node && node.firstLine) {
line = node.firstLine;
message += ' - ' + line + ':' + node.firstColumn;
}
var tmp = Error.prototype.constructor.call(this, message);
// Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
for (var idx = 0; idx < errorProps.length; idx++) {
this[errorProps[idx]] = tmp[errorProps[idx]];
}
if (line) {
this.lineNumber = line;
this.column = node.firstColumn;
}
}
Exception.prototype = new Error();
exports["default"] = Exception;
2014-11-04 09:47:03 -05:00
},{}],9:[function(require,module,exports){
2014-05-07 13:08:29 -05:00
"use strict";
var Utils = require("./utils");
var Exception = require("./exception")["default"];
var COMPILER_REVISION = require("./base").COMPILER_REVISION;
var REVISION_CHANGES = require("./base").REVISION_CHANGES;
2014-12-10 01:30:02 -05:00
var createFrame = require("./base").createFrame;
2014-05-07 13:08:29 -05:00
function checkRevision(compilerInfo) {
var compilerRevision = compilerInfo && compilerInfo[0] || 1,
currentRevision = COMPILER_REVISION;
if (compilerRevision !== currentRevision) {
if (compilerRevision < currentRevision) {
var runtimeVersions = REVISION_CHANGES[currentRevision],
compilerVersions = REVISION_CHANGES[compilerRevision];
throw new Exception("Template was precompiled with an older version of Handlebars than the current runtime. "+
"Please update your precompiler to a newer version ("+runtimeVersions+") or downgrade your runtime to an older version ("+compilerVersions+").");
} else {
// Use the embedded version info since the runtime doesn't know about this revision yet
throw new Exception("Template was precompiled with a newer version of Handlebars than the current runtime. "+
"Please update your runtime to a newer version ("+compilerInfo[1]+").");
}
}
}
exports.checkRevision = checkRevision;// TODO: Remove this line and break up compilePartial
function template(templateSpec, env) {
2014-12-10 01:30:02 -05:00
/* istanbul ignore next */
2014-05-07 13:08:29 -05:00
if (!env) {
throw new Exception("No environment passed to template");
}
2014-12-10 01:30:02 -05:00
if (!templateSpec || !templateSpec.main) {
throw new Exception('Unknown template object: ' + typeof templateSpec);
}
2014-05-07 13:08:29 -05:00
// Note: Using env.VM references rather than local var references throughout this section to allow
// for external users to override these as psuedo-supported APIs.
2014-12-10 01:30:02 -05:00
env.VM.checkRevision(templateSpec.compiler);
var invokePartialWrapper = function(partial, indent, name, context, hash, helpers, partials, data, depths) {
if (hash) {
context = Utils.extend({}, context, hash);
}
var result = env.VM.invokePartial.call(this, partial, name, context, helpers, partials, data, depths);
if (result == null && env.compile) {
var options = { helpers: helpers, partials: partials, data: data, depths: depths };
partials[name] = env.compile(partial, { data: data !== undefined, compat: templateSpec.compat }, env);
result = partials[name](context, options);
}
if (result != null) {
if (indent) {
var lines = result.split('\n');
for (var i = 0, l = lines.length; i < l; i++) {
if (!lines[i] && i + 1 === l) {
break;
}
lines[i] = indent + lines[i];
}
result = lines.join('\n');
}
return result;
2014-05-07 13:08:29 -05:00
} else {
throw new Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
}
};
// Just add water
var container = {
2014-12-10 01:30:02 -05:00
lookup: function(depths, name) {
var len = depths.length;
for (var i = 0; i < len; i++) {
if (depths[i] && depths[i][name] != null) {
return depths[i][name];
}
}
},
lambda: function(current, context) {
return typeof current === 'function' ? current.call(context) : current;
},
2014-05-07 13:08:29 -05:00
escapeExpression: Utils.escapeExpression,
invokePartial: invokePartialWrapper,
2014-12-10 01:30:02 -05:00
fn: function(i) {
return templateSpec[i];
},
2014-05-07 13:08:29 -05:00
programs: [],
2014-12-10 01:30:02 -05:00
program: function(i, data, depths) {
var programWrapper = this.programs[i],
fn = this.fn(i);
if (data || depths) {
programWrapper = program(this, i, fn, data, depths);
2014-05-07 13:08:29 -05:00
} else if (!programWrapper) {
2014-12-10 01:30:02 -05:00
programWrapper = this.programs[i] = program(this, i, fn);
2014-05-07 13:08:29 -05:00
}
return programWrapper;
},
2014-12-10 01:30:02 -05:00
data: function(data, depth) {
while (data && depth--) {
data = data._parent;
}
return data;
},
2014-05-07 13:08:29 -05:00
merge: function(param, common) {
var ret = param || common;
if (param && common && (param !== common)) {
2014-12-10 01:30:02 -05:00
ret = Utils.extend({}, common, param);
2014-05-07 13:08:29 -05:00
}
2014-12-10 01:30:02 -05:00
2014-05-07 13:08:29 -05:00
return ret;
},
2014-12-10 01:30:02 -05:00
2014-05-07 13:08:29 -05:00
noop: env.VM.noop,
2014-12-10 01:30:02 -05:00
compilerInfo: templateSpec.compiler
2014-05-07 13:08:29 -05:00
};
2014-12-10 01:30:02 -05:00
var ret = function(context, options) {
2014-05-07 13:08:29 -05:00
options = options || {};
2014-12-10 01:30:02 -05:00
var data = options.data;
2014-05-07 13:08:29 -05:00
2014-12-10 01:30:02 -05:00
ret._setup(options);
if (!options.partial && templateSpec.useData) {
data = initData(context, data);
2014-05-07 13:08:29 -05:00
}
2014-12-10 01:30:02 -05:00
var depths;
if (templateSpec.useDepths) {
depths = options.depths ? [context].concat(options.depths) : [context];
2014-05-07 13:08:29 -05:00
}
2014-12-10 01:30:02 -05:00
return templateSpec.main.call(container, context, container.helpers, container.partials, data, depths);
2014-05-07 13:08:29 -05:00
};
2014-12-10 01:30:02 -05:00
ret.isTop = true;
2014-05-07 13:08:29 -05:00
2014-12-10 01:30:02 -05:00
ret._setup = function(options) {
if (!options.partial) {
container.helpers = container.merge(options.helpers, env.helpers);
2014-05-07 13:08:29 -05:00
2014-12-10 01:30:02 -05:00
if (templateSpec.usePartial) {
container.partials = container.merge(options.partials, env.partials);
}
} else {
container.helpers = options.helpers;
container.partials = options.partials;
}
};
ret._child = function(i, data, depths) {
if (templateSpec.useDepths && !depths) {
throw new Exception('must pass parent depths');
}
2014-05-07 13:08:29 -05:00
2014-12-10 01:30:02 -05:00
return program(container, i, templateSpec[i], data, depths);
2014-05-07 13:08:29 -05:00
};
2014-12-10 01:30:02 -05:00
return ret;
2014-05-07 13:08:29 -05:00
}
2014-12-10 01:30:02 -05:00
exports.template = template;function program(container, i, fn, data, depths) {
2014-05-07 13:08:29 -05:00
var prog = function(context, options) {
options = options || {};
2014-12-10 01:30:02 -05:00
return fn.call(container, context, container.helpers, container.partials, options.data || data, depths && [context].concat(depths));
2014-05-07 13:08:29 -05:00
};
prog.program = i;
2014-12-10 01:30:02 -05:00
prog.depth = depths ? depths.length : 0;
2014-05-07 13:08:29 -05:00
return prog;
}
2014-12-10 01:30:02 -05:00
exports.program = program;function invokePartial(partial, name, context, helpers, partials, data, depths) {
var options = { partial: true, helpers: helpers, partials: partials, data: data, depths: depths };
2014-05-07 13:08:29 -05:00
if(partial === undefined) {
throw new Exception("The partial " + name + " could not be found");
} else if(partial instanceof Function) {
return partial(context, options);
}
}
exports.invokePartial = invokePartial;function noop() { return ""; }
2014-12-10 01:30:02 -05:00
exports.noop = noop;function initData(context, data) {
if (!data || !('root' in data)) {
data = data ? createFrame(data) : {};
data.root = context;
}
return data;
}
2014-11-04 09:47:03 -05:00
},{"./base":7,"./exception":8,"./utils":11}],10:[function(require,module,exports){
2014-05-07 13:08:29 -05:00
"use strict";
// Build out our basic SafeString type
function SafeString(string) {
this.string = string;
}
SafeString.prototype.toString = function() {
return "" + this.string;
};
exports["default"] = SafeString;
2014-11-04 09:47:03 -05:00
},{}],11:[function(require,module,exports){
2014-05-07 13:08:29 -05:00
"use strict";
/*jshint -W004 */
var SafeString = require("./safe-string")["default"];
var escape = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': "&quot;",
"'": "&#x27;",
"`": "&#x60;"
};
var badChars = /[&<>"'`]/g;
var possible = /[&<>"'`]/;
function escapeChar(chr) {
2014-12-10 01:30:02 -05:00
return escape[chr];
2014-05-07 13:08:29 -05:00
}
2014-12-10 01:30:02 -05:00
function extend(obj /* , ...source */) {
for (var i = 1; i < arguments.length; i++) {
for (var key in arguments[i]) {
if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
obj[key] = arguments[i][key];
}
2014-05-07 13:08:29 -05:00
}
}
2014-12-10 01:30:02 -05:00
return obj;
2014-05-07 13:08:29 -05:00
}
exports.extend = extend;var toString = Object.prototype.toString;
exports.toString = toString;
// Sourced from lodash
// https://github.com/bestiejs/lodash/blob/master/LICENSE.txt
var isFunction = function(value) {
return typeof value === 'function';
};
// fallback for older versions of Chrome and Safari
2014-12-10 01:30:02 -05:00
/* istanbul ignore next */
2014-05-07 13:08:29 -05:00
if (isFunction(/x/)) {
isFunction = function(value) {
return typeof value === 'function' && toString.call(value) === '[object Function]';
};
}
var isFunction;
exports.isFunction = isFunction;
2014-12-10 01:30:02 -05:00
/* istanbul ignore next */
2014-05-07 13:08:29 -05:00
var isArray = Array.isArray || function(value) {
return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;
};
exports.isArray = isArray;
function escapeExpression(string) {
// don't escape SafeStrings, since they're already safe
if (string instanceof SafeString) {
return string.toString();
2014-12-10 01:30:02 -05:00
} else if (string == null) {
2014-05-07 13:08:29 -05:00
return "";
2014-12-10 01:30:02 -05:00
} else if (!string) {
return string + '';
2014-05-07 13:08:29 -05:00
}
// Force a string conversion as this will be done by the append regardless and
// the regex test will do this transparently behind the scenes, causing issues if
// an object's to string has escaped characters in it.
string = "" + string;
if(!possible.test(string)) { return string; }
return string.replace(badChars, escapeChar);
}
exports.escapeExpression = escapeExpression;function isEmpty(value) {
if (!value && value !== 0) {
return true;
} else if (isArray(value) && value.length === 0) {
return true;
} else {
return false;
}
}
2014-12-10 01:30:02 -05:00
exports.isEmpty = isEmpty;function appendContextPath(contextPath, id) {
return (contextPath ? contextPath + '.' : '') + id;
}
exports.appendContextPath = appendContextPath;
2014-11-04 09:47:03 -05:00
},{"./safe-string":10}],12:[function(require,module,exports){
2014-05-07 13:08:29 -05:00
// Create a simple path alias to allow browserify to resolve
// the runtime on a supported path.
module.exports = require('./dist/cjs/handlebars.runtime');
2014-11-04 09:47:03 -05:00
},{"./dist/cjs/handlebars.runtime":6}],13:[function(require,module,exports){
2014-05-07 14:56:48 -05:00
var $ = require('unopinionate').selector;
var $document = $(document),
bindings = {};
var click = function(events) {
click.bind.apply(click, arguments);
return click;
};
/*** Configuration Options ***/
click.distanceLimit = 10;
click.timeLimit = 140;
/*** Useful Properties ***/
click.isTouch = ('ontouchstart' in window) ||
window.DocumentTouch &&
document instanceof DocumentTouch;
/*** Cached Functions ***/
var onTouchstart = function(e) {
e.stopPropagation(); //Prevents multiple click events from happening
click._doAnywheres(e);
var $this = $(this),
startTime = new Date().getTime(),
startPos = click._getPos(e);
$this.one('touchend', function(e) {
e.preventDefault(); //Prevents click event from firing
var time = new Date().getTime() - startTime,
endPos = click._getPos(e),
distance = Math.sqrt(
Math.pow(endPos.x - startPos.x, 2) +
Math.pow(endPos.y - startPos.y, 2)
);
if(time < click.timeLimit && distance < click.distanceLimit) {
//Find the correct callback
$.each(bindings, function(selector, callback) {
if($this.is(selector)) {
callback.apply(e.target, [e]);
return false;
}
});
}
});
};
/*** API ***/
click.bind = function(events) {
//Argument Surgery
if(!$.isPlainObject(events)) {
newEvents = {};
newEvents[arguments[0]] = arguments[1];
events = newEvents;
}
$.each(events, function(selector, callback) {
/*** Register Binding ***/
if(typeof bindings[selector] != 'undefined') {
click.unbind(selector); //Ensure no duplicates
}
bindings[selector] = callback;
/*** Touch Support ***/
if(click.isTouch) {
$document.delegate(selector, 'touchstart', onTouchstart);
}
/*** Mouse Support ***/
$document.delegate(selector, 'click', function(e) {
e.stopPropagation(); //Prevents multiple click events from happening
//click._doAnywheres(e); //Do anywheres first to be consistent with touch order
callback.apply(this, [e]);
});
});
return this;
};
click.unbind = function(selector) {
$document
.undelegate(selector, 'touchstart')
.undelegate(selector, 'click');
delete bindings[selector];
return this;
};
click.unbindAll = function() {
$.each(bindings, function(selector, callback) {
$document
.undelegate(selector, 'touchstart')
.undelegate(selector, 'click');
});
bindings = {};
return this;
};
click.trigger = function(selector, e) {
e = e || $.Event('click');
if(typeof bindings[selector] != 'undefined') {
bindings[selector](e);
}
else {
console.error("No click events bound for selector '"+selector+"'.");
}
return this;
};
click.anywhere = function(callback) {
click._anywheres.push(callback);
return this;
};
/*** Internal (but useful) Methods ***/
click._getPos = function(e) {
e = e.originalEvent;
if(e.pageX || e.pageY) {
return {
x: e.pageX,
y: e.pageY
};
}
else if(e.changedTouches) {
return {
x: e.changedTouches[0].clientX,
y: e.changedTouches[0].clientY
};
}
else {
return {
x: e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft,
y: e.clientY + document.body.scrollTop + document.documentElement.scrollTop
};
}
};
click._anywheres = [];
click._doAnywheres = function(e) {
var i = click._anywheres.length;
while(i--) {
click._anywheres[i](e);
}
};
$(document).bind('mousedown', click._doAnywheres);
module.exports = click;
2014-11-04 09:47:03 -05:00
},{"unopinionate":16}],14:[function(require,module,exports){
2014-05-08 15:41:59 -05:00
var $ = require('unopinionate').selector;
var bodyScrollers = [];
$(function() {
var $html = $('html'),
$body = $('body');
$(window, document, 'body').bind('scroll touchmove', function() {
var top = $html[0].scrollTop || $body[0].scrollTop;
for(var i=0; i<bodyScrollers.length; i++) {
bodyScrollers[i](top);
}
});
});
var onScroll = function(callback) {
bodyScrollers.push(callback);
};
module.exports = onScroll;
2014-11-04 09:47:03 -05:00
},{"unopinionate":16}],15:[function(require,module,exports){
2014-05-07 16:51:03 -05:00
(function(root) {
var callbacks = [];
var transitionComplete = function(callback) {
if(callbacks.length === 0) {
setEvent();
}
callbacks.push(callback);
};
function setEvent() {
document.addEventListener(eventName(), function() {
var i = callbacks.length;
while(i--) {
callbacks[i]();
}
callbacks = [];
});
}
var _eventName;
function eventName() {
if(!_eventName) {
// Sourced from: http://stackoverflow.com/questions/5023514/how-do-i-normalize-css3-transition-functions-across-browsers
var el = document.createElement('fakeelement');
transitions = {
transition: 'transitionend',
OTransition: 'oTransitionEnd',
MozTransition: 'transitionend',
WebkitTransition: 'webkitTransitionEnd'
};
for(var t in transitions) {
if(el.style[t] !== undefined) {
_eventName = transitions[t];
}
}
}
return _eventName;
}
/*** Export ***/
// AMD
if(typeof define === 'function' && define.amd) {
define([], function() {
return transitionComplete;
});
}
// CommonJS
else if(typeof exports !== 'undefined') {
module.exports = transitionComplete;
}
// Browser Global
else {
root.transitionComplete = transitionComplete;
}
})(this);
2014-11-04 09:47:03 -05:00
},{}],16:[function(require,module,exports){
2014-05-07 13:08:29 -05:00
(function (global){
(function(root) {
var unopinionate = {
selector: root.jQuery || root.Zepto || root.ender || root.$,
template: root.Handlebars || root.Mustache
};
/*** Export ***/
//AMD
if(typeof define === 'function' && define.amd) {
define([], function() {
return unopinionate;
});
}
//CommonJS
else if(typeof module.exports !== 'undefined') {
module.exports = unopinionate;
}
//Global
else {
root.unopinionate = unopinionate;
}
})(typeof window != 'undefined' ? window : global);
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
2014-11-04 09:47:03 -05:00
},{}]},{},[4]);