33 lines
21 KiB
JavaScript
33 lines
21 KiB
JavaScript
|
define("taoCe/controller/home/custom-scrollbar",["jquery"],function(jQuery){!function($){$.fn.customScrollbar=function(options,args){var defaultOptions={skin:void 0,hScroll:!0,vScroll:!0,updateOnWindowResize:!1,animationSpeed:300,onCustomScroll:void 0,swipeSpeed:1,wheelSpeed:40,fixedThumbWidth:void 0,fixedThumbHeight:void 0,preventDefaultScroll:!1},Scrollable=function(element,options){this.$element=$(element),this.options=options,this.addScrollableClass(),this.addSkinClass(),this.addScrollBarComponents(),this.options.vScroll&&(this.vScrollbar=new Scrollbar(this,new VSizing)),this.options.hScroll&&(this.hScrollbar=new Scrollbar(this,new HSizing)),this.$element.data("scrollable",this),
|
||
|
this.initKeyboardScrolling(),this.bindEvents()};Scrollable.prototype={addScrollableClass:function(){this.$element.hasClass("scrollable")||(this.scrollableAdded=!0,this.$element.addClass("scrollable"))},removeScrollableClass:function(){this.scrollableAdded&&this.$element.removeClass("scrollable")},addSkinClass:function(){"string"!=typeof this.options.skin||this.$element.hasClass(this.options.skin)||(this.skinClassAdded=!0,this.$element.addClass(this.options.skin))},removeSkinClass:function(){this.skinClassAdded&&this.$element.removeClass(this.options.skin)},addScrollBarComponents:function(){this.assignViewPort(),0==this.$viewPort.length&&(this.$element.wrapInner('<div class="viewport" />'),
|
||
|
this.assignViewPort(),this.viewPortAdded=!0),this.assignOverview(),0==this.$overview.length&&(this.$viewPort.wrapInner('<div class="overview" />'),this.assignOverview(),this.overviewAdded=!0),this.addScrollBar("vertical","prepend"),this.addScrollBar("horizontal","append")},removeScrollbarComponents:function(){this.removeScrollbar("vertical"),this.removeScrollbar("horizontal"),this.overviewAdded&&this.$element.unwrap(),this.viewPortAdded&&this.$element.unwrap()},removeScrollbar:function(orientation){this[orientation+"ScrollbarAdded"]&&this.$element.find(".scroll-bar."+orientation).remove()},assignViewPort:function(){this.$viewPort=this.$element.find(".viewport");
|
||
|
},assignOverview:function(){this.$overview=this.$viewPort.find(".overview")},addScrollBar:function(orientation,fun){0==this.$element.find(".scroll-bar."+orientation).length&&(this.$element[fun]("<div class='scroll-bar "+orientation+"'><div class='thumb'></div></div>"),this[orientation+"ScrollbarAdded"]=!0)},resize:function(keepPosition){this.vScrollbar&&this.vScrollbar.resize(keepPosition),this.hScrollbar&&this.hScrollbar.resize(keepPosition)},scrollTo:function(element){this.vScrollbar&&this.vScrollbar.scrollToElement(element),this.hScrollbar&&this.hScrollbar.scrollToElement(element)},scrollToXY:function(x,y){this.scrollToX(x),this.scrollToY(y)},scrollToX:function(x){
|
||
|
this.hScrollbar&&this.hScrollbar.scrollOverviewTo(x,!0)},scrollToY:function(y){this.vScrollbar&&this.vScrollbar.scrollOverviewTo(y,!0)},scrollByX:function(x){this.hScrollbar&&this.scrollToX(this.hScrollbar.overviewPosition()+x)},scrollByY:function(y){this.vScrollbar&&this.scrollToY(this.vScrollbar.overviewPosition()+y)},remove:function(){this.removeScrollableClass(),this.removeSkinClass(),this.removeScrollbarComponents(),this.$element.data("scrollable",null),this.removeKeyboardScrolling(),this.vScrollbar&&this.vScrollbar.remove(),this.hScrollbar&&this.hScrollbar.remove()},setAnimationSpeed:function(speed){this.options.animationSpeed=speed},isInside:function(element,wrappingElement){
|
||
|
var $element=$(element),$wrappingElement=$(wrappingElement),elementOffset=$element.offset(),wrappingElementOffset=$wrappingElement.offset();return elementOffset.top>=wrappingElementOffset.top&&elementOffset.left>=wrappingElementOffset.left&&elementOffset.top+$element.height()<=wrappingElementOffset.top+$wrappingElement.height()&&elementOffset.left+$element.width()<=wrappingElementOffset.left+$wrappingElement.width()},initKeyboardScrolling:function(){var _this=this;this.elementKeydown=function(event){document.activeElement===_this.$element[0]&&(_this.vScrollbar&&_this.vScrollbar.keyScroll(event),_this.hScrollbar&&_this.hScrollbar.keyScroll(event))},this.$element.attr("tabindex","-1").keydown(this.elementKeydown);
|
||
|
},removeKeyboardScrolling:function(){this.$element.removeAttr("tabindex").unbind("keydown",this.elementKeydown)},bindEvents:function(){this.options.onCustomScroll&&this.$element.on("customScroll",this.options.onCustomScroll)}};var Scrollbar=function(scrollable,sizing){this.scrollable=scrollable,this.sizing=sizing,this.$scrollBar=this.sizing.scrollBar(this.scrollable.$element),this.$thumb=this.$scrollBar.find(".thumb"),this.setScrollPosition(0,0),this.resize(),this.initMouseMoveScrolling(),this.initMouseWheelScrolling(),this.initTouchScrolling(),this.initMouseClickScrolling(),this.initWindowResize()};Scrollbar.prototype={resize:function(keepPosition){this.overviewSize=this.sizing.size(this.scrollable.$overview),
|
||
|
this.calculateViewPortSize(),this.sizing.size(this.scrollable.$viewPort,this.viewPortSize),this.ratio=this.viewPortSize/this.overviewSize,this.sizing.size(this.$scrollBar,this.viewPortSize),this.thumbSize=this.calculateThumbSize(),this.sizing.size(this.$thumb,this.thumbSize),this.maxThumbPosition=this.calculateMaxThumbPosition(),this.maxOverviewPosition=this.calculateMaxOverviewPosition(),this.enabled=this.overviewSize>this.viewPortSize,void 0===this.scrollPercent&&(this.scrollPercent=0),this.enabled?this.rescroll(keepPosition):this.setScrollPosition(0,0),this.$scrollBar.toggle(this.enabled)},calculateViewPortSize:function(){var elementSize=this.sizing.size(this.scrollable.$element);
|
||
|
if(elementSize>0&&!this.maxSizeUsed)this.viewPortSize=elementSize,this.maxSizeUsed=!1;else{var maxSize=this.sizing.maxSize(this.scrollable.$element);this.viewPortSize=Math.min(maxSize,this.overviewSize),this.maxSizeUsed=!0}},calculateThumbSize:function(){var size,fixedSize=this.sizing.fixedThumbSize(this.scrollable.options);return size=fixedSize?fixedSize:this.ratio*this.viewPortSize,Math.max(size,this.sizing.minSize(this.$thumb))},initMouseMoveScrolling:function(){var _this=this;this.$thumb.mousedown(function(event){_this.enabled&&_this.startMouseMoveScrolling(event)}),this.documentMouseup=function(event){_this.stopMouseMoveScrolling(event)},$(document).mouseup(this.documentMouseup),
|
||
|
this.documentMousemove=function(event){_this.mouseMoveScroll(event)},$(document).mousemove(this.documentMousemove),this.$thumb.click(function(event){event.stopPropagation()})},removeMouseMoveScrolling:function(){this.$thumb.unbind(),$(document).unbind("mouseup",this.documentMouseup),$(document).unbind("mousemove",this.documentMousemove)},initMouseWheelScrolling:function(){var _this=this;this.scrollable.$element.mousewheel(function(event,delta,deltaX,deltaY){if(_this.enabled){var scrolled=_this.mouseWheelScroll(deltaX,deltaY);_this.stopEventConditionally(event,scrolled)}})},removeMouseWheelScrolling:function(){this.scrollable.$element.unbind("mousewheel")},initTouchScrolling:function(){
|
||
|
if(document.addEventListener){var _this=this;this.elementTouchstart=function(event){_this.enabled&&_this.startTouchScrolling(event)},this.scrollable.$element[0].addEventListener("touchstart",this.elementTouchstart),this.documentTouchmove=function(event){_this.touchScroll(event)},document.addEventListener("touchmove",this.documentTouchmove),this.elementTouchend=function(event){_this.stopTouchScrolling(event)},this.scrollable.$element[0].addEventListener("touchend",this.elementTouchend)}},removeTouchScrolling:function(){document.addEventListener&&(this.scrollable.$element[0].removeEventListener("touchstart",this.elementTouchstart),document.removeEventListener("touchmove",this.documentTouchmove),
|
||
|
this.scrollable.$element[0].removeEventListener("touchend",this.elementTouchend))},initMouseClickScrolling:function(){var _this=this;this.scrollBarClick=function(event){_this.mouseClickScroll(event)},this.$scrollBar.click(this.scrollBarClick)},removeMouseClickScrolling:function(){this.$scrollBar.unbind("click",this.scrollBarClick)},initWindowResize:function(){if(this.scrollable.options.updateOnWindowResize){var _this=this;this.windowResize=function(){_this.resize()},$(window).resize(this.windowResize)}},removeWindowResize:function(){$(window).unbind("resize",this.windowResize)},isKeyScrolling:function(key){return null!=this.keyScrollDelta(key)},keyScrollDelta:function(key){
|
||
|
for(var scrollingKey in this.sizing.scrollingKeys)if(scrollingKey==key)return this.sizing.scrollingKeys[key](this.viewPortSize);return null},startMouseMoveScrolling:function(event){this.mouseMoveScrolling=!0,$("html").addClass("not-selectable"),this.setUnselectable($("html"),"on"),this.setScrollEvent(event)},stopMouseMoveScrolling:function(event){this.mouseMoveScrolling=!1,$("html").removeClass("not-selectable"),this.setUnselectable($("html"),null)},setUnselectable:function(element,value){element.attr("unselectable")!=value&&(element.attr("unselectable",value),element.find(":not(input)").attr("unselectable",value))},mouseMoveScroll:function(event){if(this.mouseMoveScrolling){
|
||
|
var delta=this.sizing.mouseDelta(this.scrollEvent,event);this.scrollThumbBy(delta),this.setScrollEvent(event)}},startTouchScrolling:function(event){event.touches&&1==event.touches.length&&(this.setScrollEvent(event.touches[0]),this.touchScrolling=!0,event.stopPropagation())},touchScroll:function(event){if(this.touchScrolling&&event.touches&&1==event.touches.length){var delta=-this.sizing.mouseDelta(this.scrollEvent,event.touches[0])*this.scrollable.options.swipeSpeed,scrolled=this.scrollOverviewBy(delta);scrolled&&this.setScrollEvent(event.touches[0]),this.stopEventConditionally(event,scrolled)}},stopTouchScrolling:function(event){this.touchScrolling=!1,event.stopPropagation();
|
||
|
},mouseWheelScroll:function(deltaX,deltaY){var delta=-this.sizing.wheelDelta(deltaX,deltaY)*this.scrollable.options.wheelSpeed;if(0!=delta)return this.scrollOverviewBy(delta)},mouseClickScroll:function(event){var delta=this.viewPortSize-20;event["page"+this.sizing.scrollAxis()]<this.$thumb.offset()[this.sizing.offsetComponent()]&&(delta=-delta),this.scrollOverviewBy(delta)},keyScroll:function(event){var keyDown=event.which;if(this.enabled&&this.isKeyScrolling(keyDown)){var scrolled=this.scrollOverviewBy(this.keyScrollDelta(keyDown));this.stopEventConditionally(event,scrolled)}},scrollThumbBy:function(delta){var thumbPosition=this.thumbPosition();thumbPosition+=delta,
|
||
|
thumbPosition=this.positionOrMax(thumbPosition,this.maxThumbPosition);var oldScrollPercent=this.scrollPercent;if(this.scrollPercent=thumbPosition/this.maxThumbPosition,oldScrollPercent!=this.scrollPercent){var overviewPosition=thumbPosition*this.maxOverviewPosition/this.maxThumbPosition;return this.setScrollPosition(overviewPosition,thumbPosition),this.triggerCustomScroll(oldScrollPercent),!0}return!1},thumbPosition:function(){return this.$thumb.position()[this.sizing.offsetComponent()]},scrollOverviewBy:function(delta){var overviewPosition=this.overviewPosition()+delta;return this.scrollOverviewTo(overviewPosition,!1)},overviewPosition:function(){return-this.scrollable.$overview.position()[this.sizing.offsetComponent()];
|
||
|
},scrollOverviewTo:function(overviewPosition,animate){overviewPosition=this.positionOrMax(overviewPosition,this.maxOverviewPosition);var oldScrollPercent=this.scrollPercent;if(this.scrollPercent=overviewPosition/this.maxOverviewPosition,oldScrollPercent!=this.scrollPercent){var thumbPosition=this.scrollPercent*this.maxThumbPosition;return animate?this.setScrollPositionWithAnimation(overviewPosition,thumbPosition):this.setScrollPosition(overviewPosition,thumbPosition),this.triggerCustomScroll(oldScrollPercent),!0}return!1},positionOrMax:function(p,max){return p<0?0:p>max?max:p},triggerCustomScroll:function(oldScrollPercent){this.scrollable.$element.trigger("customScroll",{
|
||
|
scrollAxis:this.sizing.scrollAxis(),direction:this.sizing.scrollDirection(oldScrollPercent,this.scrollPercent),scrollPercent:100*this.scrollPercent})},rescroll:function(keepPosition){if(keepPosition){var overviewPosition=this.positionOrMax(this.overviewPosition(),this.maxOverviewPosition);this.scrollPercent=overviewPosition/this.maxOverviewPosition;var thumbPosition=this.scrollPercent*this.maxThumbPosition;this.setScrollPosition(overviewPosition,thumbPosition)}else{var thumbPosition=this.scrollPercent*this.maxThumbPosition,overviewPosition=this.scrollPercent*this.maxOverviewPosition;this.setScrollPosition(overviewPosition,thumbPosition)}},setScrollPosition:function(overviewPosition,thumbPosition){
|
||
|
this.$thumb.css(this.sizing.offsetComponent(),thumbPosition+"px"),this.scrollable.$overview.css(this.sizing.offsetComponent(),-overviewPosition+"px")},setScrollPositionWithAnimation:function(overviewPosition,thumbPosition){var thumbAnimationOpts={},overviewAnimationOpts={};thumbAnimationOpts[this.sizing.offsetComponent()]=thumbPosition+"px",this.$thumb.animate(thumbAnimationOpts,this.scrollable.options.animationSpeed),overviewAnimationOpts[this.sizing.offsetComponent()]=-overviewPosition+"px",this.scrollable.$overview.animate(overviewAnimationOpts,this.scrollable.options.animationSpeed)},calculateMaxThumbPosition:function(){return Math.max(0,this.sizing.size(this.$scrollBar)-this.thumbSize);
|
||
|
},calculateMaxOverviewPosition:function(){return Math.max(0,this.sizing.size(this.scrollable.$overview)-this.sizing.size(this.scrollable.$viewPort))},setScrollEvent:function(event){var attr="page"+this.sizing.scrollAxis();this.scrollEvent&&this.scrollEvent[attr]==event[attr]||(this.scrollEvent={pageX:event.pageX,pageY:event.pageY})},scrollToElement:function(element){var $element=$(element);if(this.sizing.isInside($element,this.scrollable.$overview)&&!this.sizing.isInside($element,this.scrollable.$viewPort)){var elementOffset=$element.offset(),overviewOffset=this.scrollable.$overview.offset();this.scrollable.$viewPort.offset();this.scrollOverviewTo(elementOffset[this.sizing.offsetComponent()]-overviewOffset[this.sizing.offsetComponent()],!0);
|
||
|
}},remove:function(){this.removeMouseMoveScrolling(),this.removeMouseWheelScrolling(),this.removeTouchScrolling(),this.removeMouseClickScrolling(),this.removeWindowResize()},stopEventConditionally:function(event,condition){(condition||this.scrollable.options.preventDefaultScroll)&&(event.preventDefault(),event.stopPropagation())}};var HSizing=function(){};HSizing.prototype={size:function($el,arg){return arg?$el.width(arg):$el.width()},minSize:function($el){return parseInt($el.css("min-width"))||0},maxSize:function($el){return parseInt($el.css("max-width"))||0},fixedThumbSize:function(options){return options.fixedThumbWidth},scrollBar:function($el){return $el.find(".scroll-bar.horizontal");
|
||
|
},mouseDelta:function(event1,event2){return event2.pageX-event1.pageX},offsetComponent:function(){return"left"},wheelDelta:function(deltaX,deltaY){return deltaX},scrollAxis:function(){return"X"},scrollDirection:function(oldPercent,newPercent){return oldPercent<newPercent?"right":"left"},scrollingKeys:{37:function(viewPortSize){return-10},39:function(viewPortSize){return 10}},isInside:function(element,wrappingElement){var $element=$(element),$wrappingElement=$(wrappingElement),elementOffset=$element.offset(),wrappingElementOffset=$wrappingElement.offset();return elementOffset.left>=wrappingElementOffset.left&&elementOffset.left+$element.width()<=wrappingElementOffset.left+$wrappingElement.width();
|
||
|
}};var VSizing=function(){};return VSizing.prototype={size:function($el,arg){return arg?$el.height(arg):$el.height()},minSize:function($el){return parseInt($el.css("min-height"))||0},maxSize:function($el){return parseInt($el.css("max-height"))||0},fixedThumbSize:function(options){return options.fixedThumbHeight},scrollBar:function($el){return $el.find(".scroll-bar.vertical")},mouseDelta:function(event1,event2){return event2.pageY-event1.pageY},offsetComponent:function(){return"top"},wheelDelta:function(deltaX,deltaY){return deltaY},scrollAxis:function(){return"Y"},scrollDirection:function(oldPercent,newPercent){return oldPercent<newPercent?"down":"up"},scrollingKeys:{
|
||
|
38:function(viewPortSize){return-10},40:function(viewPortSize){return 10},33:function(viewPortSize){return-(viewPortSize-20)},34:function(viewPortSize){return viewPortSize-20}},isInside:function(element,wrappingElement){var $element=$(element),$wrappingElement=$(wrappingElement),elementOffset=$element.offset(),wrappingElementOffset=$wrappingElement.offset();return elementOffset.top>=wrappingElementOffset.top&&elementOffset.top+$element.height()<=wrappingElementOffset.top+$wrappingElement.height()}},this.each(function(){if(void 0==options&&(options=defaultOptions),"string"==typeof options){var scrollable=$(this).data("scrollable");scrollable&&scrollable[options](args);
|
||
|
}else{if("object"!=typeof options)throw"Invalid type of options";options=$.extend(defaultOptions,options),new Scrollable($(this),options)}})}}(jQuery),function($){function handler(event){var orgEvent=event||window.event,args=[].slice.call(arguments,1),delta=0,deltaX=0,deltaY=0;return event=$.event.fix(orgEvent),event.type="mousewheel",orgEvent.wheelDelta&&(delta=orgEvent.wheelDelta/120),orgEvent.detail&&(delta=-orgEvent.detail/3),deltaY=delta,void 0!==orgEvent.axis&&orgEvent.axis===orgEvent.HORIZONTAL_AXIS&&(deltaY=0,deltaX=delta),void 0!==orgEvent.wheelDeltaY&&(deltaY=orgEvent.wheelDeltaY/120),void 0!==orgEvent.wheelDeltaX&&(deltaX=orgEvent.wheelDeltaX/120),
|
||
|
args.unshift(event,delta,deltaX,deltaY),($.event.dispatch||$.event.handle).apply(this,args)}var types=["DOMMouseScroll","mousewheel"];if($.event.fixHooks)for(var i=types.length;i;)$.event.fixHooks[types[--i]]=$.event.mouseHooks;$.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var i=types.length;i;)this.addEventListener(types[--i],handler,!1);else this.onmousewheel=handler},teardown:function(){if(this.removeEventListener)for(var i=types.length;i;)this.removeEventListener(types[--i],handler,!1);else this.onmousewheel=null}},$.fn.extend({mousewheel:function(fn){return fn?this.bind("mousewheel",fn):this.trigger("mousewheel")},unmousewheel:function(fn){
|
||
|
return this.unbind("mousewheel",fn)}})}(jQuery)}),define("taoCe/controller/home/splash",["jquery","taoCe/controller/home/custom-scrollbar"],function($){"use strict";var SplashScreen={init:function(isHomePage){this.$splashScreen=$("#splash-screen");var $splashWrapper=$(".splash-screen-wrapper"),$splashDesc=$(".desc",this.$splashScreen),$splashDiagram=$(".diagram",this.$splashScreen);this.redirectUrl="",$splashWrapper.css("display","block"),isHomePage?$(".modal-footer",this.$splashScreen).show():$(".modal-footer",this.$splashScreen).hide(),$("[data-module-name]",$splashDiagram).each(function(){var $this=$(this);$this.hasClass("disabled")&&($this.find("span").remove(),
|
||
|
$this.prepend('<span class="icon-lock"></span>'))}),$splashDesc.customScrollbar({updateOnWindowResize:!0,skin:"gray-skin",hScroll:!1}),this.$splashScreen.modal({disableClosing:isHomePage}),this.initNav(),this.initModulesNav(),this.initCloseButton()},initNav:function(){$(".modal-nav a",this.$splashScreen).on("click",function(){var selectedEl=$(this),selectedPanelId=selectedEl.data("panel");$(".modal-nav li").removeClass("active"),$("a[data-panel='"+selectedPanelId+"']").parent().addClass("active"),$(".panels").hide(),$("div[data-panel-id='"+selectedPanelId+"']").show()})},initModulesNav:function(){var splashObj=this;$("[data-module-name]",this.$splashScreen).not(".disabled").on("click",function(){
|
||
|
var selectedEl=$(this),selectedModuleName=selectedEl.data("module-name");if(splashObj.redirectUrl=selectedEl.data("url"),$("#splash-close-btn").removeAttr("disabled").find(".module-name").text(selectedEl.text()),selectedEl.hasClass("new-module"))$(".module-desc>span").attr({class:""});else{var selectedClass=selectedEl.hasClass("groups")?$(".test-takers").find("span").first().attr("class"):selectedEl.find("span").first().attr("class");$(".module-desc>span").attr({class:selectedClass})}$("[data-module-name]").removeClass("active"),$(".module-desc").hide(),selectedEl.addClass("active"),$("div[data-module='"+selectedModuleName+"']").show(),$(".desc").customScrollbar("resize",!0);
|
||
|
})},initCloseButton:function(){var splashObj=this,$closeButton=$("#splash-close-btn");$(document).on("keypress",function(e){13===e.which&&$closeButton.trigger("click")}),this.$splashScreen.on("closed.modal",function(){$(document).off("keypress")}),$closeButton.on("click",function(e){e.preventDefault(),$("#nosplash").prop("checked")&&(splashObj.redirectUrl+="&nosplash=true"),splashObj.closeSplash(splashObj.redirectUrl)})},closeSplash:function(url){window.location=url},adaptHeight:function(){var splashObj=this,$splashContentWrap=splashObj.find(".splash-content-wrap"),maxHeight=$(window).height()-splashObj.find(".modal-title").offset().top-40;$splashContentWrap.css({
|
||
|
maxHeight:maxHeight})}};return SplashScreen}),define("taoCe/controller/home",["jquery","helpers","taoCe/controller/home/splash"],function($,helpers,splash){"use strict";var $mainContainer=$("body"),homeController={entrySplash:!0,start:function(){var self=this;0===$("#splash-screen",$mainContainer).length?$.get(helpers._url("splash","Home","taoCe")).success(function(response){var $splash=$(response);$splash.css("display","none"),$mainContainer.append($splash),splash.init(self.entrySplash)}):splash.init(self.entrySplash)}};return homeController}),define("taoCe/controller/help",["lodash","taoCe/controller/home"],function(_,homeController){"use strict";return _.defaults({
|
||
|
entrySplash:!1},homeController)}),define("taoCe/controller/routes",[],function(){"use strict";return{Home:{css:"home.css"},Main:{actions:{index:"controller/home"}}}}),define("taoCe/loader/controllers.min",function(){});
|
||
|
//# sourceMappingURL=controllers.min.js.map
|