ng-essentials
Version:
Ready to use all type of essential components for an web application.
1 lines • 4.63 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/common"],e):e(t["ng-essential"]={},t.core,t.common)}(this,function(t,e,o){"use strict";var n=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{declarations:[],imports:[o.CommonModule],exports:[],providers:[]}]}],t}(),i=function(){function t(t){this.activeIndex=-1,this.dataJson=t.data}return t.prototype.start=function(){this.dataJson?(this.destroy(),$("body").append(this.getHtmlRelatedToThisIntro()),this.bindActions(),this.moveToNext()):console.info("Data is not provided.")},t.prototype.bindActions=function(){var t=this;document.getElementById("next_btn").addEventListener("click",function(){t.moveToNext()}),document.getElementById("prev_btn").addEventListener("click",function(){t.moveToPrevious()}),document.getElementById("done_btn").addEventListener("click",function(){t.destroy()}),document.getElementsByClassName("teach_app_backdrop")[0].addEventListener("click",function(){t.destroy()})},t.prototype.destroy=function(){this.beforeMoveInterceptor(),$(".teach_app_container").remove()},t.prototype.validate=function(){return!!this.activeIndex&&!(this.activeIndex<0||this.activeIndex>=this.dataJson.length)},t.prototype.beforeMoveInterceptor=function(){if(this.validate()){console.log(this.activeIndex);var t=this.dataJson[this.activeIndex],e=$(t.selector);$(e).removeClass("teach_app_active_elem")}},t.prototype.moveToNext=function(){this.beforeMoveInterceptor(),this.activeIndex++,this.inItMsgObj(this.dataJson[this.activeIndex])},t.prototype.moveToPrevious=function(){this.beforeMoveInterceptor(),this.activeIndex--,this.inItMsgObj(this.dataJson[this.activeIndex])},t.prototype.moveStepInterceptor=function(){$("#arrow_pointer").removeClass("arrow-left"),$("#arrow_pointer").removeClass("arrow-right"),$("#arrow_pointer").removeClass("arrow-top"),$("#arrow_pointer").removeClass("arrow-bottom"),$(".teach_app_msg_container").css({left:"auto",right:"auto",top:"auto",bottom:"auto"}),$("#next_btn").hide(),$("#prev_btn").hide(),$("#done_btn").hide(),0==this.activeIndex?1==this.dataJson.length?$("#done_btn").show():$("#next_btn").show():this.activeIndex>=this.dataJson.length-1?($("#prev_btn").show(),$("#done_btn").show()):($("#next_btn").show(),$("#prev_btn").show())},t.prototype.inItMsgObj=function(t){switch(this.moveStepInterceptor(),$("#message_display").html(t.message),this.highlightSelector(t.selector),t.position){case"left":this.showMsgOnLeft(t.selector);break;case"top":this.showMsgOnTop(t.selector);break;case"right":this.showMsgOnRight(t.selector);break;case"bottom":this.showMsgOnBottom(t.selector)}},t.prototype.showMsgOnLeft=function(t){var e=$(".teach_app_msg_container"),o=e.innerWidth();$("#arrow_pointer").addClass("arrow-right"),e.css({display:"block",left:-(o+15),top:"auto",right:"auto",bottom:"auto"})},t.prototype.showMsgOnTop=function(t){var e=$(".teach_app_msg_container"),o=e.innerHeight();$("#arrow_pointer").addClass("arrow-bottom"),e.css({display:"block",top:-(o+15),left:"auto",right:"auto",bottom:"auto"})},t.prototype.showMsgOnBottom=function(t){var e=$(".teach_app_msg_container");$("#arrow_pointer").addClass("arrow-top");var o=$(t).innerHeight();e.css({display:"block",top:o+25,left:"auto",right:"auto",bottom:"auto"})},t.prototype.showMsgOnRight=function(t){var e=$(".teach_app_msg_container"),o=$(t).innerWidth();$("#arrow_pointer").addClass("arrow-left"),e.css({display:"block",left:o+25,top:"auto",right:"auto",bottom:"auto"})},t.prototype.highlightSelector=function(t){var e=$(t),o=e.offset(),n=(e.position(),e.innerHeight()),i=e.innerWidth();$(".teach_app_elem_container").css({height:n+10,width:i+10,left:o.left-5,top:o.top-10}),$(t).addClass("teach_app_active_elem")},t.prototype.getHtmlRelatedToThisIntro=function(){return'\n <div class="teach_app_container">\n <div class="teach_app_backdrop"></div>\n <div class="teach_app_elem_container">\n <div class="teach_app_msg_container">\n <div id="message_display"></div>\n <div class="teach_app_actions">\n <button id="prev_btn" class="btn btn-link">Prev</button>\n <button id="next_btn" class="btn btn-link">Next</button>\n <button id="done_btn" class="btn btn-link">Done</button>\n </div>\n <div id="arrow_pointer"></div>\n </div>\n </div>\n </div>\n '},t}();t.NgEssentialsModule=n,t.AppIntroService=i,Object.defineProperty(t,"__esModule",{value:!0})});