Made eslint using 'browser' environment and added globals, because RainLoop is used in browsers.

This also allowed to remove all webpack 'externals' overhead.
This commit is contained in:
djmaze 2020-08-12 00:25:36 +02:00
parent c3a213802d
commit e7180a86ce
81 changed files with 1857 additions and 1259 deletions

View file

@ -1,6 +1,8 @@
/* ============================================================
* bootstrap-dropdown.js v2.3.2
* http://getbootstrap.com/2.3.2/javascript.html#dropdowns
* bootstrap-modal.js v2.3.2
* bootstrap-tab.js v2.3.2
* http://getbootstrap.com/2.3.2/javascript.html
* ============================================================
* Copyright 2013 Twitter, Inc.
*
@ -17,28 +19,25 @@
* limitations under the License.
* ============================================================ */
!function ($) {
($ => {
"use strict"; // jshint ;_;
const doc = document;
/* DROPDOWN CLASS DEFINITION
* ========================= */
var toggle = '[data-toggle=dropdown]'
, Dropdown = function (element) {
var $el = $(element).on('click.dropdown.data-api', this.toggle)
$('html').on('click.dropdown.data-api', function () {
$el.parent().removeClass('open')
})
}
var toggle = '[data-toggle=dropdown]';
Dropdown.prototype = {
class Dropdown {
constructor: Dropdown
constructor (element) {
var $el = $(element).on('click.dropdown.data-api', this.toggle)
$('html').on('click.dropdown.data-api', () => $el.parent().removeClass('open'))
}
, toggle: function (e) {
toggle () {
var $this = $(this)
, $parent
, isActive
@ -52,7 +51,7 @@
clearMenus()
if (!isActive) {
if ('ontouchstart' in document.documentElement) {
if ('ontouchstart' in doc.documentElement) {
// if mobile we we use a backdrop because click events don't delegate
$('<div class="dropdown-backdrop"/>').insertBefore($(this)).on('click', clearMenus)
}
@ -64,10 +63,9 @@
return false
}
, keydown: function (e) {
keydown (e) {
var $this
, $items
, $active
, $parent
, isActive
, index
@ -134,8 +132,6 @@
/* DROPDOWN PLUGIN DEFINITION
* ========================== */
var old = $.fn.dropdown
$.fn.dropdown = function (option) {
return this.each(function () {
var $this = $(this)
@ -145,218 +141,182 @@
})
}
$.fn.dropdown.Constructor = Dropdown
/* APPLY TO STANDARD DROPDOWN ELEMENTS
* =================================== */
$(document)
$(doc)
.on('click.dropdown.data-api', clearMenus)
.on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
.on('click.dropdown.data-api', '.dropdown form', e => e.stopPropagation())
.on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
.on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
}(window.jQuery);
/* =========================================================
* bootstrap-modal.js v2.3.2
* http://getbootstrap.com/2.3.2/javascript.html#modals
* =========================================================
* Copyright 2013 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================= */
!function ($) {
"use strict"; // jshint ;_;
/* MODAL CLASS DEFINITION
* ====================== */
var Modal = function (element, options) {
this.options = options
this.$element = $(element)
.on('click.dismiss.modal', '[data-dismiss="modal"]', this.hide.bind(this))
this.options.remote && this.$element.find('.modal-body').on('load', this.options.remote)
}
class Modal {
Modal.prototype = {
constructor (element, options) {
this.options = options
this.$element = $(element)
.on('click.dismiss.modal', '[data-dismiss="modal"]', this.hide.bind(this))
this.options.remote && this.$element.find('.modal-body').on('load', this.options.remote)
}
constructor: Modal
toggle () {
return this[!this.isShown ? 'show' : 'hide']()
}
, toggle: function () {
return this[!this.isShown ? 'show' : 'hide']()
}
show () {
var that = this
, e = $.Event('show')
, show: function () {
var that = this
, e = $.Event('show')
this.$element.trigger(e)
this.$element.trigger(e)
if (this.isShown || e.isDefaultPrevented()) return
if (this.isShown || e.isDefaultPrevented()) return
this.isShown = true
this.isShown = true
this.escape()
this.escape()
this.backdrop(() => {
var transition = that.$element.hasClass('fade')
this.backdrop(function () {
var transition = that.$element.hasClass('fade')
if (!that.$element.parent().length) {
that.$element.appendTo(document.body) //don't move modals dom position
}
that.$element.show()
if (transition) {
that.$element[0].offsetWidth // force reflow
}
that.$element
.addClass('in')
.attr('aria-hidden', false)
that.enforceFocus()
transition ?
that.$element.one('transitionend', function () { that.$element.focus().trigger('shown') }) :
that.$element.focus().trigger('shown')
})
}
, hide: function (e) {
e && e.preventDefault()
var that = this
e = $.Event('hide')
this.$element.trigger(e)
if (!this.isShown || e.isDefaultPrevented()) return
this.isShown = false
this.escape()
$(document).off('focusin.modal')
this.$element
.removeClass('in')
.attr('aria-hidden', true)
this.$element.hasClass('fade') ?
this.hideWithTransition() :
this.hideModal()
}
, enforceFocus: function () {
var that = this
$(document).on('focusin.modal', function (e) {
if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
that.$element.focus()
}
})
}
, escape: function () {
var that = this
if (this.isShown && this.options.keyboard) {
this.$element.on('keyup.dismiss.modal', function ( e ) {
e.which == 27 && that.hide()
})
} else if (!this.isShown) {
this.$element.off('keyup.dismiss.modal')
if (!that.$element.parent().length) {
that.$element.appendTo(doc.body) //don't move modals dom position
}
}
, hideWithTransition: function () {
var that = this
, timeout = setTimeout(function () {
that.$element.off('transitionend')
that.hideModal()
}, 500)
that.$element.show()
this.$element.one('transitionend', function () {
clearTimeout(timeout)
that.hideModal()
if (transition) {
that.$element[0].offsetWidth // force reflow
}
that.$element
.addClass('in')
.attr('aria-hidden', false)
that.enforceFocus()
transition ?
that.$element.one('transitionend', function () { that.$element.focus().trigger('shown') }) :
that.$element.focus().trigger('shown')
})
}
hide (e) {
e && e.preventDefault()
e = $.Event('hide')
this.$element.trigger(e)
if (!this.isShown || e.isDefaultPrevented()) return
this.isShown = false
this.escape()
$(doc).off('focusin.modal')
this.$element
.removeClass('in')
.attr('aria-hidden', true)
this.$element.hasClass('fade') ?
this.hideWithTransition() :
this.hideModal()
}
enforceFocus () {
var that = this
$(doc).on('focusin.modal', function (e) {
if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
that.$element.focus()
}
})
}
escape () {
var that = this
if (this.isShown && this.options.keyboard) {
this.$element.on('keyup.dismiss.modal', function ( e ) {
e.which == 27 && that.hide()
})
} else if (!this.isShown) {
this.$element.off('keyup.dismiss.modal')
}
}
, hideModal: function () {
var that = this
this.$element.hide()
this.backdrop(function () {
that.removeBackdrop()
that.$element.trigger('hidden')
})
}
hideWithTransition () {
var that = this
, timeout = setTimeout(function () {
that.$element.off('transitionend')
that.hideModal()
}, 500)
, removeBackdrop: function () {
this.$backdrop && this.$backdrop.remove()
this.$backdrop = null
}
this.$element.one('transitionend', function () {
clearTimeout(timeout)
that.hideModal()
})
}
, backdrop: function (callback) {
var that = this
, animate = this.$element.hasClass('fade') ? 'fade' : ''
hideModal () {
var that = this
this.$element.hide()
this.backdrop(function () {
that.removeBackdrop()
that.$element.trigger('hidden')
})
}
if (this.isShown && this.options.backdrop) {
var doAnimate = animate
removeBackdrop () {
this.$backdrop && this.$backdrop.remove()
this.$backdrop = null
}
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
.appendTo(document.body)
backdrop (callback) {
var animate = this.$element.hasClass('fade') ? 'fade' : ''
this.$backdrop.click(
this.options.backdrop == 'static' ?
this.$element[0].focus.bind(this.$element[0])
: this.hide.bind(this)
)
if (this.isShown && this.options.backdrop) {
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
.appendTo(doc.body)
this.$backdrop.addClass('in')
this.$backdrop.click(
this.options.backdrop == 'static' ?
this.$element[0].focus.bind(this.$element[0])
: this.hide.bind(this)
)
if (!callback) return
if (animate) this.$backdrop[0].offsetWidth // force reflow
doAnimate ?
this.$backdrop.one('transitionend', callback) :
callback()
this.$backdrop.addClass('in')
} else if (!this.isShown && this.$backdrop) {
this.$backdrop.removeClass('in')
if (!callback) return
this.$element.hasClass('fade')?
this.$backdrop.one('transitionend', callback) :
callback()
} else if (callback) {
animate ?
this.$backdrop.one('transitionend', callback) :
callback()
}
} else if (!this.isShown && this.$backdrop) {
this.$backdrop.removeClass('in')
this.$element.hasClass('fade')?
this.$backdrop.one('transitionend', callback) :
callback()
} else if (callback) {
callback()
}
}
}
/* MODAL PLUGIN DEFINITION
* ======================= */
var old = $.fn.modal
$.fn.modal = function (option) {
return this.each(function () {
var $this = $(this)
@ -374,13 +334,10 @@
, show: true
}
$.fn.modal.Constructor = Modal
/* MODAL DATA-API
* ============== */
$(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
$(doc).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
var $this = $(this)
, href = $this.attr('href')
, $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
@ -395,85 +352,14 @@
})
})
}(window.jQuery);
/* ========================================================
* bootstrap-tab.js v2.3.2
* http://getbootstrap.com/2.3.2/javascript.html#tabs
* ========================================================
* Copyright 2013 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ======================================================== */
!function ($) {
"use strict"; // jshint ;_;
/* TAB CLASS DEFINITION
* ==================== */
var Tab = function (element) {
this.element = $(element)
}
Tab.prototype = {
constructor: Tab
, show: function () {
var $this = this.element
, $ul = $this.closest('ul:not(.dropdown-menu)')
, selector = $this.attr('data-target')
, previous
, $target
, e
if (!selector) {
selector = $this.attr('href')
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
}
if ( $this.parent('li').hasClass('active') ) return
previous = $ul.find('.active:last a')[0]
e = $.Event('show', {
relatedTarget: previous
})
$this.trigger(e)
if (e.isDefaultPrevented()) return
$target = $(selector)
this.activate($this.parent('li'), $ul)
this.activate($target, $target.parent(), function () {
$this.trigger({
type: 'shown'
, relatedTarget: previous
})
})
}
, activate: function ( element, container, callback) {
var activate = ( element, container, callback) => {
var $active = container.find('> .active')
, transition = callback
&& $active.hasClass('fade')
function next() {
, next = () => {
$active
.removeClass('active')
.find('> .dropdown-menu > .active')
@ -501,14 +387,54 @@
$active.removeClass('in')
}
class Tab {
constructor (element) {
this.element = $(element)
}
show () {
var $this = this.element
, $ul = $this.closest('ul:not(.dropdown-menu)')
, selector = $this.attr('data-target')
, previous
, $target
, e
if (!selector) {
selector = $this.attr('href')
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
}
if ( $this.parent('li').hasClass('active') ) return
previous = $ul.find('.active:last a')[0]
e = $.Event('show', {
relatedTarget: previous
})
$this.trigger(e)
if (e.isDefaultPrevented()) return
$target = $(selector)
activate($this.parent('li'), $ul)
activate($target, $target.parent(), () => {
$this.trigger({
type: 'shown'
, relatedTarget: previous
})
})
}
}
/* TAB PLUGIN DEFINITION
* ===================== */
var old = $.fn.tab
$.fn.tab = function ( option ) {
return this.each(function () {
var $this = $(this)
@ -518,15 +444,12 @@
})
}
$.fn.tab.Constructor = Tab
/* TAB DATA-API
* ============ */
$(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
$(doc).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
e.preventDefault()
$(this).tab('show')
})
}(window.jQuery);
})(window.jQuery);

File diff suppressed because one or more lines are too long

View file

@ -56,7 +56,7 @@ fieldset:1,figcaption:1,figure:1,footer:1,form:1,header:1,hgroup:1,main:1,menu:1
track:1,wbr:1},$inline:b,$list:{dl:1,ol:1,ul:1},$listItem:{dd:1,dt:1,li:1},$nonBodyContent:a({body:1,head:1,html:1},d.head),$nonEditable:{applet:1,audio:1,button:1,embed:1,iframe:1,map:1,object:1,option:1,param:1,script:1,textarea:1,video:1},$object:{applet:1,audio:1,button:1,hr:1,iframe:1,img:1,input:1,object:1,select:1,table:1,textarea:1,video:1},$removeEmpty:{abbr:1,acronym:1,b:1,bdi:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,mark:1,meter:1,output:1,q:1,ruby:1,
s:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,time:1,tt:1,u:1,"var":1},$tabIndex:{a:1,area:1,button:1,input:1,object:1,select:1,textarea:1},$tableContent:{caption:1,col:1,colgroup:1,tbody:1,td:1,tfoot:1,th:1,thead:1,tr:1},$transparent:{a:1,audio:1,canvas:1,del:1,ins:1,map:1,noscript:1,object:1,video:1},$intermediate:{caption:1,colgroup:1,dd:1,dt:1,figcaption:1,legend:1,li:1,optgroup:1,option:1,rp:1,rt:1,summary:1,tbody:1,td:1,tfoot:1,th:1,thead:1,tr:1}});return d}();
CKEDITOR.dom.event=function(a){this.$=a};
CKEDITOR.dom.event.prototype={getKey:function(){return this.$.keyCode||this.$.which},getKeystroke:function(){var a=this.getKey();if(this.$.ctrlKey||this.$.metaKey)a+=CKEDITOR.CTRL;this.$.shiftKey&&(a+=CKEDITOR.SHIFT);this.$.altKey&&(a+=CKEDITOR.ALT);return a},preventDefault:function(a){var d=this.$;d.preventDefault?d.preventDefault():d.returnValue=!1;a&&this.stopPropagation()},stopPropagation:function(){var a=this.$;a.stopPropagation?a.stopPropagation():a.cancelBubble=!0},getTarget:function(){var a=
CKEDITOR.dom.event.prototype={getKey:function(){return this.$.keyCode||this.$.which},getKeystroke:function(){var a=this.getKey();if(this.$.ctrlKey||this.$.metaKey)a+=CKEDITOR.CTRL;this.$.shiftKey&&(a+=CKEDITOR.SHIFT);this.$.altKey&&(a+=CKEDITOR.ALT);return a},preventDefault:function(a){var d=this.$;d.preventDefault();a&&this.stopPropagation()},stopPropagation:function(){var a=this.$;a.stopPropagation()},getTarget:function(){var a=
this.$.target||this.$.srcElement;return a?new CKEDITOR.dom.node(a):null},getPhase:function(){return this.$.eventPhase||2},getPageOffset:function(){var a=this.getTarget().getDocument().$;return{x:this.$.pageX||this.$.clientX+(a.documentElement.scrollLeft||a.body.scrollLeft),y:this.$.pageY||this.$.clientY+(a.documentElement.scrollTop||a.body.scrollTop)}}};CKEDITOR.CTRL=1114112;CKEDITOR.SHIFT=2228224;CKEDITOR.ALT=4456448;CKEDITOR.EVENT_PHASE_CAPTURING=1;CKEDITOR.EVENT_PHASE_AT_TARGET=2;
CKEDITOR.EVENT_PHASE_BUBBLING=3;CKEDITOR.dom.domObject=function(a){a&&(this.$=a)};
CKEDITOR.dom.domObject.prototype=function(){var a=function(a,b){return function(c){"undefined"!=typeof CKEDITOR&&a.fire(b,new CKEDITOR.dom.event(c))}};return{getPrivate:function(){var a;(a=this.getCustomData("_"))||this.setCustomData("_",a={});return a},on:function(d){var b=this.getCustomData("_cke_nativeListeners");b||(b={},this.setCustomData("_cke_nativeListeners",b));b[d]||(b=b[d]=a(this,d),this.$.addEventListener?this.$.addEventListener(d,b,!!CKEDITOR.event.useCapture):this.$.attachEvent&&this.$.attachEvent("on"+
@ -1007,4 +1007,4 @@ c='\x3cscript id\x3d"cke_actscrpt" type\x3d"text/javascript"'+(CKEDITOR.env.ie?'
h&&CKEDITOR.env.ie&&10>CKEDITOR.env.version&&(c+='\x3cscript id\x3d"cke_basetagscrpt"\x3evar baseTag \x3d document.querySelector( "base" );baseTag.href \x3d baseTag.href;\x3c/script\x3e');a=a.replace(/(?=\s*<\/(:?head)>)/,c);this.clearCustomData();this.clearListeners();b.fire("contentDomUnload");var k=this.getDocument();try{k.write(a)}catch(l){setTimeout(function(){k.write(a)},0)}}},getData:function(a){if(a)return this.getHtml();a=this.editor;var f=a.config,b=f.fullPage,c=b&&a.docType,d=b&&a.xmlDeclaration,
e=this.getDocument(),b=b?e.getDocumentElement().getOuterHtml():e.getBody().getHtml();CKEDITOR.env.gecko&&f.enterMode!=CKEDITOR.ENTER_BR&&(b=b.replace(/<br>(?=\s*(:?$|<\/body>))/,""));b=a.dataProcessor.toDataFormat(b);d&&(b=d+"\n"+b);c&&(b=c+"\n"+b);return b},focus:function(){this._.isLoadingData?this._.isPendingFocus=!0:l.baseProto.focus.call(this)},detach:function(){var a=this.editor,f=a.document,b;try{b=a.window.getFrame()}catch(c){}l.baseProto.detach.call(this);this.clearCustomData();f.getDocumentElement().clearCustomData();
CKEDITOR.tools.removeFunction(this._.frameLoadedHandler);b&&b.getParent()?(b.clearCustomData(),(a=b.removeCustomData("onResize"))&&a.removeListener(),b.remove()):CKEDITOR.warn("editor-destroy-iframe")}}})})();CKEDITOR.config.disableObjectResizing=!1;CKEDITOR.config.disableNativeTableHandles=!0;CKEDITOR.config.disableNativeSpellChecker=!0;CKEDITOR.plugins.colordialog={requires:"dialog",init:function(b){var c=new CKEDITOR.dialogCommand("colordialog");c.editorFocus=!1;b.addCommand("colordialog",c);CKEDITOR.dialog.add("colordialog",this.path+"dialogs/colordialog.js");b.getColorFromDialog=function(c,f){var d=function(a){this.removeListener("ok",d);this.removeListener("cancel",d);a="ok"==a.name?this.getValueOf("picker","selectedColor"):null;c.call(f,a)},e=function(a){a.on("ok",d);a.on("cancel",d)};b.execCommand("colordialog");if(b._.storedDialogs&&
b._.storedDialogs.colordialog)e(b._.storedDialogs.colordialog);else CKEDITOR.on("dialogDefinition",function(a){if("colordialog"==a.data.name){var b=a.data.definition;a.removeListener();b.onLoad=CKEDITOR.tools.override(b.onLoad,function(a){return function(){e(this);b.onLoad=a;"function"==typeof a&&a.call(this)}})}})}}};CKEDITOR.plugins.add("colordialog",CKEDITOR.plugins.colordialog);CKEDITOR.config.plugins='dialogui,dialog,about,clipboard,autolink,base64image,basicstyles,bidi,blockquote,button,panelbutton,panel,floatpanel,colorbutton,divarea,enterkey,entities,floatingspace,listblock,richcombo,font,image,lineutils,widgetselection,widget,image2,indent,indentlist,fakeobjects,link,list,maximize,pastebase64,table,quicktable,removeformat,sourcearea,toolbar,undo,wysiwygarea,colordialog';CKEDITOR.config.skin='moono-lisa';(function() {var setIcons = function(icons, strip) {var path = CKEDITOR.getUrl( 'plugins/' + strip );icons = icons.split( ',' );for ( var i = 0; i < icons.length; i++ )CKEDITOR.skin.icons[ icons[ i ] ] = { path: path, offset: -icons[ ++i ], bgsize : icons[ ++i ] };};if (CKEDITOR.env.hidpi) setIcons('about,0,,copy-rtl,24,,copy,48,,cut-rtl,72,,cut,96,,paste-rtl,120,,paste,144,,base64image,168,,bold,192,,italic,216,,strike,240,,subscript,264,,superscript,288,,underline,312,,bidiltr,336,,bidirtl,360,,blockquote,384,,bgcolor,408,,textcolor,432,,image,456,,indent-rtl,480,,indent,504,,outdent-rtl,528,,outdent,552,,anchor-rtl,576,,anchor,600,,link,624,,unlink,648,,bulletedlist-rtl,672,,bulletedlist,696,,numberedlist-rtl,720,,numberedlist,744,,maximize,768,,table,792,,removeformat,816,,source-rtl,840,,source,864,,redo-rtl,888,,redo,912,,undo-rtl,936,,undo,960,','icons_hidpi.png');else setIcons('about,0,auto,copy-rtl,24,auto,copy,48,auto,cut-rtl,72,auto,cut,96,auto,paste-rtl,120,auto,paste,144,auto,base64image,168,auto,bold,192,auto,italic,216,auto,strike,240,auto,subscript,264,auto,superscript,288,auto,underline,312,auto,bidiltr,336,auto,bidirtl,360,auto,blockquote,384,auto,bgcolor,408,auto,textcolor,432,auto,image,456,auto,indent-rtl,480,auto,indent,504,auto,outdent-rtl,528,auto,outdent,552,auto,anchor-rtl,576,auto,anchor,600,auto,link,624,auto,unlink,648,auto,bulletedlist-rtl,672,auto,bulletedlist,696,auto,numberedlist-rtl,720,auto,numberedlist,744,auto,maximize,768,auto,table,792,auto,removeformat,816,auto,source-rtl,840,auto,source,864,auto,redo-rtl,888,auto,redo,912,auto,undo-rtl,936,auto,undo,960,auto','icons.png');})();CKEDITOR.lang.languages={"af":1,"ar":1,"az":1,"bg":1,"bn":1,"bs":1,"ca":1,"cs":1,"cy":1,"da":1,"de":1,"de-ch":1,"el":1,"en":1,"en-au":1,"en-ca":1,"en-gb":1,"eo":1,"es":1,"et":1,"eu":1,"fa":1,"fi":1,"fo":1,"fr":1,"fr-ca":1,"gl":1,"gu":1,"he":1,"hi":1,"hr":1,"hu":1,"id":1,"is":1,"it":1,"ja":1,"ka":1,"km":1,"ko":1,"ku":1,"lt":1,"lv":1,"mk":1,"mn":1,"ms":1,"nb":1,"nl":1,"no":1,"oc":1,"pl":1,"pt":1,"pt-br":1,"ro":1,"ru":1,"si":1,"sk":1,"sl":1,"sq":1,"sr":1,"sr-latn":1,"sv":1,"th":1,"tr":1,"tt":1,"ug":1,"uk":1,"vi":1,"zh":1,"zh-cn":1};}());
b._.storedDialogs.colordialog)e(b._.storedDialogs.colordialog);else CKEDITOR.on("dialogDefinition",function(a){if("colordialog"==a.data.name){var b=a.data.definition;a.removeListener();b.onLoad=CKEDITOR.tools.override(b.onLoad,function(a){return function(){e(this);b.onLoad=a;"function"==typeof a&&a.call(this)}})}})}}};CKEDITOR.plugins.add("colordialog",CKEDITOR.plugins.colordialog);CKEDITOR.config.plugins='dialogui,dialog,about,clipboard,autolink,base64image,basicstyles,bidi,blockquote,button,panelbutton,panel,floatpanel,colorbutton,divarea,enterkey,entities,floatingspace,listblock,richcombo,font,image,lineutils,widgetselection,widget,image2,indent,indentlist,fakeobjects,link,list,maximize,pastebase64,table,quicktable,removeformat,sourcearea,toolbar,undo,wysiwygarea,colordialog';CKEDITOR.config.skin='moono-lisa';(function() {var setIcons = function(icons, strip) {var path = CKEDITOR.getUrl( 'plugins/' + strip );icons = icons.split( ',' );for ( var i = 0; i < icons.length; i++ )CKEDITOR.skin.icons[ icons[ i ] ] = { path: path, offset: -icons[ ++i ], bgsize : icons[ ++i ] };};if (CKEDITOR.env.hidpi) setIcons('about,0,,copy-rtl,24,,copy,48,,cut-rtl,72,,cut,96,,paste-rtl,120,,paste,144,,base64image,168,,bold,192,,italic,216,,strike,240,,subscript,264,,superscript,288,,underline,312,,bidiltr,336,,bidirtl,360,,blockquote,384,,bgcolor,408,,textcolor,432,,image,456,,indent-rtl,480,,indent,504,,outdent-rtl,528,,outdent,552,,anchor-rtl,576,,anchor,600,,link,624,,unlink,648,,bulletedlist-rtl,672,,bulletedlist,696,,numberedlist-rtl,720,,numberedlist,744,,maximize,768,,table,792,,removeformat,816,,source-rtl,840,,source,864,,redo-rtl,888,,redo,912,,undo-rtl,936,,undo,960,','icons_hidpi.png');else setIcons('about,0,auto,copy-rtl,24,auto,copy,48,auto,cut-rtl,72,auto,cut,96,auto,paste-rtl,120,auto,paste,144,auto,base64image,168,auto,bold,192,auto,italic,216,auto,strike,240,auto,subscript,264,auto,superscript,288,auto,underline,312,auto,bidiltr,336,auto,bidirtl,360,auto,blockquote,384,auto,bgcolor,408,auto,textcolor,432,auto,image,456,auto,indent-rtl,480,auto,indent,504,auto,outdent-rtl,528,auto,outdent,552,auto,anchor-rtl,576,auto,anchor,600,auto,link,624,auto,unlink,648,auto,bulletedlist-rtl,672,auto,bulletedlist,696,auto,numberedlist-rtl,720,auto,numberedlist,744,auto,maximize,768,auto,table,792,auto,removeformat,816,auto,source-rtl,840,auto,source,864,auto,redo-rtl,888,auto,redo,912,auto,undo-rtl,936,auto,undo,960,auto','icons.png');})();CKEDITOR.lang.languages={"af":1,"ar":1,"az":1,"bg":1,"bn":1,"bs":1,"ca":1,"cs":1,"cy":1,"da":1,"de":1,"de-ch":1,"el":1,"en":1,"en-au":1,"en-ca":1,"en-gb":1,"eo":1,"es":1,"et":1,"eu":1,"fa":1,"fi":1,"fo":1,"fr":1,"fr-ca":1,"gl":1,"gu":1,"he":1,"hi":1,"hr":1,"hu":1,"id":1,"is":1,"it":1,"ja":1,"ka":1,"km":1,"ko":1,"ku":1,"lt":1,"lv":1,"mk":1,"mn":1,"ms":1,"nb":1,"nl":1,"no":1,"oc":1,"pl":1,"pt":1,"pt-br":1,"ro":1,"ru":1,"si":1,"sk":1,"sl":1,"sq":1,"sr":1,"sr-latn":1,"sv":1,"th":1,"tr":1,"tt":1,"ug":1,"uk":1,"vi":1,"zh":1,"zh-cn":1};}());

617
vendors/jua/jua.js vendored
View file

@ -3,376 +3,301 @@
'use strict';
var
Globals = {},
Utils = {},
iDefLimit = 20,
$ = jQuery;
Globals.iDefLimit = 20;
const
defined = v => undefined !== v;
/**
* @param {*} mValue
* @return {boolean}
*/
Utils.isUndefined = function (mValue)
{
return 'undefined' === typeof mValue;
};
/**
* @param {Object} mObjectFirst
* @param {Object=} mObjectSecond
* @return {Object}
*/
Utils.extend = function (mObjectFirst, mObjectSecond)
{
if (mObjectSecond)
var Utils = {
/**
* @param {*} oParent
* @param {*} oDescendant
*
* @return {boolean}
*/
contains : (oParent, oDescendant) =>
{
for (var sProp in mObjectSecond)
if (oParent && oDescendant)
{
if (mObjectSecond.hasOwnProperty(sProp))
if (oParent === oDescendant)
{
mObjectFirst[sProp] = mObjectSecond[sProp];
return true;
}
if (oParent.contains)
{
return oParent.contains(oDescendant);
}
}
}
return mObjectFirst;
};
/**
* @param {*} oParent
* @param {*} oDescendant
*
* @return {boolean}
*/
Utils.contains = function (oParent, oDescendant)
{
var bResult = false;
if (oParent && oDescendant)
{
if (oParent === oDescendant)
{
bResult = true;
}
else if (oParent.contains)
{
bResult = oParent.contains(oDescendant);
}
else
{
/*jshint bitwise: false*/
bResult = oDescendant.compareDocumentPosition ?
return oDescendant.compareDocumentPosition ?
!!(oDescendant.compareDocumentPosition(oParent) & 8) : false;
/*jshint bitwise: true*/
}
}
return bResult;
};
return false;
},
Utils.mainClearTimeout = function(iTimer)
{
if (0 < iTimer)
mainClearTimeout : iTimer =>
{
clearTimeout(iTimer);
}
iTimer = 0;
};
/**
* @param {Event} oEvent
* @return {?Event}
*/
Utils.getEvent = function(oEvent)
{
oEvent = (oEvent && (oEvent.originalEvent ?
oEvent.originalEvent : oEvent)) || window.event;
return oEvent.dataTransfer ? oEvent : null;
};
/**
* @param {Object} oValues
* @param {string} sKey
* @param {?} mDefault
* @return {?}
*/
Utils.getValue = function (oValues, sKey, mDefault)
{
return (!oValues || !sKey || Utils.isUndefined(oValues[sKey])) ? mDefault : oValues[sKey];
};
/**
* @param {Object} oOwner
* @param {string} sPublicName
* @param {*} mObject
*/
Utils.setValue = function(oOwner, sPublicName, mObject)
{
oOwner[sPublicName] = mObject;
};
/**
* @param {*} aData
* @return {boolean}
*/
Utils.isNonEmptyArray = function (aData)
{
return aData && aData.length && 0 < aData.length ? true : false;
};
/**
* @param {*} mValue
* @return {number}
*/
Utils.pInt = function (mValue)
{
return parseInt(mValue || 0, 10);
};
/**
* @param {Function} fFunction
* @param {Object=} oScope
* @return {Function}
*/
Utils.scopeBind = function (fFunction, oScope)
{
return function () {
return fFunction.apply(Utils.isUndefined(oScope) ? null : oScope,
Array.prototype.slice.call(arguments));
};
};
/**
* @param {number=} iLen
* @return {string}
*/
Utils.fakeMd5 = function (iLen)
{
var
sResult = '',
sLine = '0123456789abcdefghijklmnopqrstuvwxyz'
;
iLen = Utils.isUndefined(iLen) ? 32 : Utils.pInt(iLen);
while (sResult.length < iLen)
{
sResult += sLine.substr(window.Math.round(window.Math.random() * sLine.length), 1);
}
return sResult;
};
/**
* @return {string}
*/
Utils.getNewUid = function ()
{
return 'jua-uid-' + Utils.fakeMd5(16) + '-' + (new window.Date()).getTime().toString();
};
/**
* @param {*} oFile
* @return {Object}
*/
Utils.getDataFromFile = function (oFile)
{
var
sFileName = Utils.isUndefined(oFile.fileName) ? (Utils.isUndefined(oFile.name) ? null : oFile.name) : oFile.fileName,
iSize = Utils.isUndefined(oFile.fileSize) ? (Utils.isUndefined(oFile.size) ? null : oFile.size) : oFile.fileSize,
sType = Utils.isUndefined(oFile.type) ? null : oFile.type
;
if (sFileName.charAt(0) === '/')
{
sFileName = sFileName.substr(1);
}
if (!sType && 0 === iSize)
{
return null; // Folder
}
return {
'FileName': sFileName,
'Size': iSize,
'Type': sType,
'Folder': '',
'File' : oFile
};
};
/**
* @param {*} aItems
* @param {Function} fFileCallback
* @param {number=} iLimit = 20
* @param {Function=} fLimitCallback
*/
Utils.getDataFromFiles = function (aItems, fFileCallback, iLimit, fLimitCallback)
{
var
iInputLimit = 0,
iLen = 0,
iIndex = 0,
oItem = null,
oFile = null,
bUseLimit = false,
bCallLimit = false
;
iLimit = Utils.isUndefined(iLimit) ? Globals.iDefLimit : Utils.pInt(iLimit);
iInputLimit = iLimit;
bUseLimit = 0 < iLimit;
aItems = aItems && 0 < aItems.length ? aItems : null;
if (aItems)
{
for (iIndex = 0, iLen = aItems.length; iIndex < iLen; iIndex++)
if (0 < iTimer)
{
oItem = aItems[iIndex];
if (oItem)
{
if (!bUseLimit || 0 <= --iLimit)
{
oFile = Utils.getDataFromFile(oItem);
if (oFile)
{
fFileCallback(oFile);
}
}
else if (bUseLimit && !bCallLimit)
{
if (0 > iLimit && fLimitCallback)
{
bCallLimit = true;
fLimitCallback(iInputLimit);
}
}
}
clearTimeout(iTimer);
}
}
};
/**
* @param {*} oInput
* @param {Function} fFileCallback
* @param {number=} iLimit = 20
* @param {Function=} fLimitCallback
*/
Utils.getDataFromInput = function (oInput, fFileCallback, iLimit, fLimitCallback)
{
var aFiles = oInput && oInput.files && 0 < oInput.files.length ? oInput.files : null;
if (aFiles)
{
Utils.getDataFromFiles(aFiles, fFileCallback, iLimit, fLimitCallback);
}
else
{
fFileCallback({
'FileName': oInput.value.split('\\').pop().split('/').pop(),
'Size': null,
'Type': null,
'Folder': '',
'File' : null
});
}
};
iTimer = 0;
},
Utils.eventContainsFiles = function (oEvent)
{
var bResult = false;
if (oEvent && oEvent.dataTransfer && oEvent.dataTransfer.types && oEvent.dataTransfer.types.length)
/**
* @param {Event} oEvent
* @return {?Event}
*/
getEvent : oEvent =>
{
oEvent = (oEvent && (oEvent.originalEvent ?
oEvent.originalEvent : oEvent)) || window.event;
return oEvent.dataTransfer ? oEvent : null;
},
/**
* @param {Object} oValues
* @param {string} sKey
* @param {?} mDefault
* @return {?}
*/
getValue : (oValues, sKey, mDefault) => (!oValues || !sKey || !defined(oValues[sKey])) ? mDefault : oValues[sKey],
/**
* @param {Function} fFunction
* @param {Object=} oScope
* @return {Function}
*/
scopeBind : (fFunction, oScope) => (...args) => {
return fFunction.apply(defined(oScope) ? oScope : null,
Array.prototype.slice.call(args));
},
/**
* @param {number=} iLen
* @return {string}
*/
fakeMd5 : iLen =>
{
var
iIindex = 0,
iLen = oEvent.dataTransfer.types.length
sResult = '',
sLine = '0123456789abcdefghijklmnopqrstuvwxyz'
;
for (; iIindex < iLen; iIindex++)
iLen = defined(iLen) ? parseInt(iLen || 0, 10) : 32;
while (sResult.length < iLen)
{
if (oEvent.dataTransfer.types[iIindex].toLowerCase() === 'files')
sResult += sLine.substr(Math.round(Math.random() * sLine.length), 1);
}
return sResult;
},
/**
* @return {string}
*/
getNewUid : () => 'jua-uid-' + Utils.fakeMd5(16) + '-' + (new Date()).getTime().toString(),
/**
* @param {*} oFile
* @return {Object}
*/
getDataFromFile : oFile =>
{
var
sFileName = defined(oFile.fileName) ? oFile.fileName : (defined(oFile.name) ? oFile.name : null),
iSize = defined(oFile.fileSize) ? oFile.fileSize : (defined(oFile.size) ? oFile.size : null),
sType = defined(oFile.type) ? oFile.type : null
;
if (sFileName.charAt(0) === '/')
{
sFileName = sFileName.substr(1);
}
if (!sType && 0 === iSize)
{
return null; // Folder
}
return {
'FileName': sFileName,
'Size': iSize,
'Type': sType,
'Folder': '',
'File' : oFile
};
},
/**
* @param {*} aItems
* @param {Function} fFileCallback
* @param {number=} iLimit = 20
* @param {Function=} fLimitCallback
*/
getDataFromFiles : (aItems, fFileCallback, iLimit, fLimitCallback) =>
{
var
iInputLimit = 0,
iLen = 0,
iIndex = 0,
oItem = null,
oFile = null,
bUseLimit = false,
bCallLimit = false
;
iLimit = defined(iLimit) ? parseInt(iLimit || 0, 10) : iDefLimit;
iInputLimit = iLimit;
bUseLimit = 0 < iLimit;
aItems = aItems && 0 < aItems.length ? aItems : null;
if (aItems)
{
for (iIndex = 0, iLen = aItems.length; iIndex < iLen; iIndex++)
{
bResult = true;
break;
oItem = aItems[iIndex];
if (oItem)
{
if (!bUseLimit || 0 <= --iLimit)
{
oFile = Utils.getDataFromFile(oItem);
if (oFile)
{
fFileCallback(oFile);
}
}
else if (bUseLimit && !bCallLimit)
{
if (0 > iLimit && fLimitCallback)
{
bCallLimit = true;
fLimitCallback(iInputLimit);
}
}
}
}
}
}
},
return bResult;
};
/**
* @param {Event} oEvent
* @param {Function} fFileCallback
* @param {number=} iLimit = 20
* @param {Function=} fLimitCallback
*/
Utils.getDataFromDragEvent = function (oEvent, fFileCallback, iLimit, fLimitCallback)
{
var aFiles = null;
oEvent = Utils.getEvent(oEvent);
if (oEvent && Utils.eventContainsFiles(oEvent))
/**
* @param {*} oInput
* @param {Function} fFileCallback
* @param {number=} iLimit = 20
* @param {Function=} fLimitCallback
*/
getDataFromInput : (oInput, fFileCallback, iLimit, fLimitCallback) =>
{
aFiles = (Utils.getValue(oEvent, 'files', null) || (oEvent.dataTransfer ?
Utils.getValue(oEvent.dataTransfer, 'files', null) : null));
if (aFiles && 0 < aFiles.length)
var aFiles = oInput && oInput.files && 0 < oInput.files.length ? oInput.files : null;
if (aFiles)
{
Utils.getDataFromFiles(aFiles, fFileCallback, iLimit, fLimitCallback);
}
}
};
else
{
fFileCallback({
'FileName': oInput.value.split('\\').pop().split('/').pop(),
'Size': null,
'Type': null,
'Folder': '',
'File' : null
});
}
},
Utils.createNextLabel = function ()
{
return $('<label style="' +
'position: absolute; background-color:#fff; right: 0px; top: 0px; left: 0px; bottom: 0px; margin: 0px; padding: 0px; cursor: pointer;' +
'"></label>').css({
'opacity': 0
});
};
Utils.createNextInput = function ()
{
return $('<input type="file" tabindex="-1" hidefocus="hidefocus" style="position: absolute; left: -9999px;" />');
};
/**
* @param {string=} sName
* @param {boolean=} bMultiple = true
* @return {?Object}
*/
Utils.getNewInput = function (sName, bMultiple)
{
sName = Utils.isUndefined(sName) ? '' : sName.toString();
var oLocal = Utils.createNextInput();
if (0 < sName.length)
eventContainsFiles : oEvent =>
{
oLocal.attr('name', sName);
}
var bResult = false;
if (oEvent && oEvent.dataTransfer && oEvent.dataTransfer.types && oEvent.dataTransfer.types.length)
{
var
iIindex = 0,
iLen = oEvent.dataTransfer.types.length
;
if (Utils.isUndefined(bMultiple) ? true : bMultiple)
for (; iIindex < iLen; iIindex++)
{
if (oEvent.dataTransfer.types[iIindex].toLowerCase() === 'files')
{
bResult = true;
break;
}
}
}
return bResult;
},
/**
* @param {Event} oEvent
* @param {Function} fFileCallback
* @param {number=} iLimit = 20
* @param {Function=} fLimitCallback
*/
getDataFromDragEvent : (oEvent, fFileCallback, iLimit, fLimitCallback) =>
{
oLocal.prop('multiple', true);
}
var aFiles = null;
return oLocal;
};
oEvent = Utils.getEvent(oEvent);
if (oEvent && Utils.eventContainsFiles(oEvent))
{
aFiles = (Utils.getValue(oEvent, 'files', null) || (oEvent.dataTransfer ?
Utils.getValue(oEvent.dataTransfer, 'files', null) : null));
/**
* @param {?} mStringOrFunction
* @param {Array=} aFunctionParams
* @return {string}
*/
Utils.getStringOrCallFunction = function (mStringOrFunction, aFunctionParams)
{
return $.isFunction(mStringOrFunction) ?
mStringOrFunction.apply(null, Array.isArray(aFunctionParams) ? aFunctionParams : []).toString() :
mStringOrFunction.toString();
if (aFiles && 0 < aFiles.length)
{
Utils.getDataFromFiles(aFiles, fFileCallback, iLimit, fLimitCallback);
}
}
},
createNextLabel : () =>
{
return $('<label style="' +
'position: absolute; background-color:#fff; right: 0px; top: 0px; left: 0px; bottom: 0px; margin: 0px; padding: 0px; cursor: pointer;' +
'"></label>').css({
'opacity': 0
});
},
createNextInput : () => $('<input type="file" tabindex="-1" hidefocus="hidefocus" style="position: absolute; left: -9999px;" />'),
/**
* @param {string=} sName
* @param {boolean=} bMultiple = true
* @return {?Object}
*/
getNewInput : (sName, bMultiple) =>
{
sName = defined(sName) ? sName.toString() : '';
var oLocal = Utils.createNextInput();
if (0 < sName.length)
{
oLocal.attr('name', sName);
}
if (defined(bMultiple) ? bMultiple : true)
{
oLocal.prop('multiple', true);
}
return oLocal;
},
/**
* @param {?} mStringOrFunction
* @param {Array=} aFunctionParams
* @return {string}
*/
getStringOrCallFunction : (mStringOrFunction, aFunctionParams) => $.isFunction(mStringOrFunction) ?
mStringOrFunction.apply(null, Array.isArray(aFunctionParams) ? aFunctionParams : []).toString() :
mStringOrFunction.toString()
};
@ -453,7 +378,7 @@
if (fProgressFunction && oXhr.upload)
{
oXhr.upload.onprogress = function (oEvent) {
if (oEvent && oEvent.lengthComputable && !Utils.isUndefined(oEvent.loaded) && !Utils.isUndefined(oEvent.total))
if (oEvent && oEvent.lengthComputable && defined(oEvent.loaded) && defined(oEvent.total))
{
fProgressFunction(sUid, oEvent.loaded, oEvent.total);
}
@ -483,7 +408,7 @@
fCompleteFunction(sUid, bResult, oResult);
}
if (!Utils.isUndefined(self.oXhrs[sUid]))
if (defined(self.oXhrs[sUid]))
{
self.oXhrs[sUid] = null;
}
@ -557,7 +482,7 @@
oLabel.remove();
}, 10);
},
Utils.getValue(self.oOptions, 'multipleSizeLimit', Globals.iDefLimit),
Utils.getValue(self.oOptions, 'multipleSizeLimit', iDefLimit),
self.oJua.getEvent('onLimitReached')
);
})
@ -624,7 +549,7 @@
*/
function Jua(oOptions)
{
oOptions = Utils.isUndefined(oOptions) ? {} : oOptions;
oOptions = defined(oOptions) ? oOptions : {};
var
self = this,
@ -649,7 +574,7 @@
'onLimitReached': null
};
self.oOptions = Utils.extend({
self.oOptions = {
'action': '',
'name': '',
'hidden': {},
@ -661,9 +586,10 @@
'disableMultiple': false,
'disableDocumentDropPrevent': false,
'multipleSizeLimit': 50
}, oOptions);
};
Object.entries(oOptions).forEach(([key, value])=>self.oOptions[key]=value);
self.oQueue = queue(Utils.pInt(Utils.getValue(self.oOptions, 'queueSize', 10)));
self.oQueue = queue(parseInt(Utils.getValue(self.oOptions, 'queueSize', 10) || 0, 10));
if (self.runEvent('onCompleteAll'))
{
self.oQueue.await(function () {
@ -694,7 +620,7 @@
{
(function (self) {
var
$doc = $(window.document),
$doc = $(document),
oBigDropZone = $(Utils.getValue(self.oOptions, 'dragAndDropBodyElement', false) || $doc),
oDragAndDropElement = Utils.getValue(self.oOptions, 'dragAndDropElement', false),
fHandleDragOver = function (oEvent) {
@ -736,7 +662,7 @@
Utils.mainClearTimeout(self.iDocTimer);
}
},
Utils.getValue(self.oOptions, 'multipleSizeLimit', Globals.iDefLimit),
Utils.getValue(self.oOptions, 'multipleSizeLimit', iDefLimit),
self.getEvent('onLimitReached')
);
}
@ -763,7 +689,7 @@
oEvent = Utils.getEvent(oEvent);
if (oEvent)
{
var oRelatedTarget = window.document['elementFromPoint'] ? window.document['elementFromPoint'](oEvent['clientX'], oEvent['clientY']) : null;
var oRelatedTarget = document['elementFromPoint'] ? document['elementFromPoint'](oEvent['clientX'], oEvent['clientY']) : null;
if (oRelatedTarget && Utils.contains(this, oRelatedTarget))
{
return;
@ -871,11 +797,6 @@
{
self.bEnableDnD = false;
}
Utils.setValue(self, 'on', self.on);
Utils.setValue(self, 'cancel', self.cancel);
Utils.setValue(self, 'isDragAndDropSupported', self.isDragAndDropSupported);
Utils.setValue(self, 'setDragAndDropEnabledStatus', self.setDragAndDropEnabledStatus);
}
/**

File diff suppressed because one or more lines are too long

View file

@ -30,9 +30,7 @@
';': 186, '\'': 222,
'[': 219, ']': 221, '\\': 220
},
code = function(x){
return _MAP[x] || x.toUpperCase().charCodeAt(0);
},
code = x => _MAP[x] || x.toUpperCase().charCodeAt(0),
_downKeys = [];
for(k=1;k<20;k++) _MAP['f'+k] = 111+k;
@ -43,95 +41,15 @@
17:'ctrlKey',
91:'metaKey'
};
function updateModifierKey(event) {
for(k in _mods) _mods[k] = event[modifierMap[k]];
}
// handle keydown event
function dispatch(event) {
var key, handler, k, i, modifiersMatch, scope;
key = event.keyCode;
if (!_downKeys.includes(key)) {
_downKeys.push(key);
}
// if a modifier key, set the key.<modifierkeyname> property to true and return
if(key == 93 || key == 224) key = 91; // right command on webkit, command on Gecko
if(key in _mods) {
_mods[key] = true;
// 'assignKey' from inside this closure is exported to window.key
for(k in _MODIFIERS) if(_MODIFIERS[k] == key) assignKey[k] = true;
return;
}
updateModifierKey(event);
// see if we need to ignore the keypress (filter() can can be overridden)
// by default ignore key presses if a select, textarea, or input is focused
if(!assignKey.filter.call(this, event)) return;
// abort if no potentially matching shortcuts found
if (!(key in _handlers)) return;
scope = getScope();
// for each potential shortcut
for (i = 0; i < _handlers[key].length; i++) {
handler = _handlers[key][i];
// see if it's in the current scope
if(handler.scope == scope || handler.scope == 'all'){
// check if modifiers match if any
modifiersMatch = handler.mods.length > 0;
for(k in _mods)
if((!_mods[k] && handler.mods.includes(+k)) ||
(_mods[k] && !handler.mods.includes(+k))) modifiersMatch = false;
// call the handler and stop the event if neccessary
if((handler.mods.length == 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) || modifiersMatch){
if(handler.method(event, handler)===false){
if(event.preventDefault) event.preventDefault();
else event.returnValue = false;
if(event.stopPropagation) event.stopPropagation();
if(event.cancelBubble) event.cancelBubble = true;
}
}
}
}
}
// unset modifier keys on keyup
function clearModifier(event){
var key = event.keyCode, k,
i = _downKeys.indexOf(key);
// remove key from _downKeys
if (i >= 0) {
_downKeys.splice(i, 1);
}
if(key == 93 || key == 224) key = 91;
if(key in _mods) {
_mods[key] = false;
for(k in _MODIFIERS) if(_MODIFIERS[k] == key) assignKey[k] = false;
}
}
function resetModifiers() {
for(let k in _mods) _mods[k] = false;
for(let k in _MODIFIERS) assignKey[k] = false;
}
// parse and assign shortcut
function assignKey(key, scope, method){
var keys, mods, bScopeIsArray = false;
keys = getKeys(key);
var keys = getKeys(key), mods;
if (method === undefined) {
method = scope;
scope = 'all';
}
bScopeIsArray = !!(typeof scope !== 'string' && scope.length && typeof scope[0] === 'string');
// for each shortcut
for (var i = 0; i < keys.length; i++) {
// set modifier keys if any
@ -147,22 +65,16 @@
// ...store handler
if (!(key in _handlers)) _handlers[key] = [];
if (bScopeIsArray) {
for (var j = 0; j < scope.length; j++) {
_handlers[key].push({ shortcut: keys[i], scope: scope[j], method: method, key: keys[i], mods: mods });
}
if (typeof scope !== 'string' && scope.length && typeof scope[0] === 'string') {
scope.forEach(item => {
_handlers[key].push({ shortcut: keys[i], scope: item, method: method, key: keys[i], mods: mods });
});
} else {
_handlers[key].push({ shortcut: keys[i], scope: scope, method: method, key: keys[i], mods: mods });
}
}
}
function filter(event){
var tagName = (event.target || event.srcElement).tagName;
// ignore keypressed in any elements that support keyboard data input
return !(tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA');
}
// initialize key.<modifier> to false
for(k in _MODIFIERS) assignKey[k] = false;
@ -172,9 +84,8 @@
getScope = () => _scope || 'all',
// abstract key logic for assign and unassign
getKeys = key => {
var keys;
key = key.replace(/\s/g, '');
keys = key.split(',');
var keys = key.split(',');
if ((keys[keys.length - 1]) == '') {
keys[keys.length - 2] += ',';
}
@ -183,24 +94,88 @@
// abstract mods logic for assign and unassign
getMods = key => {
var mods = key.slice(0, key.length - 1);
for (var mi = 0; mi < mods.length; mi++)
mods[mi] = _MODIFIERS[mods[mi]];
mods.forEach((mod, mi) => mods[mi] = _MODIFIERS[mod]);
return mods;
};
// set the handlers globally on document
document.addEventListener('keydown', function(event) { dispatch(event) }); // Passing _scope to a callback to ensure it remains the same by execution. Fixes #48
document.addEventListener('keyup', clearModifier);
document.addEventListener('keydown', event => {
var key = event.keyCode, k, modifiersMatch, scope;
if (!_downKeys.includes(key)) {
_downKeys.push(key);
}
// if a modifier key, set the key.<modifierkeyname> property to true and return
if(key == 93 || key == 224) key = 91; // right command on webkit, command on Gecko
if(key in _mods) {
_mods[key] = true;
// 'assignKey' from inside this closure is exported to window.key
for(k in _MODIFIERS) if(_MODIFIERS[k] == key) assignKey[k] = true;
return;
}
for(k in _mods) _mods[k] = event[modifierMap[k]];
// see if we need to ignore the keypress (filter() can can be overridden)
// by default ignore key presses if a select, textarea, or input is focused
if(!assignKey.filter.call(this, event)) return;
// abort if no potentially matching shortcuts found
if (!(key in _handlers)) return;
scope = getScope();
// for each potential shortcut
_handlers[key].forEach(handler => {
// see if it's in the current scope
if(handler.scope == scope || handler.scope == 'all'){
// check if modifiers match if any
modifiersMatch = handler.mods.length > 0;
for(k in _mods)
if((!_mods[k] && handler.mods.includes(+k)) ||
(_mods[k] && !handler.mods.includes(+k))) modifiersMatch = false;
// call the handler and stop the event if neccessary
if((handler.mods.length == 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) || modifiersMatch){
if(handler.method(event, handler)===false){
event.preventDefault();
event.stopPropagation();
}
}
}
});
});
// unset modifier keys on keyup
document.addEventListener('keyup', event => {
var key = event.keyCode, k,
i = _downKeys.indexOf(key);
// remove key from _downKeys
if (i >= 0) {
_downKeys.splice(i, 1);
}
if(key == 93 || key == 224) key = 91;
if(key in _mods) {
_mods[key] = false;
for(k in _MODIFIERS) if(_MODIFIERS[k] == key) assignKey[k] = false;
}
});
// reset modifiers to false whenever the window is (re)focused.
window.addEventListener('focus', resetModifiers);
window.addEventListener('focus', () => {
for(let k in _mods) _mods[k] = false;
for(let k in _MODIFIERS) assignKey[k] = false;
});
// set window.key and window.key.set/get, and the default filter
global.key = assignKey;
global.key.setScope = setScope;
global.key.getScope = getScope;
global.key.filter = filter;
if(typeof module !== 'undefined') module.exports = key;
global.key.filter = event => {
var tagName = event.target.tagName;
// ignore keypressed in any elements that support keyboard data input
return !(tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA');
};
})(this);

View file

@ -179,13 +179,7 @@
// Using different namespace for click because click event should not unbind if selector is same object('this')
_this.$items.on('click.lgcustom', function(event) {
// For IE8
try {
event.preventDefault();
event.preventDefault();
} catch (er) {
event.returnValue = false;
}
event.preventDefault();
_this.$el.trigger('onBeforeOpen.lg');

File diff suppressed because one or more lines are too long

View file

@ -176,13 +176,7 @@
// Using different namespace for click because click event should not unbind if selector is same object('this')
_this.$items.on('click.lgcustom', function(event) {
// For IE8
try {
event.preventDefault();
event.preventDefault();
} catch (er) {
event.returnValue = false;
}
event.preventDefault();
_this.$el.trigger('onBeforeOpen.lg');

290
vendors/routes/crossroads.js vendored Normal file
View file

@ -0,0 +1,290 @@
/** @license
* Crossroads.js <http://millermedeiros.github.com/crossroads.js>
* Released under the MIT license
* Author: Miller Medeiros
* Version: 0.7.1 - Build: 93 (2012/02/02 09:29 AM)
*/
(global => {
// Helpers -----------
//====================
//borrowed from AMD-utils
function typecastValue(val) {
var r;
if (val === null || val === 'null') {
r = null;
} else if (val === 'true') {
r = true;
} else if (val === 'false') {
r = false;
} else if (val === undefined || val === 'undefined') {
r = undefined;
} else if (val === '' || isNaN(val)) {
//isNaN('') returns false
r = val;
} else {
//parseFloat(null || '') returns NaN
r = parseFloat(val);
}
return r;
}
// Crossroads --------
//====================
class Crossroads {
constructor() {
this._routes = [];
this.bypassed = new signals.Signal();
this.routed = new global.signals.Signal();
this.shouldTypecast = false;
}
addRoute(pattern, callback, priority) {
var route = new Route(pattern, callback, priority, this),
routes = this._routes,
n = routes.length;
do { --n; } while (routes[n] && route._priority <= routes[n]._priority);
routes.splice(n+1, 0, route);
return route;
}
removeRoute(route) {
var i = this._routes.indexOf(route);
if (i !== -1) {
this._routes.splice(i, 1);
}
route._destroy();
}
removeAllRoutes() {
var n = this.getNumRoutes();
while (n--) {
this._routes[n]._destroy();
}
this._routes.length = 0;
}
parse(request) {
request = request || '';
var routes = this._getMatchedRoutes(request),
i = 0,
n = routes.length,
cur;
if (n) {
//shold be incremental loop, execute routes in order
while (i < n) {
cur = routes[i];
cur.route.matched.dispatch.apply(cur.route.matched, cur.params);
cur.isFirst = !i;
this.routed.dispatch(request, cur);
i += 1;
}
} else {
this.bypassed.dispatch(request);
}
}
getNumRoutes() {
return this._routes.length;
}
_getMatchedRoutes(request) {
var res = [],
routes = this._routes,
n = routes.length,
route;
//should be decrement loop since higher priorities are added at the end of array
while (route = routes[--n]) {
if ((!res.length || route.greedy) && route.match(request)) {
res.push({
route : route,
params : route._getParamsArray(request)
});
}
}
return res;
}
}
// Route --------------
//=====================
class Route {
constructor(pattern, callback, priority, router) {
this.greedy = false;
this.rules = void(0);
var isRegexPattern = pattern instanceof RegExp;
this._router = router;
this._pattern = pattern;
this._paramsIds = isRegexPattern ? null : patternLexer.getParamIds(this._pattern);
this._optionalParamsIds = isRegexPattern ? null : patternLexer.getOptionalParamsIds(this._pattern);
this._matchRegexp = isRegexPattern ? pattern : patternLexer.compilePattern(pattern);
this.matched = new global.signals.Signal();
if (callback) {
this.matched.add(callback);
}
this._priority = priority || 0;
}
match(request) {
return this._matchRegexp.test(request) && this._validateParams(request); //validate params even if regexp because of `request_` rule.
}
_validateParams(request) {
var rules = this.rules,
values = this._getParamsObject(request),
key;
for (key in rules) {
// normalize_ isn't a validation rule... (#39)
if(key !== 'normalize_' && rules.hasOwnProperty(key) && ! this._isValidParam(request, key, values)){
return false;
}
}
return true;
}
_isValidParam(request, prop, values) {
var validationRule = this.rules[prop],
val = values[prop],
isValid = false;
if (val == null && this._optionalParamsIds && this._optionalParamsIds.indexOf(prop) !== -1) {
isValid = true;
}
else if (validationRule instanceof RegExp) {
isValid = validationRule.test(val);
}
else if (Array.isArray(validationRule)) {
isValid = validationRule.indexOf(val) !== -1;
}
else if (typeof validationRule === 'function') {
isValid = validationRule(val, request, values);
}
return isValid; //fail silently if validationRule is from an unsupported type
}
_getParamsObject(request) {
var shouldTypecast = this._router.shouldTypecast,
values = patternLexer.getParamValues(request, this._matchRegexp, shouldTypecast),
o = {},
n = values.length;
while (n--) {
o[n] = values[n]; //for RegExp pattern and also alias to normal paths
if (this._paramsIds) {
o[this._paramsIds[n]] = values[n];
}
}
o.request_ = shouldTypecast ? typecastValue(request) : request;
o.vals_ = values;
return o;
}
_getParamsArray(request) {
var norm = this.rules ? this.rules.normalize_ : null,
params;
if (norm && typeof norm === 'function') {
params = norm(request, this._getParamsObject(request));
} else {
params = patternLexer.getParamValues(request, this._matchRegexp, this._router.shouldTypecast);
}
return params;
}
dispose() {
this._router.removeRoute(this);
}
_destroy() {
this.matched.dispose();
this.matched = this._pattern = this._matchRegexp = null;
}
}
// Pattern Lexer ------
//=====================
const
ESCAPE_CHARS_REGEXP = /[\\.+*?^$[\](){}/'#]/g, //match chars that should be escaped on string regexp
UNNECESSARY_SLASHES_REGEXP = /\/$/g, //trailing slash
OPTIONAL_SLASHES_REGEXP = /([:}]|\w(?=\/))\/?(:)/g, //slash between `::` or `}:` or `\w:`. $1 = before, $2 = after
REQUIRED_SLASHES_REGEXP = /([:}])\/?(\{)/g, //used to insert slash between `:{` and `}{`
REQUIRED_PARAMS_REGEXP = /\{([^}]+)\}/g, //match everything between `{ }`
OPTIONAL_PARAMS_REGEXP = /:([^:]+):/g, //match everything between `: :`
PARAMS_REGEXP = /(?:\{|:)([^}:]+)(?:\}|:)/g, //capture everything between `{ }` or `: :`
//used to save params during compile (avoid escaping things that
//shouldn't be escaped).
SAVE_REQUIRED_PARAMS = '__CR_RP__',
SAVE_OPTIONAL_PARAMS = '__CR_OP__',
SAVE_REQUIRED_SLASHES = '__CR_RS__',
SAVE_OPTIONAL_SLASHES = '__CR_OS__',
SAVED_REQUIRED_REGEXP = new RegExp(SAVE_REQUIRED_PARAMS, 'g'),
SAVED_OPTIONAL_REGEXP = new RegExp(SAVE_OPTIONAL_PARAMS, 'g'),
SAVED_OPTIONAL_SLASHES_REGEXP = new RegExp(SAVE_OPTIONAL_SLASHES, 'g'),
SAVED_REQUIRED_SLASHES_REGEXP = new RegExp(SAVE_REQUIRED_SLASHES, 'g'),
captureVals = (regex, pattern) => {
var vals = [], match;
while (match = regex.exec(pattern)) {
vals.push(match[1]);
}
return vals;
},
tokenize = pattern => {
//save chars that shouldn't be escaped
return pattern.replace(OPTIONAL_SLASHES_REGEXP, '$1'+ SAVE_OPTIONAL_SLASHES +'$2')
.replace(REQUIRED_SLASHES_REGEXP, '$1'+ SAVE_REQUIRED_SLASHES +'$2')
.replace(OPTIONAL_PARAMS_REGEXP, SAVE_OPTIONAL_PARAMS)
.replace(REQUIRED_PARAMS_REGEXP, SAVE_REQUIRED_PARAMS);
},
untokenize = pattern => {
return pattern.replace(SAVED_OPTIONAL_SLASHES_REGEXP, '\\/?')
.replace(SAVED_REQUIRED_SLASHES_REGEXP, '\\/')
.replace(SAVED_OPTIONAL_REGEXP, '([^\\/]+)?/?')
.replace(SAVED_REQUIRED_REGEXP, '([^\\/]+)');
},
patternLexer = {
getParamIds : pattern => captureVals(PARAMS_REGEXP, pattern),
getOptionalParamsIds : pattern => captureVals(OPTIONAL_PARAMS_REGEXP, pattern),
getParamValues : (request, regexp, shouldTypecast) => {
var vals = regexp.exec(request);
if (vals) {
vals.shift();
if (shouldTypecast) {
vals = vals.map(v => typecastValue(v));
}
}
return vals;
},
compilePattern : pattern => {
pattern = pattern || '';
if (pattern) {
pattern = untokenize(
tokenize(pattern.replace(UNNECESSARY_SLASHES_REGEXP, '')).replace(ESCAPE_CHARS_REGEXP, '\\$&')
);
}
return new RegExp('^'+ pattern + '/?$'); //trailing slash is optional
}
};
global.Crossroads = Crossroads;
})(this);

View file

@ -4,11 +4,4 @@
Author: Miller Medeiros
Version: 0.7.1 - Build: 93 (2012/02/02 09:29 AM)
*/
(function(f){f(["signals"],function(g){function f(a,b){if(a.indexOf)return a.indexOf(b);else{for(var c=a.length;c--;)if(a[c]===b)return c;return-1}}function i(a,b){return"[object "+b+"]"===Object.prototype.toString.call(a)}function n(a){return a===null||a==="null"?null:a==="true"?!0:a==="false"?!1:a===m||a==="undefined"?m:a===""||isNaN(a)?a:parseFloat(a)}function k(){this._routes=[];this.bypassed=new g.Signal;this.routed=new g.Signal}function o(a,b,c,e){var d=i(a,"RegExp");this._router=e;this._pattern=
a;this._paramsIds=d?null:h.getParamIds(this._pattern);this._optionalParamsIds=d?null:h.getOptionalParamsIds(this._pattern);this._matchRegexp=d?a:h.compilePattern(a);this.matched=new g.Signal;b&&this.matched.add(b);this._priority=c||0}var j,h,m;k.prototype={normalizeFn:null,create:function(){return new k},shouldTypecast:!1,addRoute:function(a,b,c){a=new o(a,b,c,this);this._sortedInsert(a);return a},removeRoute:function(a){var b=f(this._routes,a);b!==-1&&this._routes.splice(b,1);a._destroy()},removeAllRoutes:function(){for(var a=
this.getNumRoutes();a--;)this._routes[a]._destroy();this._routes.length=0},parse:function(a){var a=a||"",b=this._getMatchedRoutes(a),c=0,e=b.length,d;if(e)for(;c<e;)d=b[c],d.route.matched.dispatch.apply(d.route.matched,d.params),d.isFirst=!c,this.routed.dispatch(a,d),c+=1;else this.bypassed.dispatch(a)},getNumRoutes:function(){return this._routes.length},_sortedInsert:function(a){var b=this._routes,c=b.length;do--c;while(b[c]&&a._priority<=b[c]._priority);b.splice(c+1,0,a)},_getMatchedRoutes:function(a){for(var b=
[],c=this._routes,e=c.length,d;d=c[--e];)(!b.length||d.greedy)&&d.match(a)&&b.push({route:d,params:d._getParamsArray(a)});return b},toString:function(){return"[crossroads numRoutes:"+this.getNumRoutes()+"]"}};j=new k;j.VERSION="0.7.1";o.prototype={greedy:!1,rules:void 0,match:function(a){return this._matchRegexp.test(a)&&this._validateParams(a)},_validateParams:function(a){var b=this.rules,c=this._getParamsObject(a),e;for(e in b)if(e!=="normalize_"&&b.hasOwnProperty(e)&&!this._isValidParam(a,e,c))return!1;
return!0},_isValidParam:function(a,b,c){var e=this.rules[b],d=c[b],l=!1;d==null&&this._optionalParamsIds&&f(this._optionalParamsIds,b)!==-1?l=!0:i(e,"RegExp")?l=e.test(d):i(e,"Array")?l=f(e,d)!==-1:i(e,"Function")&&(l=e(d,a,c));return l},_getParamsObject:function(a){for(var b=this._router.shouldTypecast,c=h.getParamValues(a,this._matchRegexp,b),e={},d=c.length;d--;)e[d]=c[d],this._paramsIds&&(e[this._paramsIds[d]]=c[d]);e.request_=b?n(a):a;e.vals_=c;return e},_getParamsArray:function(a){var b=this.rules?
this.rules.normalize_:null;return(b=b||this._router.normalizeFn)&&i(b,"Function")?b(a,this._getParamsObject(a)):h.getParamValues(a,this._matchRegexp,this._router.shouldTypecast)},dispose:function(){this._router.removeRoute(this)},_destroy:function(){this.matched.dispose();this.matched=this._pattern=this._matchRegexp=null},toString:function(){return'[Route pattern:"'+this._pattern+'", numListeners:'+this.matched.getNumListeners()+"]"}};h=j.patternLexer=function(){function a(a,b){for(var c=[],d;d=a.exec(b);)c.push(d[1]);
return c}var b=/[\\.+*?\^$\[\](){}\/'#]/g,c=/\/$/g,e=/([:}]|\w(?=\/))\/?(:)/g,d=/([:}])\/?(\{)/g,f=/\{([^}]+)\}/g,g=/:([^:]+):/g,h=/(?:\{|:)([^}:]+)(?:\}|:)/g,i=RegExp("__CR_RP__","g"),j=RegExp("__CR_OP__","g"),k=RegExp("__CR_OS__","g"),m=RegExp("__CR_RS__","g");return{getParamIds:function(b){return a(h,b)},getOptionalParamsIds:function(b){return a(g,b)},getParamValues:function(a,b,c){if(a=b.exec(a))if(a.shift(),c){c=a;a=c.length;for(b=[];a--;)b[a]=n(c[a]);a=b}return a},compilePattern:function(a){if(a=
a||"")a=a.replace(c,""),a=a.replace(e,"$1__CR_OS__$2"),a=a.replace(d,"$1__CR_RS__$2"),a=a.replace(g,"__CR_OP__"),a=a.replace(f,"__CR_RP__"),a=a.replace(b,"\\$&"),a=a.replace(k,"\\/?"),a=a.replace(m,"\\/"),a=a.replace(j,"([^\\/]+)?/?"),a=a.replace(i,"([^\\/]+)");return RegExp("^"+a+"/?$")}}}();return j})})(typeof define==="function"&&define.amd?define:function(f,g){typeof module!=="undefined"&&module.exports?module.exports=g(require(f[0])):window.crossroads=g(window[f[0]])});
(e=>{function t(e){return null===e||"null"===e?null:"true"===e||"false"!==e&&(void 0===e||"undefined"===e?void 0:""===e||isNaN(e)?e:parseFloat(e))}class s{constructor(t,s,r,a){this.greedy=!1,this.rules=void 0;var i=t instanceof RegExp;this._router=a,this._pattern=t,this._paramsIds=i?null:c.getParamIds(this._pattern),this._optionalParamsIds=i?null:c.getOptionalParamsIds(this._pattern),this._matchRegexp=i?t:c.compilePattern(t),this.matched=new e.signals.Signal,s&&this.matched.add(s),this._priority=r||0}match(e){return this._matchRegexp.test(e)&&this._validateParams(e)}_validateParams(e){var t,s=this.rules,r=this._getParamsObject(e);for(t in s)if("normalize_"!==t&&s.hasOwnProperty(t)&&!this._isValidParam(e,t,r))return!1;return!0}_isValidParam(e,t,s){var r=this.rules[t],a=s[t],i=!1;return null==a&&this._optionalParamsIds&&-1!==this._optionalParamsIds.indexOf(t)?i=!0:r instanceof RegExp?i=r.test(a):Array.isArray(r)?i=-1!==r.indexOf(a):"function"==typeof r&&(i=r(a,e,s)),i}_getParamsObject(e){for(var s=this._router.shouldTypecast,r=c.getParamValues(e,this._matchRegexp,s),a={},i=r.length;i--;)a[i]=r[i],this._paramsIds&&(a[this._paramsIds[i]]=r[i]);return a.request_=s?t(e):e,a.vals_=r,a}_getParamsArray(e){var t=this.rules?this.rules.normalize_:null;return t&&"function"==typeof t?t(e,this._getParamsObject(e)):c.getParamValues(e,this._matchRegexp,this._router.shouldTypecast)}dispose(){this._router.removeRoute(this)}_destroy(){this.matched.dispose(),this.matched=this._pattern=this._matchRegexp=null}}const r=/[\\.+*?^$[\](){}\/'#]/g,a=/\/$/g,i=/([:}]|\w(?=\/))\/?(:)/g,_=/([:}])\/?(\{)/g,h=/\{([^}]+)\}/g,o=/:([^:]+):/g,l=/(?:\{|:)([^}:]+)(?:\}|:)/g,n=new RegExp("__CR_RP__","g"),u=new RegExp("__CR_OP__","g"),p=new RegExp("__CR_OS__","g"),g=new RegExp("__CR_RS__","g"),d=(e,t)=>{for(var s,r=[];s=e.exec(t);)r.push(s[1]);return r},c={getParamIds:e=>d(l,e),getOptionalParamsIds:e=>d(o,e),getParamValues:(e,s,r)=>{var a=s.exec(e);return a&&(a.shift(),r&&(a=a.map(e=>t(e)))),a},compilePattern:e=>((e=e||"")&&(e=(e=>e.replace(p,"\\/?").replace(g,"\\/").replace(u,"([^\\/]+)?/?").replace(n,"([^\\/]+)"))((e=>e.replace(i,"$1__CR_OS__$2").replace(_,"$1__CR_RS__$2").replace(o,"__CR_OP__").replace(h,"__CR_RP__"))(e.replace(a,"")).replace(r,"\\$&"))),new RegExp("^"+e+"/?$"))};e.Crossroads=class{constructor(){this._routes=[],this.bypassed=new signals.Signal,this.routed=new e.signals.Signal,this.shouldTypecast=!1}addRoute(e,t,r){var a=new s(e,t,r,this),i=this._routes,_=i.length;do{--_}while(i[_]&&a._priority<=i[_]._priority);return i.splice(_+1,0,a),a}removeRoute(e){var t=this._routes.indexOf(e);-1!==t&&this._routes.splice(t,1),e._destroy()}removeAllRoutes(){for(var e=this.getNumRoutes();e--;)this._routes[e]._destroy();this._routes.length=0}parse(e){e=e||"";var t,s=this._getMatchedRoutes(e),r=0,a=s.length;if(a)for(;r<a;)(t=s[r]).route.matched.dispatch.apply(t.route.matched,t.params),t.isFirst=!r,this.routed.dispatch(e,t),r+=1;else this.bypassed.dispatch(e)}getNumRoutes(){return this._routes.length}_getMatchedRoutes(e){for(var t,s=[],r=this._routes,a=r.length;t=r[--a];)s.length&&!t.greedy||!t.match(e)||s.push({route:t,params:t._getParamsArray(e)});return s}}})(this);

168
vendors/routes/hasher.js vendored Normal file
View file

@ -0,0 +1,168 @@
/*!!
* Hasher <http://github.com/millermedeiros/hasher>
* @author Miller Medeiros
* @version 1.1.2 (2012/10/31 03:19 PM)
* Released under the MIT License
*/
(global => {
//--------------------------------------------------------------------------------------
// Private Vars
//--------------------------------------------------------------------------------------
var
// local storage for brevity and better compression --------------------------------
Signal = signals.Signal,
// local vars ----------------------------------------------------------------------
_hash,
_isActive,
_hashValRegexp = /#(.*)$/,
_hashRegexp = /^#/;
//--------------------------------------------------------------------------------------
// Private Methods
//--------------------------------------------------------------------------------------
const _trimHash = hash => {
if(! hash) return '';
var regexp = new RegExp('^\\/|\\$', 'g');
return hash.replace(regexp, '');
},
_getWindowHash = () => {
//parsed full URL instead of getting window.location.hash because Firefox decode hash value (and all the other browsers don't)
//also because of IE8 bug with hash query in local file [issue #6]
var result = _hashValRegexp.exec( global.location.href );
return (result && result[1])? decodeURIComponent(result[1]) : '';
},
_registerChange = newHash => {
if(_hash !== newHash){
var oldHash = _hash;
_hash = newHash; //should come before event dispatch to make sure user can get proper value inside event handler
hasher.changed.dispatch(_trimHash(newHash), _trimHash(oldHash));
}
},
_checkHistory = () => {
var windowHash = _getWindowHash();
if (windowHash !== _hash){
_registerChange(windowHash);
}
},
_makePath = path => {
path = path.join('/');
return path ? '/' + path.replace(_hashRegexp, '') : path;
},
//--------------------------------------------------------------------------------------
// Public (API)
//--------------------------------------------------------------------------------------
hasher = /** @lends hasher */ {
/**
* Signal dispatched when hash value changes.
* - pass current hash as 1st parameter to listeners and previous hash value as 2nd parameter.
* @type signals.Signal
*/
changed : new Signal(),
/**
* Signal dispatched when hasher is initialized.
* - pass current hash as first parameter to listeners.
* @type signals.Signal
*/
initialized : new Signal(),
/**
* Start listening/dispatching changes in the hash/history.
* <ul>
* <li>hasher won't dispatch CHANGE events by manually typing a new value or pressing the back/forward buttons before calling this method.</li>
* </ul>
*/
init : () => {
if (!_isActive) {
_hash = _getWindowHash();
//thought about branching/overloading hasher.init() to avoid checking multiple times but
//don't think worth doing it since it probably won't be called multiple times.
global.addEventListener('hashchange', _checkHistory);
_isActive = true;
hasher.initialized.dispatch(_trimHash(_hash));
}
},
/**
* Stop listening/dispatching changes in the hash/history.
* <ul>
* <li>hasher won't dispatch CHANGE events by manually typing a new value or pressing the back/forward buttons after calling this method, unless you call hasher.init() again.</li>
* <li>hasher will still dispatch changes made programatically by calling hasher.setHash();</li>
* </ul>
*/
stop : () => {
if (_isActive) {
global.removeEventListener('hashchange', _checkHistory);
_isActive = false;
}
},
/**
* Set Hash value, generating a new history record.
* @param {...string} path Hash value without '#'.
* @example hasher.setHash('lorem', 'ipsum', 'dolor') -> '#/lorem/ipsum/dolor'
*/
setHash : (...path) => {
path = _makePath(path);
if(path !== _hash){
// we should store raw value
_registerChange(path);
if (path === _hash) {
// we check if path is still === _hash to avoid error in
// case of multiple consecutive redirects [issue #39]
global.location.hash = '#' + encodeURI(path);
}
}
},
/**
* Set Hash value without keeping previous hash on the history record.
* Similar to calling `window.location.replace("#/hash")` but will also work on IE6-7.
* @param {...string} path Hash value without '#'.
* @example hasher.replaceHash('lorem', 'ipsum', 'dolor') -> '#/lorem/ipsum/dolor'
*/
replaceHash : (...path) => {
path = _makePath(path);
if(path !== _hash){
// we should store raw value
_registerChange(path, true);
if (path === _hash) {
// we check if path is still === _hash to avoid error in
// case of multiple consecutive redirects [issue #39]
global.location.replace('#' + encodeURI(path));
}
}
},
/**
* Removes all event listeners, stops hasher and destroy hasher object.
* - IMPORTANT: hasher won't work after calling this method, hasher Object will be deleted.
*/
dispose : () => {
hasher.stop();
hasher.initialized.dispose();
hasher.changed.dispose();
global.hasher = null;
}
};
hasher.initialized.memorize = true; //see #33
global.hasher = hasher;
})(this);

View file

@ -4,4 +4,4 @@
* @version 1.1.2 (2012/10/31 03:19 PM)
* Released under the MIT License
*/
(function(a){a("hasher",["signals"],function(b){var c=(function(k){var o=25,q=k.document,n=k.history,w=b.Signal,f,u,m,E,d,C,s=/#(.*)$/,j=/(\?.*)|(\#.*)/,g=/^\#/,i=(!+"\v1"),A=("onhashchange" in k)&&q.documentMode!==7,e=i&&!A,r=(location.protocol==="file:");function t(G){if(!G){return""}var F=new RegExp("^\\"+f.prependHash+"|\\"+f.appendHash+"$","g");return G.replace(F,"")}function D(){var F=s.exec(f.getURL());return(F&&F[1])?decodeURIComponent(F[1]):""}function z(){return(d)?d.contentWindow.frameHash:null}function y(){d=q.createElement("iframe");d.src="about:blank";d.style.display="none";q.body.appendChild(d)}function h(){if(d&&u!==z()){var F=d.contentWindow.document;F.open();F.write("<html><head><title>"+q.title+'</title><script type="text/javascript">var frameHash="'+u+'";<\/script></head><body>&nbsp;</body></html>');F.close()}}function l(F,G){if(u!==F){var H=u;u=F;if(e){if(!G){h()}else{d.contentWindow.frameHash=F}}f.changed.dispatch(t(F),t(H))}}if(e){C=function(){var G=D(),F=z();if(F!==u&&F!==G){f.setHash(t(F))}else{if(G!==u){l(G)}}}}else{C=function(){var F=D();if(F!==u){l(F)}}}function B(H,F,G){if(H.addEventListener){H.addEventListener(F,G,false)}else{if(H.attachEvent){H.attachEvent("on"+F,G)}}}function x(H,F,G){if(H.removeEventListener){H.removeEventListener(F,G,false)}else{if(H.detachEvent){H.detachEvent("on"+F,G)}}}function p(G){G=Array.prototype.slice.call(arguments);var F=G.join(f.separator);F=F?f.prependHash+F.replace(g,"")+f.appendHash:F;return F}function v(F){F=encodeURI(F);if(i&&r){F=F.replace(/\?/,"%3F")}return F}f={VERSION:"1.1.2",appendHash:"",prependHash:"/",separator:"/",changed:new w(),stopped:new w(),initialized:new w(),init:function(){if(E){return}u=D();if(A){B(k,"hashchange",C)}else{if(e){if(!d){y()}h()}m=setInterval(C,o)}E=true;f.initialized.dispatch(t(u))},stop:function(){if(!E){return}if(A){x(k,"hashchange",C)}else{clearInterval(m);m=null}E=false;f.stopped.dispatch(t(u))},isActive:function(){return E},getURL:function(){return k.location.href},getBaseURL:function(){return f.getURL().replace(j,"")},setHash:function(F){F=p.apply(null,arguments);if(F!==u){l(F);if(F===u){k.location.hash="#"+v(F)}}},replaceHash:function(F){F=p.apply(null,arguments);if(F!==u){l(F,true);if(F===u){k.location.replace("#"+v(F))}}},getHash:function(){return t(u)},getHashAsArray:function(){return f.getHash().split(f.separator)},dispose:function(){f.stop();f.initialized.dispose();f.stopped.dispose();f.changed.dispose();d=f=k.hasher=null},toString:function(){return'[hasher version="'+f.VERSION+'" hash="'+f.getHash()+'"]'}};f.initialized.memorize=true;return f}(window));return c})}(typeof define==="function"&&define.amd?define:function(c,b,a){window[c]=a(window[b[0]])}));
(e=>{var i,a,n=signals.Signal,s=/#(.*)$/,t=/^#/;const r=e=>{if(!e)return"";var i=new RegExp("^\\/|\\$","g");return e.replace(i,"")},h=()=>{var i=s.exec(e.location.href);return i&&i[1]?decodeURIComponent(i[1]):""},o=e=>{if(i!==e){var a=i;i=e,l.changed.dispatch(r(e),r(a))}},c=()=>{var e=h();e!==i&&o(e)},d=e=>(e=e.join("/"))?"/"+e.replace(t,""):e,l={changed:new n,initialized:new n,init:()=>{a||(i=h(),e.addEventListener("hashchange",c),a=!0,l.initialized.dispatch(r(i)))},stop:()=>{a&&(e.removeEventListener("hashchange",c),a=!1)},setHash:(...a)=>{(a=d(a))!==i&&(o(a),a===i&&(e.location.hash="#"+encodeURI(a)))},replaceHash:(...a)=>{(a=d(a))!==i&&(o(a),a===i&&e.location.replace("#"+encodeURI(a)))},dispose:()=>{l.stop(),l.initialized.dispose(),l.changed.dispose(),e.hasher=null}};l.initialized.memorize=!0,e.hasher=l})(this);

326
vendors/routes/signals.js vendored Normal file
View file

@ -0,0 +1,326 @@
/** @license
* JS Signals <http://millermedeiros.github.com/js-signals/>
* Released under the MIT license
* Author: Miller Medeiros
* Version: 1.0.0 - Build: 268 (2012/11/29 05:48 PM)
*/
(global=>{
// SignalBinding -------------------------------------------------
//================================================================
class SignalBinding {
/**
* Object that represents a binding between a Signal and a listener function.
* <br />- <strong>This is an internal constructor and shouldn't be called by regular users.</strong>
* <br />- inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes.
* @author Miller Medeiros
* @constructor
* @internal
* @name SignalBinding
* @param {Signal} signal Reference to Signal object that listener is currently bound to.
* @param {Function} listener Handler function bound to the signal.
* @param {boolean} isOnce If binding should be executed just once.
* @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
* @param {Number} [priority] The priority level of the event listener. (default = 0).
*/
constructor (signal, listener, isOnce, listenerContext, priority) {
/**
* If binding is active and should be executed.
* @type boolean
*/
this.active = true;
/**
* Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute`. (curried parameters)
* @type Array|null
*/
this.params = null;
/**
* Handler function bound to the signal.
* @type Function
* @private
*/
this._listener = listener;
/**
* If binding should be executed just once.
* @type boolean
* @private
*/
this._isOnce = isOnce;
/**
* Context on which listener will be executed (object that should represent the `this` variable inside listener function).
* @memberOf SignalBinding.prototype
* @name context
* @type Object|undefined|null
*/
this.context = listenerContext;
/**
* Reference to Signal object that listener is currently bound to.
* @type Signal
* @private
*/
this._signal = signal;
/**
* Listener priority
* @type Number
* @private
*/
this._priority = priority || 0;
}
/**
* Call listener passing arbitrary parameters.
* <p>If binding was added using `Signal.addOnce()` it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch.</p>
* @param {Array} [paramsArr] Array of parameters that should be passed to the listener
* @return {*} Value returned by the listener.
*/
execute (paramsArr) {
var handlerReturn, params;
if (this.active && !!this._listener) {
params = this.params? this.params.concat(paramsArr) : paramsArr;
handlerReturn = this._listener.apply(this.context, params);
if (this._isOnce) {
this.detach();
}
}
return handlerReturn;
}
/**
* Detach binding from signal.
* - alias to: mySignal.remove(myBinding.getListener());
* @return {Function|null} Handler function bound to the signal or `null` if binding was previously detached.
*/
detach () {
return this.isBound()? this._signal.remove(this._listener, this.context) : null;
}
/**
* @return {Boolean} `true` if binding is still bound to the signal and have a listener.
*/
isBound () {
return (!!this._signal && !!this._listener);
}
/**
* @return {boolean} If SignalBinding will only be executed once.
*/
isOnce () {
return this._isOnce;
}
/**
* @return {Function} Handler function bound to the signal.
*/
getListener () {
return this._listener;
}
/**
* @return {Signal} Signal that listener is currently bound to.
*/
getSignal () {
return this._signal;
}
/**
* Delete instance properties
* @private
*/
_destroy () {
delete this._signal;
delete this._listener;
delete this.context;
}
}
// Signal --------------------------------------------------------
//================================================================
function validateListener(listener, fnName) {
if (typeof listener !== 'function') {
throw new Error( 'listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName) );
}
}
class Signal {
/**
* Custom event broadcaster
* <br />- inspired by Robert Penner's AS3 Signals.
* @name Signal
* @author Miller Medeiros
* @constructor
*/
constructor () {
/**
* If Signal should keep record of previously dispatched parameters and
* automatically execute listener during `add()`/`addOnce()` if Signal was
* already dispatched before.
* @type boolean
*/
this.memorize = false;
/**
* If Signal is active and should broadcast events.
* <p><strong>IMPORTANT:</strong> Setting this property during a dispatch will only affect the next dispatch, if you want to stop the propagation of a signal use `halt()` instead.</p>
* @type boolean
*/
this.active = true;
/**
* @type Array.<SignalBinding>
* @private
*/
this._bindings = [];
this._prevParams = null;
// enforce dispatch to aways work on same context (#47)
var self = this;
this.dispatch = (...args) => Signal.prototype.dispatch.apply(self, args);
}
/**
* @param {Function} listener
* @return {number}
* @private
*/
_indexOfListener (listener, context) {
var n = this._bindings.length,
cur;
while (n--) {
cur = this._bindings[n];
if (cur._listener === listener && cur.context === context) {
return n;
}
}
return -1;
}
/**
* Add a listener to the signal.
* @param {Function} listener Signal handler function.
* @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
* @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)
* @return {SignalBinding} An Object representing the binding between the Signal and listener.
*/
add (listener, listenerContext, priority) {
validateListener(listener, 'add');
var prevIndex = this._indexOfListener(listener, listenerContext),
binding;
if (prevIndex !== -1) {
binding = this._bindings[prevIndex];
if (binding.isOnce() !== false) {
throw new Error('You cannot addOnce() then add() the same listener without removing the relationship first.');
}
} else {
binding = new SignalBinding(this, listener, false, listenerContext, priority);
//simplified insertion sort
var n = this._bindings.length;
do { --n; } while (this._bindings[n] && binding._priority <= this._bindings[n]._priority);
this._bindings.splice(n + 1, 0, binding);
}
if(this.memorize && this._prevParams){
binding.execute(this._prevParams);
}
return binding;
}
/**
* Remove a single listener from the dispatch queue.
* @param {Function} listener Handler function that should be removed.
* @param {Object} [context] Execution context (since you can add the same handler multiple times if executing in a different context).
* @return {Function} Listener handler function.
*/
remove (listener, context) {
validateListener(listener, 'remove');
var i = this._indexOfListener(listener, context);
if (i !== -1) {
this._bindings[i]._destroy(); //no reason to a SignalBinding exist if it isn't attached to a signal
this._bindings.splice(i, 1);
}
return listener;
}
/**
* Remove all listeners from the Signal.
*/
removeAll () {
var n = this._bindings.length;
while (n--) {
this._bindings[n]._destroy();
}
this._bindings.length = 0;
}
/**
* Dispatch/Broadcast Signal to all listeners added to the queue.
* @param {...*} [params] Parameters that should be passed to each handler.
*/
dispatch (...paramsArr) {
if (! this.active) {
return;
}
var n = this._bindings.length,
bindings;
if (this.memorize) {
this._prevParams = paramsArr;
}
if (! n) {
//should come after memorize
return;
}
bindings = this._bindings.slice(); //clone array in case add/remove items during dispatch
//execute all callbacks until end of the list or until a callback returns `false` or stops propagation
//reverse loop since listeners with higher priority will be added at the end of the list
do { n--; } while (bindings[n] && bindings[n].execute(paramsArr) !== false);
}
/**
* Remove all bindings from signal and destroy any reference to external objects (destroy Signal object).
* <p><strong>IMPORTANT:</strong> calling any method on the signal instance after calling dispose will throw errors.</p>
*/
dispose () {
this.removeAll();
delete this._bindings;
delete this._prevParams;
}
}
// Namespace -----------------------------------------------------
//================================================================
var signals = Signal;
/**
* Custom event broadcaster
* @see Signal
*/
// alias for backwards compatibility (see #gh-44)
signals.Signal = Signal;
global.signals = signals;
})(this);

View file

@ -4,10 +4,4 @@
Author: Miller Medeiros
Version: 1.0.0 - Build: 268 (2012/11/29 05:48 PM)
*/
(function(i){function h(a,b,c,d,e){this._listener=b;this._isOnce=c;this.context=d;this._signal=a;this._priority=e||0}function g(a,b){if(typeof a!=="function")throw Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",b));}function e(){this._bindings=[];this._prevParams=null;var a=this;this.dispatch=function(){e.prototype.dispatch.apply(a,arguments)}}h.prototype={active:!0,params:null,execute:function(a){var b;this.active&&this._listener&&(a=this.params?this.params.concat(a):
a,b=this._listener.apply(this.context,a),this._isOnce&&this.detach());return b},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal;delete this._listener;delete this.context},toString:function(){return"[SignalBinding isOnce:"+this._isOnce+
", isBound:"+this.isBound()+", active:"+this.active+"]"}};e.prototype={VERSION:"1.0.0",memorize:!1,_shouldPropagate:!0,active:!0,_registerListener:function(a,b,c,d){var e=this._indexOfListener(a,c);if(e!==-1){if(a=this._bindings[e],a.isOnce()!==b)throw Error("You cannot add"+(b?"":"Once")+"() then add"+(!b?"":"Once")+"() the same listener without removing the relationship first.");}else a=new h(this,a,b,c,d),this._addBinding(a);this.memorize&&this._prevParams&&a.execute(this._prevParams);return a},
_addBinding:function(a){var b=this._bindings.length;do--b;while(this._bindings[b]&&a._priority<=this._bindings[b]._priority);this._bindings.splice(b+1,0,a)},_indexOfListener:function(a,b){for(var c=this._bindings.length,d;c--;)if(d=this._bindings[c],d._listener===a&&d.context===b)return c;return-1},has:function(a,b){return this._indexOfListener(a,b)!==-1},add:function(a,b,c){g(a,"add");return this._registerListener(a,!1,b,c)},addOnce:function(a,b,c){g(a,"addOnce");return this._registerListener(a,
!0,b,c)},remove:function(a,b){g(a,"remove");var c=this._indexOfListener(a,b);c!==-1&&(this._bindings[c]._destroy(),this._bindings.splice(c,1));return a},removeAll:function(){for(var a=this._bindings.length;a--;)this._bindings[a]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(a){if(this.active){var b=Array.prototype.slice.call(arguments),c=this._bindings.length,d;if(this.memorize)this._prevParams=
b;if(c){d=this._bindings.slice();this._shouldPropagate=!0;do c--;while(d[c]&&this._shouldPropagate&&d[c].execute(b)!==!1)}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll();delete this._bindings;delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};var f=e;f.Signal=e;typeof define==="function"&&define.amd?define(function(){return f}):typeof module!=="undefined"&&module.exports?module.exports=f:i.signals=
f})(this);
(i=>{class t{constructor(i,t,e,s,n){this.active=!0,this.params=null,this._listener=t,this._isOnce=e,this.context=s,this._signal=i,this._priority=n||0}execute(i){var t,e;return this.active&&this._listener&&(e=this.params?this.params.concat(i):i,t=this._listener.apply(this.context,e),this._isOnce&&this.detach()),t}detach(){return this.isBound()?this._signal.remove(this._listener,this.context):null}isBound(){return!!this._signal&&!!this._listener}isOnce(){return this._isOnce}getListener(){return this._listener}getSignal(){return this._signal}_destroy(){delete this._signal,delete this._listener,delete this.context}}function e(i,t){if("function"!=typeof i)throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",t))}class s{constructor(){this.memorize=!1,this.active=!0,this._bindings=[],this._prevParams=null;var i=this;this.dispatch=((...t)=>s.prototype.dispatch.apply(i,t))}_indexOfListener(i,t){for(var e,s=this._bindings.length;s--;)if((e=this._bindings[s])._listener===i&&e.context===t)return s;return-1}add(i,s,n){e(i,"add");var r,h=this._indexOfListener(i,s);if(-1!==h){if(!1!==(r=this._bindings[h]).isOnce())throw new Error("You cannot addOnce() then add() the same listener without removing the relationship first.")}else{r=new t(this,i,!1,s,n);var a=this._bindings.length;do{--a}while(this._bindings[a]&&r._priority<=this._bindings[a]._priority);this._bindings.splice(a+1,0,r)}return this.memorize&&this._prevParams&&r.execute(this._prevParams),r}remove(i,t){e(i,"remove");var s=this._indexOfListener(i,t);return-1!==s&&(this._bindings[s]._destroy(),this._bindings.splice(s,1)),i}removeAll(){for(var i=this._bindings.length;i--;)this._bindings[i]._destroy();this._bindings.length=0}dispatch(...i){if(this.active){var t,e=this._bindings.length;if(this.memorize&&(this._prevParams=i),e){t=this._bindings.slice();do{e--}while(t[e]&&!1!==t[e].execute(i))}}}dispose(){this.removeAll(),delete this._bindings,delete this._prevParams}}var n=s;n.Signal=s,i.signals=n})(this);