12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302 |
- /*!
- * Ace v1.4.0
- */
- if (typeof jQuery === 'undefined') { throw new Error('Ace\'s JavaScript requires jQuery') }
- /**
- Required. Ace's Basic File to Initiliaze Different Parts and Some Variables.
- */
- //some basic variables
- (function(undefined) {
- if( !('ace' in window) ) window['ace'] = {}
- if( !('helper' in window['ace']) ) window['ace'].helper = {}
- if( !('vars' in window['ace']) ) window['ace'].vars = {}
- window['ace'].vars['icon'] = ' ace-icon ';
- window['ace'].vars['.icon'] = '.ace-icon';
- ace.vars['touch'] = ('ontouchstart' in window);//(('ontouchstart' in document.documentElement) || (window.DocumentTouch && document instanceof DocumentTouch));
-
- //sometimes the only good way to work around browser's pecularities is to detect them using user-agents
- //though it's not accurate
- var agent = navigator.userAgent
- ace.vars['webkit'] = !!agent.match(/AppleWebKit/i)
- ace.vars['safari'] = !!agent.match(/Safari/i) && !agent.match(/Chrome/i);
- ace.vars['android'] = ace.vars['safari'] && !!agent.match(/Android/i)
- ace.vars['ios_safari'] = !!agent.match(/OS ([4-9])(_\d)+ like Mac OS X/i) && !agent.match(/CriOS/i)
-
- ace.vars['ie'] = window.navigator.msPointerEnabled || (document.all && document.querySelector);//8-11
- ace.vars['old_ie'] = document.all && !document.addEventListener;//8 and below
- ace.vars['very_old_ie'] = document.all && !document.querySelector;//7 and below
- ace.vars['firefox'] = 'MozAppearance' in document.documentElement.style;
-
- ace.vars['non_auto_fixed'] = ace.vars['android'] || ace.vars['ios_safari'];
- })();
- (function($ , undefined) {
- //sometimes we try to use 'tap' event instead of 'click' if jquery mobile plugin is available
- ace['click_event'] = ace.vars['touch'] && $.fn.tap ? 'tap' : 'click';
- })(jQuery);
- //document ready function
- jQuery(function($) {
- basics();
- enableSidebar();
-
- enableDemoAjax();
- handleScrollbars();
-
- dropdownAutoPos();
-
- navbarHelpers();
- sidebarTooltips();
-
- scrollTopBtn();
-
- someBrowserFix();
-
- bsCollapseToggle();
- smallDeviceDropdowns();
-
- ////////////////////////////
- function basics() {
- // for android and ios we don't use "top:auto" when breadcrumbs is fixed
- if(ace.vars['non_auto_fixed']) {
- $('body').addClass('mob-safari');
- }
- ace.vars['transition'] = !!$.support.transition.end
- }
-
- function enableSidebar() {
- //initiate sidebar function
- var $sidebar = $('.sidebar');
- if($.fn.ace_sidebar) $sidebar.ace_sidebar();
- if($.fn.ace_sidebar_scroll) $sidebar.ace_sidebar_scroll({
- //for other options please see documentation
- 'include_toggle': false || ace.vars['safari'] || ace.vars['ios_safari'] //true = include toggle button in the scrollbars
- });
- if($.fn.ace_sidebar_hover) $sidebar.ace_sidebar_hover({
- 'sub_hover_delay': 750,
- 'sub_scroll_style': 'no-track scroll-thin scroll-margin scroll-visible'
- });
- }
-
- //Load content via ajax
- function enableDemoAjax() {
- if(!$.fn.ace_ajax) return;
-
- if(window.Pace) {
- window.paceOptions = {
- ajax: true,
- document: true,
- eventLag: false // disabled
- //elements: {selectors: ['.page-content-area']}
- }
- }
- var demo_ajax_options = {
- 'close_active': true,
-
- 'default_url': 'page/index',//default hash
- 'content_url': function(hash) {
- //***NOTE***
- //this is for Ace demo only, you should change it to return a valid URL
- //please refer to documentation for more info
- if( !hash.match(/^page\//) ) return false;
- var path = document.location.pathname;
- //for example in Ace HTML demo version we convert /ajax/index.html#page/gallery to > /ajax/content/gallery.html and load it
- if(path.match(/(\/ajax\/)(index\.html)?/))
- return path.replace(/(\/ajax\/)(index\.html)?/, '/ajax/content/'+hash.replace(/^page\//, '')+'.html') ;
- //for example in Ace PHP demo version we convert "ajax.php#page/dashboard" to "ajax.php?page=dashboard" and load it
- return path + "?" + hash.replace(/\//, "=");
- }
- }
-
- //for IE9 and below we exclude PACE loader (using conditional IE comments)
- //for other browsers we use the following extra ajax loader options
- if(window.Pace) {
- demo_ajax_options['loading_overlay'] = 'body';//the opaque overlay is applied to 'body'
- }
- //initiate ajax loading on this element( which is .page-content-area[data-ajax-content=true] in Ace's demo)
- $('[data-ajax-content=true]').ace_ajax(demo_ajax_options)
- //if general error happens and ajax is working, let's stop loading icon & PACE
- $(window).on('error.ace_ajax', function() {
- $('[data-ajax-content=true]').each(function() {
- var $this = $(this);
- if( $this.ace_ajax('working') ) {
- if(window.Pace && Pace.running) Pace.stop();
- $this.ace_ajax('stopLoading', true);
- }
- })
- })
- }
- /////////////////////////////
- function handleScrollbars() {
- //add scrollbars for navbar dropdowns
- var has_scroll = !!$.fn.ace_scroll;
- if(has_scroll) $('.dropdown-content').ace_scroll({reset: false, mouseWheelLock: true})
- //reset scrolls bars on window resize
- if(has_scroll && !ace.vars['old_ie']) {//IE has an issue with widget fullscreen on ajax?!!!
- $(window).on('resize.reset_scroll', function() {
- $('.ace-scroll:not(.scroll-disabled)').not(':hidden').ace_scroll('reset');
- });
- if(has_scroll) $(document).on('settings.ace.reset_scroll', function(e, name) {
- if(name == 'sidebar_collapsed') $('.ace-scroll:not(.scroll-disabled)').not(':hidden').ace_scroll('reset');
- });
- }
- }
- function dropdownAutoPos() {
- //change a dropdown to "dropup" depending on its position
- $(document).on('click.dropdown.pos', '.dropdown-toggle[data-position="auto"]', function() {
- var offset = $(this).offset();
- var parent = $(this.parentNode);
- if ( parseInt(offset.top + $(this).height()) + 50
- >
- (ace.helper.scrollTop() + ace.helper.winHeight() - parent.find('.dropdown-menu').eq(0).height())
- ) parent.addClass('dropup');
- else parent.removeClass('dropup');
- });
- }
-
- function navbarHelpers() {
- //prevent dropdowns from hiding when a from is clicked
- /**$(document).on('click', '.dropdown-navbar form', function(e){
- e.stopPropagation();
- });*/
- //disable navbar icon animation upon click
- $('.ace-nav [class*="icon-animated-"]').closest('a').one('click', function(){
- var icon = $(this).find('[class*="icon-animated-"]').eq(0);
- var $match = icon.attr('class').match(/icon\-animated\-([\d\w]+)/);
- icon.removeClass($match[0]);
- });
- //prevent dropdowns from hiding when a tab is selected
- $(document).on('click', '.dropdown-navbar .nav-tabs', function(e){
- e.stopPropagation();
- var $this , href
- var that = e.target
- if( ($this = $(e.target).closest('[data-toggle=tab]')) && $this.length > 0) {
- $this.tab('show');
- e.preventDefault();
- $(window).triggerHandler('resize.navbar.dropdown')
- }
- });
- }
-
- function sidebarTooltips() {
- //tooltip in sidebar items
- $('.sidebar .nav-list .badge[title],.sidebar .nav-list .badge[title]').each(function() {
- var tooltip_class = $(this).attr('class').match(/tooltip\-(?:\w+)/);
- tooltip_class = tooltip_class ? tooltip_class[0] : 'tooltip-error';
- $(this).tooltip({
- 'placement': function (context, source) {
- var offset = $(source).offset();
- if( parseInt(offset.left) < parseInt(document.body.scrollWidth / 2) ) return 'right';
- return 'left';
- },
- container: 'body',
- template: '<div class="tooltip '+tooltip_class+'"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
- });
- });
-
- //or something like this if items are dynamically inserted
- /**
- $('.sidebar').tooltip({
- 'placement': function (context, source) {
- var offset = $(source).offset();
- if( parseInt(offset.left) < parseInt(document.body.scrollWidth / 2) ) return 'right';
- return 'left';
- },
- selector: '.nav-list .badge[title],.nav-list .label[title]',
- container: 'body',
- template: '<div class="tooltip tooltip-error"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
- });
- */
- }
-
-
- function scrollTopBtn() {
- //the scroll to top button
- var scroll_btn = $('.btn-scroll-up');
- if(scroll_btn.length > 0) {
- var is_visible = false;
- $(window).on('scroll.scroll_btn', function() {
- var scroll = ace.helper.scrollTop();
- var h = ace.helper.winHeight();
- var body_sH = document.body.scrollHeight;
- if(scroll > parseInt(h / 4) || (scroll > 0 && body_sH >= h && h + scroll >= body_sH - 1)) {//|| for smaller pages, when reached end of page
- if(!is_visible) {
- scroll_btn.addClass('display');
- is_visible = true;
- }
- } else {
- if(is_visible) {
- scroll_btn.removeClass('display');
- is_visible = false;
- }
- }
- }).triggerHandler('scroll.scroll_btn');
- scroll_btn.on(ace.click_event, function(){
- var duration = Math.min(500, Math.max(100, parseInt(ace.helper.scrollTop() / 3)));
- $('html,body').animate({scrollTop: 0}, duration);
- return false;
- });
- }
- }
-
- function someBrowserFix() {
- //chrome and webkit have a problem here when resizing from 479px to more
- //we should force them redraw the navbar!
- if( ace.vars['webkit'] ) {
- var ace_nav = $('.ace-nav').get(0);
- if( ace_nav ) $(window).on('resize.webkit_fix' , function(){
- ace.helper.redraw(ace_nav);
- });
- }
-
-
- //fix an issue with ios safari, when an element is fixed and an input receives focus
- if(ace.vars['ios_safari']) {
- $(document).on('ace.settings.ios_fix', function(e, event_name, event_val) {
- if(event_name != 'navbar_fixed') return;
- $(document).off('focus.ios_fix blur.ios_fix', 'input,textarea,.wysiwyg-editor');
- if(event_val == true) {
- $(document).on('focus.ios_fix', 'input,textarea,.wysiwyg-editor', function() {
- $(window).on('scroll.ios_fix', function() {
- var navbar = $('#navbar').get(0);
- if(navbar) ace.helper.redraw(navbar);
- });
- }).on('blur.ios_fix', 'input,textarea,.wysiwyg-editor', function() {
- $(window).off('scroll.ios_fix');
- })
- }
- }).triggerHandler('ace.settings.ios_fix', ['navbar_fixed', $('#navbar').css('position') == 'fixed']);
- }
- }
-
-
- function bsCollapseToggle() {
- //bootstrap collapse component icon toggle
- $(document).on('hide.bs.collapse show.bs.collapse', function (ev) {
- var panel_id = ev.target.getAttribute('id')
- var panel = $('a[href*="#'+ panel_id+'"]');
- if(panel.length == 0) panel = $('a[data-target*="#'+ panel_id+'"]');
- if(panel.length == 0) return;
- panel.find(ace.vars['.icon']).each(function(){
- var $icon = $(this)
- var $match
- var $icon_down = null
- var $icon_up = null
- if( ($icon_down = $icon.attr('data-icon-show')) ) {
- $icon_up = $icon.attr('data-icon-hide')
- }
- else if( $match = $icon.attr('class').match(/fa\-(.*)\-(up|down)/) ) {
- $icon_down = 'fa-'+$match[1]+'-down'
- $icon_up = 'fa-'+$match[1]+'-up'
- }
- if($icon_down) {
- if(ev.type == 'show') $icon.removeClass($icon_down).addClass($icon_up)
- else $icon.removeClass($icon_up).addClass($icon_down)
-
- return false;//ignore other icons that match, one is enough
- }
- });
- })
- }
-
-
- //in small devices display navbar dropdowns like modal boxes
- function smallDeviceDropdowns() {
- if(ace.vars['old_ie']) return;
-
- $('.ace-nav > li')
- .on('shown.bs.dropdown.navbar', function(e) {
- adjustNavbarDropdown.call(this);
- })
- .on('hidden.bs.dropdown.navbar', function(e) {
- $(window).off('resize.navbar.dropdown');
- resetNavbarDropdown.call(this);
- })
-
- function adjustNavbarDropdown() {
- var $sub = $(this).find('> .dropdown-menu');
- if( $sub.css('position') == 'fixed' ) {
- var win_width = parseInt($(window).width());
- var offset_w = win_width > 320 ? 60 : (win_width > 240 ? 40 : 30);
- var avail_width = parseInt(win_width) - offset_w;
- var avail_height = parseInt($(window).height()) - 30;
-
- var width = parseInt(Math.min(avail_width , 320));
- //we set 'width' here for text wrappings and spacings to take effect before calculating scrollHeight
- $sub.css('width', width);
- var tabbed = false;
- var extra_parts = 0;
- var dropdown_content = $sub.find('.tab-pane.active .dropdown-content.ace-scroll');
- if(dropdown_content.length == 0) dropdown_content = $sub.find('.dropdown-content.ace-scroll');
- else tabbed = true;
- var parent_menu = dropdown_content.closest('.dropdown-menu');
- var scrollHeight = $sub[0].scrollHeight;
- if(dropdown_content.length == 1) {
- //sometimes there's no scroll-content, for example in detached scrollbars
- var content = dropdown_content.find('.scroll-content')[0];
- if(content) {
- scrollHeight = content.scrollHeight;
- }
-
- extra_parts += parent_menu.find('.dropdown-header').outerHeight();
- extra_parts += parent_menu.find('.dropdown-footer').outerHeight();
-
- var tab_content = parent_menu.closest('.tab-content');
- if( tab_content.length != 0 ) {
- extra_parts += tab_content.siblings('.nav-tabs').eq(0).height();
- }
- }
-
-
- var height = parseInt(Math.min(avail_height , 480, scrollHeight + extra_parts));
- var left = parseInt(Math.abs((avail_width + offset_w - width)/2));
- var top = parseInt(Math.abs((avail_height + 30 - height)/2));
-
- var zindex = parseInt($sub.css('z-index')) || 0;
- $sub.css({'height': height, 'left': left, 'right': 'auto', 'top': top - (!tabbed ? 1 : 3)});
- if(dropdown_content.length == 1) {
- if(!ace.vars['touch']) {
- dropdown_content.ace_scroll('update', {size: height - extra_parts}).ace_scroll('enable').ace_scroll('reset');
- }
- else {
- dropdown_content
- .ace_scroll('disable').css('max-height', height - extra_parts).addClass('overflow-scroll');
- }
- }
- $sub.css('height', height + (!tabbed ? 2 : 7));//for bottom border adjustment and tab content paddings
-
-
- if($sub.hasClass('user-menu')) {
- $sub.css('height', '');//because of user-info hiding/showing at different widths, which changes above 'scrollHeight', so we remove it!
-
- //user menu is re-positioned in small widths
- //but we need to re-position again in small heights as well (modal mode)
- var user_info = $(this).find('.user-info');
- if(user_info.length == 1 && user_info.css('position') == 'fixed') {
- user_info.css({'left': left, 'right': 'auto', 'top': top, 'width': width - 2, 'max-width': width - 2, 'z-index': zindex + 1});
- }
- else user_info.css({'left': '', 'right': '', 'top': '', 'width': '', 'max-width': '', 'z-index': ''});
- }
-
- //dropdown's z-index is limited by parent .navbar's z-index (which doesn't make sense because dropdowns are fixed!)
- //so for example when in 'content-slider' page, fixed modal toggle buttons go above are dropdowns
- //so we increase navbar's z-index to fix this!
- $(this).closest('.navbar.navbar-fixed-top').css('z-index', zindex);
- }
- else {
- if($sub.length != 0) resetNavbarDropdown.call(this, $sub);
- }
-
- var self = this;
- $(window)
- .off('resize.navbar.dropdown')
- .one('resize.navbar.dropdown', function() {
- $(self).triggerHandler('shown.bs.dropdown.navbar');
- })
- }
- //reset scrollbars and user menu
- function resetNavbarDropdown($sub) {
- $sub = $sub || $(this).find('> .dropdown-menu');
-
- if($sub.length > 0) {
- $sub
- .css({'width': '', 'height': '', 'left': '', 'right': '', 'top': ''})
- .find('.dropdown-content').each(function() {
- if(ace.vars['touch']) {
- $(this).css('max-height', '').removeClass('overflow-scroll');
- }
- var size = parseInt($(this).attr('data-size') || 0) || $.fn.ace_scroll.defaults.size;
- $(this).ace_scroll('update', {size: size}).ace_scroll('enable').ace_scroll('reset');
- })
-
- if( $sub.hasClass('user-menu') ) {
- var user_info =
- $(this).find('.user-info')
- .css({'left': '', 'right': '', 'top': '', 'width': '', 'max-width': '', 'z-index': ''});
- }
- }
-
- $(this).closest('.navbar').css('z-index', '');
- }
- }
- });//jQuery document ready
- //some ace helper functions
- (function($$ , undefined) {//$$ is ace.helper
- $$.unCamelCase = function(str) {
- return str.replace(/([a-z])([A-Z])/g, function(match, c1, c2){ return c1+'-'+c2.toLowerCase() })
- }
- $$.strToVal = function(str) {
- var res = str.match(/^(?:(true)|(false)|(null)|(\-?[\d]+(?:\.[\d]+)?)|(\[.*\]|\{.*\}))$/i);
- var val = str;
- if(res) {
- if(res[1]) val = true;
- else if(res[2]) val = false;
- else if(res[3]) val = null;
- else if(res[4]) val = parseFloat(str);
- else if(res[5]) {
- try { val = JSON.parse(str) }
- catch (err) {}
- }
- }
- return val;
- }
- $$.getAttrSettings = function(el, attr_list, prefix) {
- var list_type = attr_list instanceof Array ? 1 : 2;
- //attr_list can be Array or Object(key/value)
- var prefix = prefix ? prefix.replace(/([^\-])$/ , '$1-') : '';
- prefix = 'data-' + prefix;
- var settings = {}
- for(var li in attr_list) if(attr_list.hasOwnProperty(li)) {
- var name = list_type == 1 ? attr_list[li] : li;
- var attr_val, attr_name = $$.unCamelCase(name.replace(/[^A-Za-z0-9]{1,}/g , '-')).toLowerCase()
- if( ! ((attr_val = el.getAttribute(prefix + attr_name)) ) ) continue;
- settings[name] = $$.strToVal(attr_val);
- }
- return settings;
- }
- $$.scrollTop = function() {
- return document.scrollTop || document.documentElement.scrollTop || document.body.scrollTop
- }
- $$.winHeight = function() {
- return window.innerHeight || document.documentElement.clientHeight;
- }
- $$.redraw = function(elem, force) {
- var saved_val = elem.style['display'];
- elem.style.display = 'none';
- elem.offsetHeight;
- if(force !== true) {
- elem.style.display = saved_val;
- }
- else {
- //force redraw for example in old IE
- setTimeout(function() {
- elem.style.display = saved_val;
- }, 10);
- }
- }
- })(ace.helper);;/**
- <b>Load content via Ajax </b>. For more information please refer to documentation #basics/ajax
- */
- (function($ , undefined) {
- var ajax_loaded_scripts = {}
- function AceAjax(contentArea, settings) {
- var $contentArea = $(contentArea);
- var self = this;
- $contentArea.attr('data-ajax-content', 'true');
-
- //get a list of 'data-*' attributes that override 'defaults' and 'settings'
- var attrib_values = ace.helper.getAttrSettings(contentArea, $.fn.ace_ajax.defaults);
- this.settings = $.extend({}, $.fn.ace_ajax.defaults, settings, attrib_values);
- var working = false;
- var $overlay = $();//empty set
- this.force_reload = false;//set jQuery ajax's cache option to 'false' to reload content
- this.loadUrl = function(hash, cache) {
- var url = false;
- hash = hash.replace(/^(\#\!)?\#/, '');
-
- this.force_reload = (cache === false)
-
- if(typeof this.settings.content_url === 'function') url = this.settings.content_url(hash);
- if(typeof url === 'string') this.getUrl(url, hash, false);
- }
-
- this.loadAddr = function(url, hash, cache) {
- this.force_reload = (cache === false);
- this.getUrl(url, hash, false);
- }
-
- this.getUrl = function(url, hash, manual_trigger) {
- if(working) {
- return;
- }
-
- var event
- $contentArea.trigger(event = $.Event('ajaxloadstart'), {url: url, hash: hash})
- if (event.isDefaultPrevented()) return;
-
- self.startLoading();
- $.ajax({
- 'url': url,
- 'cache': !this.force_reload
- })
- .error(function() {
- $contentArea.trigger('ajaxloaderror', {url: url, hash: hash});
-
- self.stopLoading(true);
- })
- .done(function(result) {
- $contentArea.trigger('ajaxloaddone', {url: url, hash: hash});
-
- var link_element = null, link_text = '';;
- if(typeof self.settings.update_active === 'function') {
- link_element = self.settings.update_active.call(null, hash, url);
- }
- else if(self.settings.update_active === true && hash) {
- link_element = $('a[data-url="'+hash+'"]');
- if(link_element.length > 0) {
- var nav = link_element.closest('.nav');
- if(nav.length > 0) {
- nav.find('.active').each(function(){
- var $class = 'active';
- if( $(this).hasClass('hover') || self.settings.close_active ) $class += ' open';
-
- $(this).removeClass($class);
- if(self.settings.close_active) {
- $(this).find(' > .submenu').css('display', '');
- }
- })
-
- var active_li = link_element.closest('li').addClass('active').parents('.nav li').addClass('active open');
- nav.closest('.sidebar[data-sidebar-scroll=true]').each(function() {
- var $this = $(this);
- $this.ace_sidebar_scroll('reset');
- if(manual_trigger) $this.ace_sidebar_scroll('scroll_to_active');//first time only
- })
- }
- }
- }
- /////////
- if(typeof self.settings.update_breadcrumbs === 'function') {
- link_text = self.settings.update_breadcrumbs.call(null, hash, url, link_element);
- }
- else if(self.settings.update_breadcrumbs === true && link_element != null && link_element.length > 0) {
- link_text = updateBreadcrumbs(link_element);
- }
- /////////
- //convert "title" and "link" tags to "div" tags for later processing
- result = String(result)
- .replace(/<(title|link)([\s\>])/gi,'<div class="hidden ajax-append-$1"$2')
- .replace(/<\/(title|link)\>/gi,'</div>')
-
-
- $overlay.addClass('content-loaded').detach();
- $contentArea.empty().html(result);
-
- $(self.settings.loading_overlay || $contentArea).append($overlay);
-
- //remove previous stylesheets inserted via ajax
- setTimeout(function() {
- $('head').find('link.ace-ajax-stylesheet').remove();
- var main_selectors = ['link.ace-main-stylesheet', 'link#main-ace-style', 'link[href*="/ace.min.css"]', 'link[href*="/ace.css"]']
- var ace_style = [];
- for(var m = 0; m < main_selectors.length; m++) {
- ace_style = $('head').find(main_selectors[m]).first();
- if(ace_style.length > 0) break;
- }
-
- $contentArea.find('.ajax-append-link').each(function(e) {
- var $link = $(this);
- if ( $link.attr('href') ) {
- var new_link = jQuery('<link />', {type : 'text/css', rel: 'stylesheet', 'class': 'ace-ajax-stylesheet'})
- if( ace_style.length > 0 ) new_link.insertBefore(ace_style);
- else new_link.appendTo('head');
- new_link.attr('href', $link.attr('href'));//we set "href" after insertion, for IE to work
- }
- $link.remove();
- })
- }, 10);
- //////////////////////
- if(typeof self.settings.update_title === 'function') {
- self.settings.update_title.call(null, hash, url, link_text);
- }
- else if(self.settings.update_title === true) {
- updateTitle(link_text);
- }
-
- if( !manual_trigger ) {
- $('html,body').animate({scrollTop: 0}, 250);
- }
- //////////////////////
- $contentArea.trigger('ajaxloadcomplete', {url: url, hash: hash});
- //////////////////////
-
- self.stopLoading();
- })
- }
-
-
- ///////////////////////
- var fixPos = false;
- var loadTimer = null;
- this.startLoading = function() {
- if(working) return;
- working = true;
-
- if(!this.settings.loading_overlay && $contentArea.css('position') == 'static') {
- $contentArea.css('position', 'relative');//for correct icon positioning
- fixPos = true;
- }
-
- $overlay.remove();
- $overlay = $('<div class="ajax-loading-overlay"><i class="ajax-loading-icon '+(this.settings.loading_icon || '')+'"></i> '+this.settings.loading_text+'</div>')
- if(this.settings.loading_overlay == 'body') $('body').append($overlay.addClass('ajax-overlay-body'));
- else if(this.settings.loading_overlay) $(this.settings.loading_overlay).append($overlay);
- else $contentArea.append($overlay);
-
- if(this.settings.max_load_wait !== false)
- loadTimer = setTimeout(function() {
- loadTimer = null;
- if(!working) return;
-
- var event
- $contentArea.trigger(event = $.Event('ajaxloadlong'))
- if (event.isDefaultPrevented()) return;
-
- self.stopLoading(true);
- }, this.settings.max_load_wait * 1000);
- }
-
- this.stopLoading = function(stopNow) {
- if(stopNow === true) {
- working = false;
-
- $overlay.remove();
- if(fixPos) {
- $contentArea.css('position', '');//restore previous 'position' value
- fixPos = false;
- }
-
- if(loadTimer != null) {
- clearTimeout(loadTimer);
- loadTimer = null;
- }
- }
- else {
- $overlay.addClass('almost-loaded');
-
- $contentArea.one('ajaxscriptsloaded.inner_call', function() {
- self.stopLoading(true);
- /**
- if(window.Pace && Pace.running == true) {
- Pace.off('done');
- Pace.once('done', function() { self.stopLoading(true) })
- }
- else self.stopLoading(true);
- */
- })
- }
- }
-
- this.working = function() {
- return working;
- }
- ///////////////////////
-
-
-
- function updateBreadcrumbs(link_element) {
- var link_text = '';
-
- //update breadcrumbs
- var breadcrumbs = $('.breadcrumb');
- if(breadcrumbs.length > 0 && breadcrumbs.is(':visible')) {
- breadcrumbs.find('> li:not(:first-child)').remove();
- var i = 0;
- link_element.parents('.nav li').each(function() {
- var link = $(this).find('> a');
-
- var link_clone = link.clone();
- link_clone.find('i,.fa,.glyphicon,.ace-icon,.menu-icon,.badge,.label').remove();
- var text = link_clone.text();
- link_clone.remove();
-
- var href = link.attr('href');
- if(i == 0) {
- var li = $('<li class="active"></li>').appendTo(breadcrumbs);
- li.text(text);
- link_text = text;
- }
- else {
- var li = $('<li><a /></li>').insertAfter(breadcrumbs.find('> li:first-child'));
- li.find('a').attr('href', href).text(text);
- }
- i++;
- })
- }
-
- return link_text;
- }
-
- function updateTitle(link_text) {
- var $title = $contentArea.find('.ajax-append-title');
- if($title.length > 0) {
- document.title = $title.text();
- $title.remove();
- }
- else if(link_text.length > 0) {
- var extra = $.trim(String(document.title).replace(/^(.*)[\-]/, ''));//for example like " - Ace Admin"
- if(extra) extra = ' - ' + extra;
- link_text = $.trim(link_text) + extra;
- }
- }
-
-
- this.loadScripts = function(scripts, callback) {
- $.ajaxPrefilter('script', function(opts) {opts.cache = true});
- setTimeout(function() {
- //let's keep a list of loaded scripts so that we don't load them more than once!
-
- function finishLoading() {
- if(typeof callback === 'function') callback();
- $('.btn-group[data-toggle="buttons"] > .btn').button();
-
- $contentArea.trigger('ajaxscriptsloaded');
- }
-
- //var deferreds = [];
- var deferred_count = 0;//deferreds count
- var resolved = 0;
- for(var i = 0; i < scripts.length; i++) if(scripts[i]) {
- (function() {
- var script_name = "js-"+scripts[i].replace(/[^\w\d\-]/g, '-').replace(/\-\-/g, '-');
- if( ajax_loaded_scripts[script_name] !== true ) deferred_count++;
- })()
- }
-
- function nextScript(index) {
- index += 1;
- if(index < scripts.length) loadScript(index);
- else {
- finishLoading();
- }
- }
-
- function loadScript(index) {
- index = index || 0;
- if(!scripts[index]) {//could be null sometimes
- return nextScript(index);
- }
-
- var script_name = "js-"+scripts[index].replace(/[^\w\d\-]/g, '-').replace(/\-\-/g, '-');
- //only load scripts that are not loaded yet!
- if( ajax_loaded_scripts[script_name] !== true ) {
- $.getScript(scripts[index])
- .done(function() {
- ajax_loaded_scripts[script_name] = true;
- })
- //.fail(function() {
- //})
- .complete(function() {
- resolved++;
- if(resolved >= deferred_count && working) {
- finishLoading();
- }
- else {
- nextScript(index);
- }
- })
- }
- else {//script previoisly loaded
- nextScript(index);
- }
- }
-
-
- if (deferred_count > 0) {
- loadScript();
- }
- else {
- finishLoading();
- }
- }, 10)
- }
-
-
-
- /////////////////
- $(window)
- .off('hashchange.ace_ajax')
- .on('hashchange.ace_ajax', function(e, manual_trigger) {
- var hash = $.trim(window.location.hash);
- if(!hash || hash.length == 0) return;
-
- self.loadUrl(hash);
- }).trigger('hashchange.ace_ajax', [true]);
-
- var hash = $.trim(window.location.hash);
- if(!hash && this.settings.default_url) window.location.hash = this.settings.default_url;
- }//AceAjax
- $.fn.aceAjax = $.fn.ace_ajax = function (option, value, value2, value3) {
- var method_call;
- var $set = this.each(function () {
- var $this = $(this);
- var data = $this.data('ace_ajax');
- var options = typeof option === 'object' && option;
- if (!data) $this.data('ace_ajax', (data = new AceAjax(this, options)));
- if (typeof option === 'string' && typeof data[option] === 'function') {
- if(value3 != undefined) method_call = data[option](value, value2, value3);
- else if(value2 != undefined) method_call = data[option](value, value2);
- else method_call = data[option](value);
- }
- });
- return (method_call === undefined) ? $set : method_call;
- }
-
-
-
- $.fn.aceAjax.defaults = $.fn.ace_ajax.defaults = {
- content_url: false,
- default_url: false,
- loading_icon: 'fa fa-spin fa-spinner fa-2x orange',
- loading_text: '',
- loading_overlay: null,
- update_breadcrumbs: true,
- update_title: true,
- update_active: true,
- close_active: false,
- max_load_wait: false
- }
- })(window.jQuery);
- ;/**
- <b>Custom drag event for touch devices</b> used in scrollbars.
- For better touch event handling and extra options a more advanced solution such as <u>Hammer.js</u> is recommended.
- */
- //based on but not dependent on jQuery mobile
- /*
- * jQuery Mobile v1.3.2
- * http://jquerymobile.com
- *
- * Copyright 2010, 2013 jQuery Foundation, Inc. and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- *
- */
- (function($ , undefined) {
- if(!ace.vars['touch']) return;
- var touchStartEvent = "touchstart MSPointerDown pointerdown",// : "mousedown",
- touchStopEvent = "touchend touchcancel MSPointerUp MSPointerCancel pointerup pointercancel",// : "mouseup",
- touchMoveEvent = "touchmove MSPointerMove MSPointerHover pointermove";// : "mousemove";
- $.event.special.ace_drag = {
- setup: function() {
- var min_threshold = 0;
-
- var $this = $(this);
- $this.on(touchStartEvent, function(event) {
- var data = event.originalEvent.touches ?
- event.originalEvent.touches[ 0 ] :
- event,
- start = {
- //time: Date.now(),
- coords: [ data.pageX, data.pageY ],
- origin: $(event.target)
- },
- stop;
- //start.origin.trigger({'type' : 'ace_dragStart', 'start':(start || [-1,-1])});
-
- var direction = false, dx = 0, dy = 0;
- function moveHandler(event) {
- if (!start) {
- return;
- }
- var data = event.originalEvent.touches ?
- event.originalEvent.touches[ 0 ] :
- event;
- stop = {
- coords: [ data.pageX, data.pageY ]
- };
-
- // prevent scrolling
- //if ( Math.abs(start.coords[1] - stop.coords[1]) > 0 || Math.abs(start.coords[0] - stop.coords[01]) > 0 ) {
- //event.preventDefault();
- //}
- if (start && stop) {
- dx = 0;
- dy = 0;
- direction =
- (
- Math.abs(dy = start.coords[ 1 ] - stop.coords[ 1 ]) > min_threshold
- &&
- Math.abs(dx = start.coords[ 0 ] - stop.coords[ 0 ]) <= Math.abs(dy)
- )
- ?
- (dy > 0 ? 'up' : 'down')
- :
- (
- Math.abs(dx = start.coords[ 0 ] - stop.coords[ 0 ]) > min_threshold
- &&
- Math.abs( dy ) <= Math.abs(dx)
- )
- ?
- (dx > 0 ? 'left' : 'right')
- :
- false;
-
- if( direction !== false ) {
- var retval = {cancel: false}
- start.origin.trigger({
- 'type': 'ace_drag',
- //'start': start.coords,
- //'stop': stop.coords,
- 'direction': direction,
- 'dx': dx,
- 'dy': dy,
- 'retval': retval
- })
- // prevent document scrolling unless retval.cancel == true
- if( retval.cancel == false ) event.preventDefault();
- }
- }
- start.coords[0] = stop.coords[0];
- start.coords[1] = stop.coords[1];
- }
- $this
- .on(touchMoveEvent, moveHandler)
- .one(touchStopEvent, function(event) {
- $this.off(touchMoveEvent, moveHandler);
- //start.origin.trigger({'type' : 'ace_dragEnd', 'stop':(stop || [-1,-1])});
-
- start = stop = undefined;
-
- });
- });
- }
- }
- })(window.jQuery);;/**
- <b>Sidebar functions</b>. Collapsing/expanding, toggling mobile view menu and other sidebar functions.
- */
- (function($ , undefined) {
- var sidebar_count = 0;
- function Sidebar(sidebar, settings) {
- var self = this;
- this.$sidebar = $(sidebar);
- this.$sidebar.attr('data-sidebar', 'true');
- if( !this.$sidebar.attr('id') ) this.$sidebar.attr( 'id' , 'id-sidebar-'+(++sidebar_count) )
-
- //get a list of 'data-*' attributes that override 'defaults' and 'settings'
- var attrib_values = ace.helper.getAttrSettings(sidebar, $.fn.ace_sidebar.defaults, 'sidebar-');
- this.settings = $.extend({}, $.fn.ace_sidebar.defaults, settings, attrib_values);
- //some vars
- this.minimized = false;//will be initiated later
- this.collapsible = false;//...
- this.horizontal = false;//...
- this.mobile_view = false;//
- this.vars = function() {
- return {'minimized': this.minimized, 'collapsible': this.collapsible, 'horizontal': this.horizontal, 'mobile_view': this.mobile_view}
- }
- this.get = function(name) {
- if(this.hasOwnProperty(name)) return this[name];
- }
- this.set = function(name, value) {
- if(this.hasOwnProperty(name)) this[name] = value;
- }
-
- this.ref = function() {
- //return a reference to self
- return this;
- }
- var toggleIcon = function(minimized) {
- var icon = $(this).find(ace.vars['.icon']), icon1, icon2;
- if(icon.length > 0) {
- icon1 = icon.attr('data-icon1');//the icon for expanded state
- icon2 = icon.attr('data-icon2');//the icon for collapsed state
- if(minimized !== undefined) {
- if(minimized) icon.removeClass(icon1).addClass(icon2);
- else icon.removeClass(icon2).addClass(icon1);
- }
- else {
- icon.toggleClass(icon1).toggleClass(icon2);
- }
- }
- }
-
- var findToggleBtn = function() {
- var toggle_btn = self.$sidebar.find('.sidebar-collapse');
- if(toggle_btn.length == 0) toggle_btn = $('.sidebar-collapse[data-target="#'+(self.$sidebar.attr('id')||'')+'"]');
- if(toggle_btn.length != 0) toggle_btn = toggle_btn[0];
- else toggle_btn = null;
-
- return toggle_btn;
- }
-
- //collapse/expand button
- this.toggleMenu = function(toggle_btn, save) {
- if(this.collapsible) return;
- //var minimized = this.$sidebar.hasClass('menu-min');
- this.minimized = !this.minimized;
-
- try {
- //toggle_btn can also be a param to indicate saving to cookie or not?! if toggle_btn === false, it won't be saved
- ace.settings.sidebar_collapsed(sidebar, this.minimized, !(toggle_btn === false || save === false));//@ ace-extra.js
- } catch(e) {
- if(this.minimized)
- this.$sidebar.addClass('menu-min');
- else this.$sidebar.removeClass('menu-min');
- }
-
- if( !toggle_btn ) {
- toggle_btn = findToggleBtn();
- }
- if(toggle_btn) {
- toggleIcon.call(toggle_btn, this.minimized);
- }
- //force redraw for ie8
- if(ace.vars['old_ie']) ace.helper.redraw(sidebar);
- }
- this.collapse = function(toggle_btn, save) {
- if(this.collapsible) return;
- this.minimized = false;
-
- this.toggleMenu(toggle_btn, save);
- }
- this.expand = function(toggle_btn, save) {
- if(this.collapsible) return;
- this.minimized = true;
-
- this.toggleMenu(toggle_btn, save);
- }
-
-
- //collapse/expand in 2nd mobile style
- this.toggleResponsive = function(toggle_btn) {
- if(!this.mobile_view || this.mobile_style != 3) return;
-
- if( this.$sidebar.hasClass('menu-min') ) {
- //remove menu-min because it interferes with responsive-max
- this.$sidebar.removeClass('menu-min');
- var btn = findToggleBtn();
- if(btn) toggleIcon.call(btn);
- }
- this.minimized = !this.$sidebar.hasClass('responsive-min');
- this.$sidebar.toggleClass('responsive-min responsive-max');
- if( !toggle_btn ) {
- toggle_btn = this.$sidebar.find('.sidebar-expand');
- if(toggle_btn.length == 0) toggle_btn = $('.sidebar-expand[data-target="#'+(this.$sidebar.attr('id')||'')+'"]');
- if(toggle_btn.length != 0) toggle_btn = toggle_btn[0];
- else toggle_btn = null;
- }
-
- if(toggle_btn) {
- var icon = $(toggle_btn).find(ace.vars['.icon']), icon1, icon2;
- if(icon.length > 0) {
- icon1 = icon.attr('data-icon1');//the icon for expanded state
- icon2 = icon.attr('data-icon2');//the icon for collapsed state
- icon.toggleClass(icon1).toggleClass(icon2);
- }
- }
- $(document).triggerHandler('settings.ace', ['sidebar_collapsed' , this.minimized]);
- }
-
- //some helper functions
- this.is_collapsible = function() {
- var toggle
- return (this.$sidebar.hasClass('navbar-collapse'))
- && ((toggle = $('.navbar-toggle[data-target="#'+(this.$sidebar.attr('id')||'')+'"]').get(0)) != null)
- && toggle.scrollHeight > 0
- //sidebar is collapsible and collapse button is visible?
- }
- this.is_mobile_view = function() {
- var toggle
- return ((toggle = $('.menu-toggler[data-target="#'+(this.$sidebar.attr('id')||'')+'"]').get(0)) != null)
- && toggle.scrollHeight > 0
- }
- //toggling submenu
- this.$sidebar.on(ace.click_event+'.ace.submenu', '.nav-list', function (ev) {
- var nav_list = this;
- //check to see if we have clicked on an element which is inside a .dropdown-toggle element?!
- //if so, it means we should toggle a submenu
- var link_element = $(ev.target).closest('a');
- if(!link_element || link_element.length == 0) return;//return if not clicked inside a link element
- var minimized = self.minimized && !self.collapsible;
- //if .sidebar is .navbar-collapse and in small device mode, then let minimized be uneffective
-
- if( !link_element.hasClass('dropdown-toggle') ) {//it doesn't have a submenu return
- //just one thing before we return
- //if sidebar is collapsed(minimized) and we click on a first level menu item
- //and the click is on the icon, not on the menu text then let's cancel event and cancel navigation
- //Good for touch devices, that when the icon is tapped to see the menu text, navigation is cancelled
- //navigation is only done when menu text is tapped
- if( ace.click_event == 'tap'
- &&
- minimized
- &&
- link_element.get(0).parentNode.parentNode == nav_list )//only level-1 links
- {
- var text = link_element.find('.menu-text').get(0);
- if( text != null && ev.target != text && !$.contains(text , ev.target) ) {//not clicking on the text or its children
- ev.preventDefault();
- return false;
- }
- }
- //ios safari only has a bit of a problem not navigating to link address when scrolling down
- //specify data-link attribute to ignore this
- if(ace.vars['ios_safari'] && link_element.attr('data-link') !== 'false') {
- //only ios safari has a bit of a problem not navigating to link address when scrolling down
- //please see issues section in documentation
- document.location = link_element.attr('href');
- ev.preventDefault();
- return false;
- }
- return;
- }
-
- ev.preventDefault();
-
-
- var sub = link_element.siblings('.submenu').get(0);
- if(!sub) return false;
- var $sub = $(sub);
- var height_change = 0;//the amount of height change in .nav-list
- var parent_ul = sub.parentNode.parentNode;
- if
- (
- ( minimized && parent_ul == nav_list )
- ||
- ( ( $sub.parent().hasClass('hover') && $sub.css('position') == 'absolute' ) && !self.collapsible )
- )
- {
- return false;
- }
-
- var sub_hidden = (sub.scrollHeight == 0)
- //if not open and visible, let's open it and make it visible
- if( sub_hidden ) {//being shown now
- $(parent_ul).find('> .open > .submenu').each(function() {
- //close all other open submenus except for the active one
- if(this != sub && !$(this.parentNode).hasClass('active')) {
- height_change -= this.scrollHeight;
- self.hide(this, self.settings.duration, false);
- }
- })
- }
- if( sub_hidden ) {//being shown now
- self.show(sub, self.settings.duration);
- //if a submenu is being shown and another one previously started to hide, then we may need to update/hide scrollbars
- //but if no previous submenu is being hidden, then no need to check if we need to hide the scrollbars in advance
- if(height_change != 0) height_change += sub.scrollHeight;//we need new updated 'scrollHeight' here
- } else {
- self.hide(sub, self.settings.duration);
- height_change -= sub.scrollHeight;
- //== -1 means submenu is being hidden
- }
- //hide scrollbars if content is going to be small enough that scrollbars is not needed anymore
- //do this almost before submenu hiding begins
- //but when minimized submenu's toggle should have no effect
- if (height_change != 0) {
- if(self.$sidebar.attr('data-sidebar-scroll') == 'true' && !self.minimized)
- self.$sidebar.ace_sidebar_scroll('prehide', height_change)
- }
- return false;
- })
- var submenu_working = false;
- this.show = function(sub, $duration, shouldWait) {
- //'shouldWait' indicates whether to wait for previous transition (submenu toggle) to be complete or not?
- shouldWait = (shouldWait !== false);
- if(shouldWait && submenu_working) return false;
-
- var $sub = $(sub);
- var event;
- $sub.trigger(event = $.Event('show.ace.submenu'))
- if (event.isDefaultPrevented()) {
- return false;
- }
-
- if(shouldWait) submenu_working = true;
- $duration = $duration || this.settings.duration;
-
- $sub.css({
- height: 0,
- overflow: 'hidden',
- display: 'block'
- })
- .removeClass('nav-hide').addClass('nav-show')//only for window < @grid-float-breakpoint and .navbar-collapse.menu-min
- .parent().addClass('open');
-
- sub.scrollTop = 0;//this is for submenu_hover when sidebar is minimized and a submenu is scrollTop'ed using scrollbars ...
- if( $duration > 0 ) {
- $sub.css({height: sub.scrollHeight,
- 'transition-property': 'height',
- 'transition-duration': ($duration/1000)+'s'})
- }
- var complete = function(ev, trigger) {
- ev && ev.stopPropagation();
- $sub
- .css({'transition-property': '', 'transition-duration': '', overflow:'', height: ''})
- //if(ace.vars['webkit']) ace.helper.redraw(sub);//little Chrome issue, force redraw ;)
- if(trigger !== false) $sub.trigger($.Event('shown.ace.submenu'))
-
- if(shouldWait) submenu_working = false;
- }
-
- if( $duration > 0 && !!$.support.transition.end ) {
- $sub.one($.support.transition.end, complete);
- }
- else complete();
-
- //there is sometimes a glitch, so maybe retry
- if(ace.vars['android']) {
- setTimeout(function() {
- complete(null, false);
- ace.helper.redraw(sub);
- }, $duration + 20);
- }
- return true;
- }
-
-
- this.hide = function(sub, $duration, shouldWait) {
- //'shouldWait' indicates whether to wait for previous transition (submenu toggle) to be complete or not?
- shouldWait = (shouldWait !== false);
- if(shouldWait && submenu_working) return false;
-
-
- var $sub = $(sub);
- var event;
- $sub.trigger(event = $.Event('hide.ace.submenu'))
- if (event.isDefaultPrevented()) {
- return false;
- }
-
- if(shouldWait) submenu_working = true;
-
- $duration = $duration || this.settings.duration;
-
- $sub.css({
- height: sub.scrollHeight,
- overflow: 'hidden',
- display: 'block'
- })
- .parent().removeClass('open');
- sub.offsetHeight;
- //forces the "sub" to re-consider the new 'height' before transition
- if( $duration > 0 ) {
- $sub.css({'height': 0,
- 'transition-property': 'height',
- 'transition-duration': ($duration/1000)+'s'});
- }
- var complete = function(ev, trigger) {
- ev && ev.stopPropagation();
- $sub
- .css({display: 'none', overflow:'', height: '', 'transition-property': '', 'transition-duration': ''})
- .removeClass('nav-show').addClass('nav-hide')//only for window < @grid-float-breakpoint and .navbar-collapse.menu-min
- if(trigger !== false) $sub.trigger($.Event('hidden.ace.submenu'))
-
- if(shouldWait) submenu_working = false;
- }
- if( $duration > 0 && !!$.support.transition.end ) {
- $sub.one($.support.transition.end, complete);
- }
- else complete();
- //there is sometimes a glitch, so maybe retry
- if(ace.vars['android']) {
- setTimeout(function() {
- complete(null, false);
- ace.helper.redraw(sub);
- }, $duration + 20);
- }
- return true;
- }
- this.toggle = function(sub, $duration) {
- $duration = $duration || self.settings.duration;
-
- if( sub.scrollHeight == 0 ) {//if an element is hidden scrollHeight becomes 0
- if( this.show(sub, $duration) ) return 1;
- } else {
- if( this.hide(sub, $duration) ) return -1;
- }
- return 0;
- }
- //sidebar vars
- var minimized_menu_class = 'menu-min';
- var responsive_min_class = 'responsive-min';
- var horizontal_menu_class = 'h-sidebar';
- var sidebar_mobile_style = function() {
- //differnet mobile menu styles
- this.mobile_style = 1;//default responsive mode with toggle button inside navbar
- if(this.$sidebar.hasClass('responsive') && !$('.menu-toggler[data-target="#'+this.$sidebar.attr('id')+'"]').hasClass('navbar-toggle')) this.mobile_style = 2;//toggle button behind sidebar
- else if(this.$sidebar.hasClass(responsive_min_class)) this.mobile_style = 3;//minimized menu
- else if(this.$sidebar.hasClass('navbar-collapse')) this.mobile_style = 4;//collapsible (bootstrap style)
- }
- sidebar_mobile_style.call(self);
-
- function update_vars() {
- this.mobile_view = this.mobile_style < 4 && this.is_mobile_view();
- this.collapsible = !this.mobile_view && this.is_collapsible();
- this.minimized =
- (!this.collapsible && this.$sidebar.hasClass(minimized_menu_class))
- ||
- (this.mobile_style == 3 && this.mobile_view && this.$sidebar.hasClass(responsive_min_class))
- this.horizontal = !(this.mobile_view || this.collapsible) && this.$sidebar.hasClass(horizontal_menu_class)
- }
- //update some basic variables
- $(window).on('resize.sidebar.vars' , function(){
- update_vars.call(self);
- }).triggerHandler('resize.sidebar.vars')
- }//end of Sidebar
-
- //sidebar events
-
- //menu-toggler
- $(document)
- .on(ace.click_event+'.ace.menu', '.menu-toggler', function(e){
- var btn = $(this);
- var sidebar = $(btn.attr('data-target'));
- if(sidebar.length == 0) return;
-
- e.preventDefault();
-
- sidebar.toggleClass('display');
- btn.toggleClass('display');
-
- var click_event = ace.click_event+'.ace.autohide';
- var auto_hide = sidebar.attr('data-auto-hide') === 'true';
- if( btn.hasClass('display') ) {
- //hide menu if clicked outside of it!
- if(auto_hide) {
- $(document).on(click_event, function(ev) {
- if( sidebar.get(0) == ev.target || $.contains(sidebar.get(0), ev.target) ) {
- ev.stopPropagation();
- return;
- }
- sidebar.removeClass('display');
- btn.removeClass('display');
- $(document).off(click_event);
- })
- }
- if(sidebar.attr('data-sidebar-scroll') == 'true') sidebar.ace_sidebar_scroll('reset');
- }
- else {
- if(auto_hide) $(document).off(click_event);
- }
- return false;
- })
- //sidebar collapse/expand button
- .on(ace.click_event+'.ace.menu', '.sidebar-collapse', function(e){
-
- var target = $(this).attr('data-target'), $sidebar = null;
- if(target) $sidebar = $(target);
- if($sidebar == null || $sidebar.length == 0) $sidebar = $(this).closest('.sidebar');
- if($sidebar.length == 0) return;
- e.preventDefault();
- $sidebar.ace_sidebar('toggleMenu', this);
- })
- //this button is used in `mobile_style = 3` responsive menu style to expand minimized sidebar
- .on(ace.click_event+'.ace.menu', '.sidebar-expand', function(e){
- var target = $(this).attr('data-target'), $sidebar = null;
- if(target) $sidebar = $(target);
- if($sidebar == null || $sidebar.length == 0) $sidebar = $(this).closest('.sidebar');
- if($sidebar.length == 0) return;
-
- var btn = this;
- e.preventDefault();
- $sidebar.ace_sidebar('toggleResponsive', this);
-
- var click_event = ace.click_event+'.ace.autohide';
- if($sidebar.attr('data-auto-hide') === 'true') {
- if( $sidebar.hasClass('responsive-max') ) {
- $(document).on(click_event, function(ev) {
- if( $sidebar.get(0) == ev.target || $.contains($sidebar.get(0), ev.target) ) {
- ev.stopPropagation();
- return;
- }
- $sidebar.ace_sidebar('toggleResponsive', btn);
- $(document).off(click_event);
- })
- }
- else {
- $(document).off(click_event);
- }
- }
- })
-
- $.fn.ace_sidebar = function (option, value) {
- var method_call;
- var $set = this.each(function () {
- var $this = $(this);
- var data = $this.data('ace_sidebar');
- var options = typeof option === 'object' && option;
- if (!data) $this.data('ace_sidebar', (data = new Sidebar(this, options)));
- if (typeof option === 'string' && typeof data[option] === 'function') {
- if(value instanceof Array) method_call = data[option].apply(data, value);
- else method_call = data[option](value);
- }
- });
- return (method_call === undefined) ? $set : method_call;
- };
-
-
- $.fn.ace_sidebar.defaults = {
- 'duration': 300
- }
- })(window.jQuery);
- ;/**
- <b>Scrollbars for sidebar</b>. This approach can <span class="text-danger">only</span> be used on <u>fixed</u> sidebar.
- It doesn't use <u>"overflow:hidden"</u> CSS property and therefore can be used with <u>.hover</u> submenus and minimized sidebar.
- Except when in mobile view and menu toggle button is not in the navbar.
- */
- (function($ , undefined) {
- //if( !$.fn.ace_scroll ) return;
- var old_safari = ace.vars['safari'] && navigator.userAgent.match(/version\/[1-5]/i)
- //NOTE
- //Safari on windows has not been updated for a long time.
- //And it has a problem when sidebar is fixed & scrollable and there is a CSS3 animation inside page content.
- //Very probably windows users of safari have migrated to another browser by now!
- var is_element_pos =
- 'getComputedStyle' in window ?
- //el.offsetHeight is used to force redraw and recalculate 'el.style.position' esp. for webkit!
- function(el, pos) { el.offsetHeight; return window.getComputedStyle(el).position == pos }
- :
- function(el, pos) { el.offsetHeight; return $(el).css('position') == pos }
-
-
- function Sidebar_Scroll(sidebar , settings) {
- var self = this;
- var $window = $(window);
- var $sidebar = $(sidebar),
- $nav = $sidebar.find('.nav-list'),
- $toggle = $sidebar.find('.sidebar-toggle').eq(0),
- $shortcuts = $sidebar.find('.sidebar-shortcuts').eq(0);
-
- var nav = $nav.get(0);
- if(!nav) return;
-
-
- var attrib_values = ace.helper.getAttrSettings(sidebar, $.fn.ace_sidebar_scroll.defaults);
- this.settings = $.extend({}, $.fn.ace_sidebar_scroll.defaults, settings, attrib_values);
- var scroll_to_active = self.settings.scroll_to_active;
-
-
- var ace_sidebar = $sidebar.ace_sidebar('ref');
- $sidebar.attr('data-sidebar-scroll', 'true');
-
-
- var scroll_div = null,
- scroll_content = null,
- scroll_content_div = null,
- bar = null,
- track = null,
- ace_scroll = null;
- this.is_scrolling = false;
- var _initiated = false;
- this.sidebar_fixed = is_element_pos(sidebar, 'fixed');
-
- var $avail_height, $content_height;
-
- var available_height = function() {
- //available window space
- var offset = $nav.parent().offset();//because `$nav.offset()` considers the "scrolled top" amount as well
- if(self.sidebar_fixed) offset.top -= ace.helper.scrollTop();
- return $window.innerHeight() - offset.top - ( self.settings.include_toggle ? 0 : $toggle.outerHeight() );
- }
- var content_height = function() {
- return nav.clientHeight;//we don't use nav.scrollHeight here, because hover submenus are considered in calculating scrollHeight despite position=absolute!
- }
-
-
- var initiate = function(on_page_load) {
- if( _initiated ) return;
- if( !self.sidebar_fixed ) return;//eligible??
- //return if we want scrollbars only on "fixed" sidebar and sidebar is not "fixed" yet!
- //initiate once
- $nav.wrap('<div class="nav-wrap-up pos-rel" />');
- $nav.after('<div><div></div></div>');
- $nav.wrap('<div class="nav-wrap" />');
- if(!self.settings.include_toggle) $toggle.css({'z-index': 1});
- if(!self.settings.include_shortcuts) $shortcuts.css({'z-index': 99});
- scroll_div = $nav.parent().next()
- .ace_scroll({
- size: available_height(),
- //reset: true,
- mouseWheelLock: true,
- hoverReset: false,
- dragEvent: true,
- styleClass: self.settings.scroll_style,
- touchDrag: false//disable touch drag event on scrollbars, we'll add a custom one later
- })
- .closest('.ace-scroll').addClass('nav-scroll');
-
- ace_scroll = scroll_div.data('ace_scroll');
- scroll_content = scroll_div.find('.scroll-content').eq(0);
- scroll_content_div = scroll_content.find(' > div').eq(0);
-
- track = $(ace_scroll.get_track());
- bar = track.find('.scroll-bar').eq(0);
- if(self.settings.include_shortcuts && $shortcuts.length != 0) {
- $nav.parent().prepend($shortcuts).wrapInner('<div />');
- $nav = $nav.parent();
- }
- if(self.settings.include_toggle && $toggle.length != 0) {
- $nav.append($toggle);
- $nav.closest('.nav-wrap').addClass('nav-wrap-t');//it just helps to remove toggle button's top border and restore li:last-child's bottom border
- }
- $nav.css({position: 'relative'});
- if( self.settings.scroll_outside == true ) scroll_div.addClass('scrollout');
-
- nav = $nav.get(0);
- nav.style.top = 0;
- scroll_content.on('scroll.nav', function() {
- nav.style.top = (-1 * this.scrollTop) + 'px';
- });
-
- //mousewheel library available?
- $nav.on(!!$.event.special.mousewheel ? 'mousewheel.ace_scroll' : 'mousewheel.ace_scroll DOMMouseScroll.ace_scroll', function(event){
- if( !self.is_scrolling || !ace_scroll.is_active() ) {
- return !self.settings.lock_anyway;
- }
- //transfer $nav's mousewheel event to scrollbars
- return scroll_div.trigger(event);
- });
-
- $nav.on('mouseenter.ace_scroll', function() {
- track.addClass('scroll-hover');
- }).on('mouseleave.ace_scroll', function() {
- track.removeClass('scroll-hover');
- });
- /**
- $(document.body).on('touchmove.nav', function(event) {
- if( self.is_scrolling && $.contains(sidebar, event.target) ) {
- event.preventDefault();
- return false;
- }
- })
- */
- //you can also use swipe event in a similar way //swipe.nav
- var content = scroll_content.get(0);
- $nav.on('ace_drag.nav', function(event) {
- if( !self.is_scrolling || !ace_scroll.is_active() ) {
- event.retval.cancel = true;
- return;
- }
-
- //if submenu hover is being scrolled let's cancel sidebar scroll!
- if( $(event.target).closest('.can-scroll').length != 0 ) {
- event.retval.cancel = true;
- return;
- }
- if(event.direction == 'up' || event.direction == 'down') {
-
- ace_scroll.move_bar(true);
-
- var distance = event.dy;
-
- distance = parseInt(Math.min($avail_height, distance))
- if(Math.abs(distance) > 2) distance = distance * 2;
-
- if(distance != 0) {
- content.scrollTop = content.scrollTop + distance;
- nav.style.top = (-1 * content.scrollTop) + 'px';
- }
- }
- });
-
- //for drag only
- if(self.settings.smooth_scroll) {
- $nav
- .on('touchstart.nav MSPointerDown.nav pointerdown.nav', function(event) {
- $nav.css('transition-property', 'none');
- bar.css('transition-property', 'none');
- })
- .on('touchend.nav touchcancel.nav MSPointerUp.nav MSPointerCancel.nav pointerup.nav pointercancel.nav', function(event) {
- $nav.css('transition-property', 'top');
- bar.css('transition-property', 'top');
- });
- }
-
-
- if(old_safari && !self.settings.include_toggle) {
- var toggle = $toggle.get(0);
- if(toggle) scroll_content.on('scroll.safari', function() {
- ace.helper.redraw(toggle);
- });
- }
- _initiated = true;
- //if the active item is not visible, scroll down so that it becomes visible
- //only the first time, on page load
- if(on_page_load == true) {
- self.reset();//try resetting at first
- if( scroll_to_active ) {
- self.scroll_to_active();
- }
- scroll_to_active = false;
- }
-
-
-
- if( typeof self.settings.smooth_scroll === 'number' && self.settings.smooth_scroll > 0) {
- $nav.css({'transition-property': 'top', 'transition-duration': (self.settings.smooth_scroll / 1000).toFixed(2)+'s'})
- bar.css({'transition-property': 'top', 'transition-duration': (self.settings.smooth_scroll / 1500).toFixed(2)+'s'})
-
- scroll_div
- .on('drag.start', function(e) {
- e.stopPropagation();
- $nav.css('transition-property', 'none')
- })
- .on('drag.end', function(e) {
- e.stopPropagation();
- $nav.css('transition-property', 'top')
- });
- }
-
- if(ace.vars['android']) {
- //force hide address bar, because its changes don't trigger window resize and become kinda ugly
- var val = ace.helper.scrollTop();
- if(val < 2) {
- window.scrollTo( val, 0 );
- setTimeout( function() {
- self.reset();
- }, 20 );
- }
-
- var last_height = ace.helper.winHeight() , new_height;
- $(window).on('scroll.ace_scroll', function() {
- if(self.is_scrolling && ace_scroll.is_active()) {
- new_height = ace.helper.winHeight();
- if(new_height != last_height) {
- last_height = new_height;
- self.reset();
- }
- }
- });
- }
- }
-
-
-
-
- this.scroll_to_active = function() {
- if( !ace_scroll || !ace_scroll.is_active() ) return;
- try {
- //sometimes there's no active item or not 'offsetTop' property
- var $active;
-
- var vars = ace_sidebar['vars']()
- var nav_list = $sidebar.find('.nav-list')
- if(vars['minimized'] && !vars['collapsible']) {
- $active = nav_list.find('> .active')
- }
- else {
- $active = $nav.find('> .active.hover')
- if($active.length == 0) $active = $nav.find('.active:not(.open)')
- }
-
- var top = $active.outerHeight();
- nav_list = nav_list.get(0);
- var active = $active.get(0);
- while(active != nav_list) {
- top += active.offsetTop;
- active = active.parentNode;
- }
- var scroll_amount = top - scroll_div.height();
- if(scroll_amount > 0) {
- nav.style.top = -scroll_amount + 'px';
- scroll_content.scrollTop(scroll_amount);
- }
- }catch(e){}
- }
-
-
-
- this.reset = function(recalc) {
- if(recalc === true) {
- this.sidebar_fixed = is_element_pos(sidebar, 'fixed');
- }
-
- if( !this.sidebar_fixed ) {
- this.disable();
- return;//eligible??
- }
- //return if we want scrollbars only on "fixed" sidebar and sidebar is not "fixed" yet!
- if( !_initiated ) initiate();
- //initiate scrollbars if not yet
-
- var vars = ace_sidebar['vars']();
-
- //enable if:
- //menu is not collapsible mode (responsive navbar-collapse mode which has default browser scrollbar)
- //menu is not horizontal or horizontal but mobile view (which is not navbar-collapse)
- //and available height is less than nav's height
-
- var enable_scroll = !vars['collapsible'] && !vars['horizontal']
- && ($avail_height = available_height()) < ($content_height = nav.clientHeight);
- //we don't use nav.scrollHeight here, because hover submenus are considered in calculating scrollHeight despite position=absolute!
-
- this.is_scrolling = true;
- if( enable_scroll ) {
- scroll_content_div.css({height: $content_height, width: 8});
- scroll_div.prev().css({'max-height' : $avail_height})
- ace_scroll.update({size: $avail_height})
- ace_scroll.enable();
- ace_scroll.reset();
- }
- if( !enable_scroll || !ace_scroll.is_active() ) {
- if(this.is_scrolling) this.disable();
- }
- else {
- $sidebar.addClass('sidebar-scroll');
- }
-
- //return this.is_scrolling;
- }
-
-
-
- this.disable = function() {
- this.is_scrolling = false;
- if(scroll_div) {
- scroll_div.css({'height' : '', 'max-height' : ''});
- scroll_content_div.css({height: '', width: ''});//otherwise it will have height and takes up some space even when invisible
- scroll_div.prev().css({'max-height' : ''})
- ace_scroll.disable();
- }
- if(parseInt(nav.style.top) < 0 && self.settings.smooth_scroll && $.support.transition.end) {
- $nav.one($.support.transition.end, function() {
- $sidebar.removeClass('sidebar-scroll');
- $nav.off('.trans');
- });
- } else {
- $sidebar.removeClass('sidebar-scroll');
- }
- nav.style.top = 0;
- }
-
- this.prehide = function(height_change) {
- if(!this.is_scrolling || ace_sidebar.get('minimized')) return;//when minimized submenu's toggle should have no effect
-
- if(content_height() + height_change < available_height()) {
- this.disable();
- }
- else if(height_change < 0) {
- //if content height is decreasing
- //let's move nav down while a submenu is being hidden
- var scroll_top = scroll_content.scrollTop() + height_change
- if(scroll_top < 0) return;
- nav.style.top = (-1 * scroll_top) + 'px';
- }
- }
-
-
- this._reset = function(recalc) {
- if(recalc === true) {
- this.sidebar_fixed = is_element_pos(sidebar, 'fixed');
- }
-
- if(ace.vars['webkit'])
- setTimeout(function() { self.reset() } , 0);
- else this.reset();
- }
-
-
- this.set_hover = function() {
- if(track) track.addClass('scroll-hover');
- }
-
- this.get = function(name) {
- if(this.hasOwnProperty(name)) return this[name];
- }
- this.set = function(name, value) {
- if(this.hasOwnProperty(name)) this[name] = value;
- }
- this.ref = function() {
- //return a reference to self
- return this;
- }
-
- this.updateStyle = function(styleClass) {
- if(ace_scroll == null) return;
- ace_scroll.update({styleClass: styleClass});
- }
-
- //change scrollbar size after a submenu is hidden/shown
- //but don't change if sidebar is minimized
- $sidebar.on('hidden.ace.submenu.sidebar_scroll shown.ace.submenu.sidebar_scroll', '.submenu', function(e) {
- e.stopPropagation();
- if( !ace_sidebar.get('minimized') ) {
- //webkit has a little bit of a glitch!!!
- self._reset();
- if( e.type == 'shown' ) self.set_hover();
- }
- });
-
- initiate(true);//true = on_page_load
- }
-
-
- //reset on document and window changes
- $(document).on('settings.ace.sidebar_scroll', function(ev, event_name, event_val){
- $('.sidebar[data-sidebar-scroll=true]').each(function() {
- var $this = $(this);
- var sidebar_scroll = $this.ace_sidebar_scroll('ref');
- if( event_name == 'sidebar_collapsed' && is_element_pos(this, 'fixed') ) {
- if( $this.attr('data-sidebar-hover') == 'true' ) $this.ace_sidebar_hover('reset');
- sidebar_scroll._reset();
- }
- else if( event_name === 'sidebar_fixed' || event_name === 'navbar_fixed' ) {
- var is_scrolling = sidebar_scroll.get('is_scrolling');
- var sidebar_fixed = is_element_pos(this, 'fixed')
- sidebar_scroll.set('sidebar_fixed', sidebar_fixed);
- if(sidebar_fixed && !is_scrolling) {
- sidebar_scroll._reset();
- }
- else if( !sidebar_fixed ) {
- sidebar_scroll.disable();
- }
- }
-
- });
- });
-
- $(window).on('resize.ace.sidebar_scroll', function(){
- $('.sidebar[data-sidebar-scroll=true]').each(function() {
- var $this = $(this);
- if( $this.attr('data-sidebar-hover') == 'true' ) $this.ace_sidebar_hover('reset');
- /////////////
- var sidebar_scroll = $(this).ace_sidebar_scroll('ref');
-
- var sidebar_fixed = is_element_pos(this, 'fixed')
- sidebar_scroll.set('sidebar_fixed', sidebar_fixed);
- sidebar_scroll._reset();
- });
- })
-
-
-
- /////////////////////////////////////////////
- if(!$.fn.ace_sidebar_scroll) {
- $.fn.ace_sidebar_scroll = function (option, value) {
- var method_call;
- var $set = this.each(function () {
- var $this = $(this);
- var data = $this.data('ace_sidebar_scroll');
- var options = typeof option === 'object' && option;
- if (!data) $this.data('ace_sidebar_scroll', (data = new Sidebar_Scroll(this, options)));
- if (typeof option === 'string' && typeof data[option] === 'function') {
- method_call = data[option](value);
- }
- });
- return (method_call === undefined) ? $set : method_call;
- }
-
-
- $.fn.ace_sidebar_scroll.defaults = {
- 'scroll_to_active': true,
- 'include_shortcuts': true,
- 'include_toggle': false,
- 'smooth_scroll': 150,
- 'scroll_outside': false,
- 'scroll_style': '',
- 'lock_anyway': false
- }
-
- }
- })(window.jQuery);;/**
- <b>Submenu hover adjustment</b>. Automatically move up a submenu to fit into screen when some part of it goes beneath window.
- Pass a "true" value as an argument and submenu will have native browser scrollbars when necessary.
- */
- (function($ , undefined) {
- if( ace.vars['very_old_ie'] ) return;
- //ignore IE7 & below
-
- var hasTouch = ace.vars['touch'];
- var nativeScroll = ace.vars['old_ie'] || hasTouch;
-
- var is_element_pos =
- 'getComputedStyle' in window ?
- //el.offsetHeight is used to force redraw and recalculate 'el.style.position' esp. for webkit!
- function(el, pos) { el.offsetHeight; return window.getComputedStyle(el).position == pos }
- :
- function(el, pos) { el.offsetHeight; return $(el).css('position') == pos }
- $(window).on('resize.sidebar.ace_hover', function() {
- $('.sidebar[data-sidebar-hover=true]').ace_sidebar_hover('update_vars').ace_sidebar_hover('reset');
- })
- $(document).on('settings.ace.ace_hover', function(e, event_name, event_val) {
- if(event_name == 'sidebar_collapsed') $('.sidebar[data-sidebar-hover=true]').ace_sidebar_hover('reset');
- else if(event_name == 'navbar_fixed') $('.sidebar[data-sidebar-hover=true]').ace_sidebar_hover('update_vars');
- })
-
- var sidebars = [];
- function Sidebar_Hover(sidebar , settings) {
- var self = this, that = this;
-
- var attrib_values = ace.helper.getAttrSettings(sidebar, $.fn.ace_sidebar_hover.defaults);
- this.settings = $.extend({}, $.fn.ace_sidebar_hover.defaults, settings, attrib_values);
-
- var $sidebar = $(sidebar), nav_list = $sidebar.find('.nav-list').get(0);
- $sidebar.attr('data-sidebar-hover', 'true');
-
- sidebars.push($sidebar);
- var sidebar_vars = {};
- var old_ie = ace.vars['old_ie'];
-
-
- var scroll_right = false;
- //scroll style class
-
- if(hasTouch) self.settings.sub_hover_delay = parseInt(Math.max(self.settings.sub_hover_delay, 2500));//for touch device, delay is at least 2.5sec
- var $window = $(window);
- //navbar used for adding extra offset from top when adjusting submenu
- var $navbar = $('.navbar').eq(0);
- var navbar_fixed = $navbar.css('position') == 'fixed';
- this.update_vars = function() {
- navbar_fixed = $navbar.css('position') == 'fixed';
- }
- self.dirty = false;
- //on window resize or sidebar expand/collapse a previously "pulled up" submenu should be reset back to its default position
- //for example if "pulled up" in "responsive-min" mode, in "fullmode" should not remain "pulled up"
- this.reset = function() {
- if( self.dirty == false ) return;
- self.dirty = false;//so don't reset is not called multiple times in a row!
-
- $sidebar.find('.submenu').each(function() {
- var $sub = $(this), li = $sub.parent();
- $sub.css({'top': '', 'bottom': '', 'max-height': ''});
-
- if($sub.hasClass('ace-scroll')) {
- $sub.ace_scroll('disable');
- }
- else {
- $sub.removeClass('sub-scroll');
- }
-
- if( is_element_pos(this, 'absolute') ) $sub.addClass('can-scroll');
- else $sub.removeClass('can-scroll');
- li.removeClass('pull_up').find('.menu-text:first').css('margin-top', '');
- })
- $sidebar.find('.hover-show').removeClass('hover-show hover-shown hover-flip');
- }
-
- this.updateStyle = function(newStyle) {
- sub_scroll_style = newStyle;
- $sidebar.find('.submenu.ace-scroll').ace_scroll('update', {styleClass: newStyle});
- }
- this.changeDir = function(dir) {
- scroll_right = (dir === 'right');
- }
-
-
- //update submenu scrollbars on submenu hide & show
- var lastScrollHeight = -1;
- //hide scrollbars if it's going to be not needed anymore!
- if(!nativeScroll)
- $sidebar.on('hide.ace.submenu.sidebar_hover', '.submenu', function(e) {
- if(lastScrollHeight < 1) return;
- e.stopPropagation();
- var $sub = $(this).closest('.ace-scroll.can-scroll');
- if($sub.length == 0 || !is_element_pos($sub[0], 'absolute')) return;
- if($sub[0].scrollHeight - this.scrollHeight < lastScrollHeight) {
- $sub.ace_scroll('disable');
- }
- });
-
-
-
- //reset scrollbars
- if(!nativeScroll)
- $sidebar.on('shown.ace.submenu.sidebar_hover hidden.ace.submenu.sidebar_hover', '.submenu', function(e) {
- if(lastScrollHeight < 1) return;
-
- var $sub = $(this).closest('.ace-scroll.can-scroll');
- if($sub.length == 0 || !is_element_pos($sub[0], 'absolute') ) return;
-
- var sub_h = $sub[0].scrollHeight;
-
- if(lastScrollHeight > 14 && sub_h - lastScrollHeight > 4) {
- $sub.ace_scroll('enable').ace_scroll('reset');//don't update track position
- }
- else {
- $sub.ace_scroll('disable');
- }
- });
- ///////////////////////
- var currentScroll = -1;
- //some mobile browsers don't have mouseenter
- var event_1 = !hasTouch ? 'mouseenter.sub_hover' : 'touchstart.sub_hover';// pointerdown.sub_hover';
- var event_2 = !hasTouch ? 'mouseleave.sub_hover' : 'touchend.sub_hover touchcancel.sub_hover';// pointerup.sub_hover pointercancel.sub_hover';
-
- $sidebar.on(event_1, '.nav-list li, .sidebar-shortcuts', function (e) {
- sidebar_vars = $sidebar.ace_sidebar('vars');
-
-
- //ignore if collapsible mode (mobile view .navbar-collapse) so it doesn't trigger submenu movements
- //or return if horizontal but not mobile_view (style 1&3)
- if( sidebar_vars['collapsible'] /**|| sidebar_vars['horizontal']*/ ) return;
-
- var $this = $(this);
- var shortcuts = false;
- var has_hover = $this.hasClass('hover');
-
- var sub = $this.find('> .submenu').get(0);
- if( !(sub || ((this.parentNode == nav_list || has_hover || (shortcuts = $this.hasClass('sidebar-shortcuts'))) /**&& sidebar_vars['minimized']*/)) ) {
- if(sub) $(sub).removeClass('can-scroll');
- return;//include .compact and .hover state as well?
- }
-
- var target_element = sub, is_abs = false;
- if( !target_element && this.parentNode == nav_list ) target_element = $this.find('> a > .menu-text').get(0);
- if( !target_element && shortcuts ) target_element = $this.find('.sidebar-shortcuts-large').get(0);
- if( (!target_element || !(is_abs = is_element_pos(target_element, 'absolute'))) && !has_hover ) {
- if(sub) $(sub).removeClass('can-scroll');
- return;
- }
-
-
- var sub_hide = getSubHide(this);
- //var show_sub = false;
- if(sub) {
- if(is_abs) {
- self.dirty = true;
-
- var newScroll = ace.helper.scrollTop();
- //if submenu is becoming visible for first time or document has been scrolled, then adjust menu
- if( !sub_hide.is_visible() || (!hasTouch && newScroll != currentScroll) || old_ie ) {
- //try to move/adjust submenu if the parent is a li.hover or if submenu is minimized
- //if( is_element_pos(sub, 'absolute') ) {//for example in small device .hover > .submenu may not be absolute anymore!
- $(sub).addClass('can-scroll');
- //show_sub = true;
- if(!old_ie && !hasTouch) adjust_submenu.call(this, sub);
- else {
- //because ie8 needs some time for submenu to be displayed and real value of sub.scrollHeight be kicked in
- var that = this;
- setTimeout(function() { adjust_submenu.call(that, sub) }, 0)
- }
- //}
- //else $(sub).removeClass('can-scroll');
- }
- currentScroll = newScroll;
- }
- else {
- $(sub).removeClass('can-scroll');
- }
- }
- //if(show_sub)
- sub_hide.show();
-
- }).on(event_2, '.nav-list li, .sidebar-shortcuts', function (e) {
- sidebar_vars = $sidebar.ace_sidebar('vars');
-
- if( sidebar_vars['collapsible'] /**|| sidebar_vars['horizontal']*/ ) return;
- if( !$(this).hasClass('hover-show') ) return;
- getSubHide(this).hideDelay();
- });
-
-
- function subHide(li_sub) {
- var self = li_sub, $self = $(self);
- var timer = null;
- var visible = false;
-
- this.show = function() {
- if(timer != null) clearTimeout(timer);
- timer = null;
- $self.addClass('hover-show hover-shown');
- visible = true;
- //let's hide .hover-show elements that are not .hover-shown anymore (i.e. marked for hiding in hideDelay)
- for(var i = 0; i < sidebars.length ; i++)
- {
- sidebars[i].find('.hover-show').not('.hover-shown').each(function() {
- getSubHide(this).hide();
- })
- }
- }
-
- this.hide = function() {
- visible = false;
-
- $self.removeClass('hover-show hover-shown hover-flip');
-
- if(timer != null) clearTimeout(timer);
- timer = null;
-
- var sub = $self.find('> .submenu').get(0);
- if(sub) getSubScroll(sub, 'hide');
- }
-
- this.hideDelay = function(callback) {
- if(timer != null) clearTimeout(timer);
-
- $self.removeClass('hover-shown');//somehow marked for hiding
-
- timer = setTimeout(function() {
- visible = false;
- $self.removeClass('hover-show hover-flip');
- timer = null;
-
- var sub = $self.find('> .submenu').get(0);
- if(sub) getSubScroll(sub, 'hide');
-
- if(typeof callback === 'function') callback.call(this);
- }, that.settings.sub_hover_delay);
- }
-
- this.is_visible = function() {
- return visible;
- }
- }
- function getSubHide(el) {
- var sub_hide = $(el).data('subHide');
- if(!sub_hide) $(el).data('subHide', (sub_hide = new subHide(el)));
- return sub_hide;
- }
-
-
- function getSubScroll(el, func) {
- var sub_scroll = $(el).data('ace_scroll');
- if(!sub_scroll) return false;
- if(typeof func === 'string') {
- sub_scroll[func]();
- return true;
- }
- return sub_scroll;
- }
-
- function adjust_submenu(sub) {
- var $li = $(this);
- var $sub = $(sub);
- sub.style.top = '';
- sub.style.bottom = '';
- var menu_text = null
- if( sidebar_vars['minimized'] && (menu_text = $li.find('.menu-text').get(0)) ) {
- //2nd level items don't have .menu-text
- menu_text.style.marginTop = '';
- }
- var scroll = ace.helper.scrollTop();
- var navbar_height = 0;
- var $scroll = scroll;
-
- if( navbar_fixed ) {
- navbar_height = sidebar.offsetTop;//$navbar.height();
- $scroll += navbar_height + 1;
- //let's avoid our submenu from going below navbar
- //because of chrome z-index stacking issue and firefox's normal .submenu over fixed .navbar flicker issue
- }
- var off = $li.offset();
- off.top = parseInt(off.top);
-
- var extra = 0, parent_height;
-
- sub.style.maxHeight = '';//otherwise scrollHeight won't be consistent in consecutive calls!?
- var sub_h = sub.scrollHeight;
- var parent_height = $li.height();
- if(menu_text) {
- extra = parent_height;
- off.top += extra;
- }
- var sub_bottom = parseInt(off.top + sub_h)
- var move_up = 0;
- var winh = $window.height();
- //if the bottom of menu is going to go below visible window
- var top_space = parseInt(off.top - $scroll - extra);//available space on top
- var win_space = winh;//available window space
-
- var horizontal = sidebar_vars['horizontal'], horizontal_sub = false;
- if(horizontal && this.parentNode == nav_list) {
- move_up = 0;//don't move up first level submenu in horizontal mode
- off.top += $li.height();
- horizontal_sub = true;//first level submenu
- }
- if(!horizontal_sub && (move_up = (sub_bottom - (winh + scroll))) >= 0 ) {
- //don't move up more than available space
- move_up = move_up < top_space ? move_up : top_space;
- //move it up a bit more if there's empty space
- if(move_up == 0) move_up = 20;
- if(top_space - move_up > 10) {
- move_up += parseInt(Math.min(25, top_space - move_up));
- }
- //move it down if submenu's bottom is going above parent LI
- if(off.top + (parent_height - extra) > (sub_bottom - move_up)) {
- move_up -= (off.top + (parent_height - extra) - (sub_bottom - move_up));
- }
- if(move_up > 0) {
- sub.style.top = -(move_up) + 'px';
- if( menu_text ) {
- menu_text.style.marginTop = -(move_up) + 'px';
- }
- }
- }
- if(move_up < 0) move_up = 0;//when it goes below
-
- var pull_up = move_up > 0 && move_up > parent_height - 20;
- if(pull_up) {
- $li.addClass('pull_up');
- }
- else $li.removeClass('pull_up');
-
-
- //flip submenu if out of window width
- if(horizontal) {
- if($li.parent().parent().hasClass('hover-flip')) $li.addClass('hover-flip');//if a parent is already flipped, flip it then!
- else {
- var sub_off = $sub.offset();
- var sub_w = $sub.width();
- var win_w = $window.width();
- if(sub_off.left + sub_w > win_w) {
- $li.addClass('hover-flip');
- }
- }
- }
- //don't add scrollbars if it contains .hover menus
- var has_hover = $li.hasClass('hover') && !sidebar_vars['mobile_view'];
- if(has_hover && $sub.find('> li > .submenu').length > 0) return;
-
- //if( ) {
- var scroll_height = (win_space - (off.top - scroll)) + (move_up);
- //if after scroll, the submenu is above parent LI, then move it down
- var tmp = move_up - scroll_height;
- if(tmp > 0 && tmp < parent_height) scroll_height += parseInt(Math.max(parent_height, parent_height - tmp));
- scroll_height -= 5;
-
- if(scroll_height < 90) {
- return;
- }
-
- var ace_scroll = false;
- if(!nativeScroll) {
- ace_scroll = getSubScroll(sub);
- if(ace_scroll == false) {
- $sub.ace_scroll({
- //hideOnIdle: true,
- observeContent: true,
- detached: true,
- updatePos: false,
- reset: true,
- mouseWheelLock: true,
- styleClass: self.settings.sub_scroll_style
- });
- ace_scroll = getSubScroll(sub);
-
- var track = ace_scroll.get_track();
- if(track) {
- //detach it from body and insert it after submenu for better and cosistent positioning
- $sub.after(track);
- }
- }
-
- ace_scroll.update({size: scroll_height});
- }
- else {
- $sub
- .addClass('sub-scroll')
- .css('max-height', (scroll_height)+'px')
- }
- lastScrollHeight = scroll_height;
- if(!nativeScroll && ace_scroll) {
- if(scroll_height > 14 && sub_h - scroll_height > 4) {
- ace_scroll.enable()
- ace_scroll.reset();
- }
- else {
- ace_scroll.disable();
- }
- //////////////////////////////////
- var track = ace_scroll.get_track();
- if(track) {
- track.style.top = -(move_up - extra - 1) + 'px';
-
- var off = $sub.position();
- var left = off.left
- if( !scroll_right ) {
- left += ($sub.outerWidth() - ace_scroll.track_size());
- }
- else {
- left += 2;
- }
- track.style.left = parseInt(left) + 'px';
-
- if(horizontal_sub) {//first level submenu
- track.style.left = parseInt(left - 2) + 'px';
- track.style.top = parseInt(off.top) + (menu_text ? extra - 2 : 0) + 'px';
- }
- }
- }
- //}
- //again force redraw for safari!
- if( ace.vars['safari'] ) {
- ace.helper.redraw(sub)
- }
- }
- }
-
-
-
- /////////////////////////////////////////////
- $.fn.ace_sidebar_hover = function (option, value) {
- var method_call;
- var $set = this.each(function () {
- var $this = $(this);
- var data = $this.data('ace_sidebar_hover');
- var options = typeof option === 'object' && option;
- if (!data) $this.data('ace_sidebar_hover', (data = new Sidebar_Hover(this, options)));
- if (typeof option === 'string' && typeof data[option] === 'function') {
- method_call = data[option](value);
- }
- });
- return (method_call === undefined) ? $set : method_call;
- }
-
- $.fn.ace_sidebar_hover.defaults = {
- 'sub_sub_hover_delay': 750,
- 'sub_scroll_style': 'no-track scroll-thin'
- }
-
- })(window.jQuery);
- ;/**
- <b>Widget boxes</b>
- */
- (function($ , undefined) {
- var Widget_Box = function(box, options) {
- this.$box = $(box);
- var that = this;
- //this.options = $.extend({}, $.fn.widget_box.defaults, options);
- this.reload = function() {
- var $box = this.$box;
- var $remove_position = false;
- if($box.css('position') == 'static') {
- $remove_position = true;
- $box.addClass('position-relative');
- }
- $box.append('<div class="widget-box-overlay"><i class="'+ ace.vars['icon'] + 'loading-icon fa fa-spinner fa-spin fa-2x white"></i></div>');
- $box.one('reloaded.ace.widget', function() {
- $box.find('.widget-box-overlay').remove();
- if($remove_position) $box.removeClass('position-relative');
- });
- }
- this.close = function() {
- var $box = this.$box;
- var closeSpeed = 300;
- $box.fadeOut(closeSpeed , function(){
- $box.trigger('closed.ace.widget');
- $box.remove();
- }
- )
- }
-
- this.toggle = function(type, button) {
- var $box = this.$box;
- var $body = $box.find('.widget-body').eq(0);
- var $icon = null;
-
- var event_name = typeof type !== 'undefined' ? type : ($box.hasClass('collapsed') ? 'show' : 'hide');
- var event_complete_name = event_name == 'show' ? 'shown' : 'hidden';
- if(typeof button === 'undefined') {
- button = $box.find('> .widget-header a[data-action=collapse]').eq(0);
- if(button.length == 0) button = null;
- }
- if(button) {
- $icon = button.find(ace.vars['.icon']).eq(0);
- var $match
- var $icon_down = null
- var $icon_up = null
- if( ($icon_down = $icon.attr('data-icon-show')) ) {
- $icon_up = $icon.attr('data-icon-hide')
- }
- else if( $match = $icon.attr('class').match(/fa\-(.*)\-(up|down)/) ) {
- $icon_down = 'fa-'+$match[1]+'-down'
- $icon_up = 'fa-'+$match[1]+'-up'
- }
- }
- var expandSpeed = 250;
- var collapseSpeed = 200;
- if( event_name == 'show' ) {
- if($icon) $icon.removeClass($icon_down).addClass($icon_up);
- $body.hide();
- $box.removeClass('collapsed');
- $body.slideDown(expandSpeed, function(){
- $box.trigger(event_complete_name+'.ace.widget')
- })
- }
- else {
- if($icon) $icon.removeClass($icon_up).addClass($icon_down);
- $body.slideUp(collapseSpeed, function(){
- $box.addClass('collapsed')
- $box.trigger(event_complete_name+'.ace.widget')
- }
- );
- }
- }
-
- this.hide = function() {
- this.toggle('hide');
- }
- this.show = function() {
- this.toggle('show');
- }
-
-
- this.fullscreen = function() {
- var $icon = this.$box.find('> .widget-header a[data-action=fullscreen]').find(ace.vars['.icon']).eq(0);
- var $icon_expand = null
- var $icon_compress = null
- if( ($icon_expand = $icon.attr('data-icon1')) ) {
- $icon_compress = $icon.attr('data-icon2')
- }
- else {
- $icon_expand = 'fa-expand';
- $icon_compress = 'fa-compress';
- }
-
-
- if(!this.$box.hasClass('fullscreen')) {
- $icon.removeClass($icon_expand).addClass($icon_compress);
- this.$box.addClass('fullscreen');
-
- applyScrollbars(this.$box, true);
- }
- else {
- $icon.addClass($icon_expand).removeClass($icon_compress);
- this.$box.removeClass('fullscreen');
-
- applyScrollbars(this.$box, false);
- }
-
- this.$box.trigger('fullscreened.ace.widget')
- }
- }
-
- $.fn.widget_box = function (option, value) {
- var method_call;
- var $set = this.each(function () {
- var $this = $(this);
- var data = $this.data('widget_box');
- var options = typeof option === 'object' && option;
- if (!data) $this.data('widget_box', (data = new Widget_Box(this, options)));
- if (typeof option === 'string') method_call = data[option](value);
- });
- return (method_call === undefined) ? $set : method_call;
- };
- $(document).on('click.ace.widget', '.widget-header a[data-action]', function (ev) {
- ev.preventDefault();
- var $this = $(this);
- var $box = $this.closest('.widget-box');
- if( $box.length == 0 || $box.hasClass('ui-sortable-helper') ) return;
- var $widget_box = $box.data('widget_box');
- if (!$widget_box) {
- $box.data('widget_box', ($widget_box = new Widget_Box($box.get(0))));
- }
- var $action = $this.data('action');
- if($action == 'collapse') {
- var event_name = $box.hasClass('collapsed') ? 'show' : 'hide';
- var event
- $box.trigger(event = $.Event(event_name+'.ace.widget'))
- if (event.isDefaultPrevented()) return
- $widget_box.toggle(event_name, $this);
- }
- else if($action == 'close') {
- var event
- $box.trigger(event = $.Event('close.ace.widget'))
- if (event.isDefaultPrevented()) return
- $widget_box.close();
- }
- else if($action == 'reload') {
- $this.blur();
- var event
- $box.trigger(event = $.Event('reload.ace.widget'))
- if (event.isDefaultPrevented()) return
- $widget_box.reload();
- }
- else if($action == 'fullscreen') {
- var event
- $box.trigger(event = $.Event('fullscreen.ace.widget'))
- if (event.isDefaultPrevented()) return
-
- $widget_box.fullscreen();
- }
- else if($action == 'settings') {
- $box.trigger('setting.ace.widget')
- }
- });
-
-
- function applyScrollbars($widget, enable) {
- var $main = $widget.find('.widget-main').eq(0);
- $(window).off('resize.widget.scroll');
-
- //IE8 has an unresolvable issue!!! re-scrollbaring with unknown values?!
- var nativeScrollbars = ace.vars['old_ie'] || ace.vars['touch'];
-
- if(enable) {
- var ace_scroll = $main.data('ace_scroll');
- if( ace_scroll ) {
- $main.data('save_scroll', {size: ace_scroll['size'], lock: ace_scroll['lock'], lock_anyway: ace_scroll['lock_anyway']});
- }
-
- var size = $widget.height() - $widget.find('.widget-header').height() - 10;//extra paddings
- size = parseInt(size);
-
- $main.css('min-height', size);
- if( !nativeScrollbars ) {
- if( ace_scroll ) {
- $main.ace_scroll('update', {'size': size, 'mouseWheelLock': true, 'lockAnyway': true});
- }
- else {
- $main.ace_scroll({'size': size, 'mouseWheelLock': true, 'lockAnyway': true});
- }
- $main.ace_scroll('enable').ace_scroll('reset');
- }
- else {
- if( ace_scroll ) $main.ace_scroll('disable');
- $main.css('max-height', size).addClass('overflow-scroll');
- }
-
-
- $(window)
- .on('resize.widget.scroll', function() {
- var size = $widget.height() - $widget.find('.widget-header').height() - 10;//extra paddings
- size = parseInt(size);
-
- $main.css('min-height', size);
- if( !nativeScrollbars ) {
- $main.ace_scroll('update', {'size': size}).ace_scroll('reset');
- }
- else {
- $main.css('max-height', size).addClass('overflow-scroll');
- }
- });
- }
-
- else {
- $main.css('min-height', '');
- var saved_scroll = $main.data('save_scroll');
- if(saved_scroll) {
- $main
- .ace_scroll('update', {'size': saved_scroll['size'], 'mouseWheelLock': saved_scroll['lock'], 'lockAnyway': saved_scroll['lock_anyway']})
- .ace_scroll('enable')
- .ace_scroll('reset');
- }
-
- if( !nativeScrollbars ) {
- if(!saved_scroll) $main.ace_scroll('disable');
- }
- else {
- $main.css('max-height', '').removeClass('overflow-scroll');
- }
- }
- }
- })(window.jQuery);;/**
- <b>Settings box</b>. It's good for demo only. You don't need this.
- */
- (function($ , undefined) {
- $('#ace-settings-btn').on(ace.click_event, function(e){
- e.preventDefault();
- $(this).toggleClass('open');
- $('#ace-settings-box').toggleClass('open');
- })
- $('#ace-settings-navbar').on('click', function(){
- ace.settings.navbar_fixed(null, this.checked);//@ ace-extra.js
- //$(window).triggerHandler('resize.navbar');
- //force redraw?
- //if(ace.vars['webkit']) ace.helper.redraw(document.body);
- }).each(function(){this.checked = ace.settings.is('navbar', 'fixed')})
- $('#ace-settings-sidebar').on('click', function(){
- ace.settings.sidebar_fixed(null, this.checked);//@ ace-extra.js
- //if(ace.vars['webkit']) ace.helper.redraw(document.body);
- }).each(function(){this.checked = ace.settings.is('sidebar', 'fixed')})
- $('#ace-settings-breadcrumbs').on('click', function(){
- ace.settings.breadcrumbs_fixed(null, this.checked);//@ ace-extra.js
- //if(ace.vars['webkit']) ace.helper.redraw(document.body);
- }).each(function(){this.checked = ace.settings.is('breadcrumbs', 'fixed')})
- $('#ace-settings-add-container').on('click', function(){
- ace.settings.main_container_fixed(null, this.checked);//@ ace-extra.js
- //if(ace.vars['webkit']) ace.helper.redraw(document.body);
- }).each(function(){this.checked = ace.settings.is('main-container', 'fixed')})
- $('#ace-settings-compact').on('click', function(){
- if(this.checked) {
- $('#sidebar').addClass('compact');
- var hover = $('#ace-settings-hover');
- if( hover.length > 0 ) {
- hover.removeAttr('checked').trigger('click');
- }
- }
- else {
- $('#sidebar').removeClass('compact');
- $('#sidebar[data-sidebar-scroll=true]').ace_sidebar_scroll('reset')
- }
-
- if(ace.vars['old_ie']) ace.helper.redraw($('#sidebar')[0], true);
- })/*.removeAttr('checked')*/
- $('#ace-settings-highlight').on('click', function(){
- if(this.checked) $('#sidebar .nav-list > li').addClass('highlight');
- else $('#sidebar .nav-list > li').removeClass('highlight');
-
- if(ace.vars['old_ie']) ace.helper.redraw($('#sidebar')[0]);
- })/*.removeAttr('checked')*/
- $('#ace-settings-hover').on('click', function(){
- if($('#sidebar').hasClass('h-sidebar')) return;
- if(this.checked) {
- $('#sidebar li').addClass('hover')
- .filter('.open').removeClass('open').find('> .submenu').css('display', 'none');
- //and remove .open items
- }
- else {
- $('#sidebar li.hover').removeClass('hover');
- var compact = $('#ace-settings-compact');
- if( compact.length > 0 && compact.get(0).checked ) {
- compact.trigger('click');
- }
- }
-
- $('.sidebar[data-sidebar-hover=true]').ace_sidebar_hover('reset')
- $('.sidebar[data-sidebar-scroll=true]').ace_sidebar_scroll('reset')
-
- if(ace.vars['old_ie']) ace.helper.redraw($('#sidebar')[0]);
- })/*.removeAttr('checked')*/
- })(jQuery);;/**
- <b>RTL</b> (right-to-left direction for Arabic, Hebrew, Persian languages).
- It's good for demo only.
- You should hard code RTL-specific changes inside your HTML/server-side code.
- Dynamically switching to RTL using Javascript is not a good idea.
- Please refer to documentation for more info.
- */
- (function($ , undefined) {
- //Switching to RTL (right to left) Mode
- $('#ace-settings-rtl').removeAttr('checked').on('click', function(){
- switch_direction();
- });
-
-
- //>>> you should hard code changes inside HTML for RTL direction
- //you shouldn't use this function to switch direction
- //this is only for dynamically switching for demonstration
- //take a look at this function to see what changes should be made
- //also take a look at docs for some tips
- var switch_direction = function() {
- if($('#ace-rtl-stylesheet').length == 0) {
- //let's load RTL stylesheet only when needed!
- var ace_style = $('head').find('link.ace-main-stylesheet');
- if(ace_style.length == 0) {
- ace_style = $('head').find('link[href*="/ace.min.css"],link[href*="/ace-part2.min.css"]');
- if(ace_style.length == 0) {
- ace_style = $('head').find('link[href*="/ace.css"],link[href*="/ace-part2.css"]');
- }
- }
-
- var ace_skins = $('head').find('link#ace-skins-stylesheet');
- var stylesheet_url = ace_style.first().attr('href').replace(/(\.min)?\.css$/i , '-rtl$1.css');
- $.ajax({
- 'url': stylesheet_url
- }).done(function() {
- var new_link = jQuery('<link />', {type : 'text/css', rel: 'stylesheet', 'id': 'ace-rtl-stylesheet'})
- if(ace_skins.length > 0) {
- new_link.insertAfter(ace_skins);
- }
- else if(ace_style.length > 0){
- new_link.insertAfter(ace_style.last());
- }
- else new_link.appendTo('head');
-
- new_link.attr('href', stylesheet_url);
- //we set "href" after insertion, for IE to work
-
- applyChanges();
- if(window.Pace && Pace.running) Pace.stop();
- })
- }
- else {
- applyChanges();
- }
-
- //in ajax when new content is loaded, we dynamically apply RTL changes again
- //please note that this is only for Ace demo
- //for info about RTL see Ace's docs
- $('.page-content-area[data-ajax-content=true]').on('ajaxscriptsloaded.rtl', function() {
- if( $('body').hasClass('rtl') ) {
- applyChanges(this);
- }
- });
- /////////////////////////
- function applyChanges(el) {
- var $body = $(document.body);
- if(!el) $body.toggleClass('rtl');//el is 'body'
- el = el || document.body;
- var $container = $(el);
- $container
- //toggle pull-right class on dropdown-menu
- .find('.dropdown-menu:not(.datepicker-dropdown,.colorpicker)').toggleClass('dropdown-menu-right')
- .end()
- //swap pull-left & pull-right
- .find('.pull-right:not(.dropdown-menu,blockquote,.profile-skills .pull-right)').removeClass('pull-right').addClass('tmp-rtl-pull-right')
- .end()
- .find('.pull-left:not(.dropdown-submenu,.profile-skills .pull-left)').removeClass('pull-left').addClass('pull-right')
- .end()
- .find('.tmp-rtl-pull-right').removeClass('tmp-rtl-pull-right').addClass('pull-left')
- .end()
-
- .find('.chosen-select').toggleClass('chosen-rtl').next().toggleClass('chosen-rtl');
-
- function swap_classes(class1, class2) {
- $container
- .find('.'+class1).removeClass(class1).addClass('tmp-rtl-'+class1)
- .end()
- .find('.'+class2).removeClass(class2).addClass(class1)
- .end()
- .find('.tmp-rtl-'+class1).removeClass('tmp-rtl-'+class1).addClass(class2)
- }
- swap_classes('align-left', 'align-right');
- swap_classes('no-padding-left', 'no-padding-right');
- swap_classes('arrowed', 'arrowed-right');
- swap_classes('arrowed-in', 'arrowed-in-right');
- swap_classes('tabs-left', 'tabs-right');
- swap_classes('messagebar-item-left', 'messagebar-item-right');//for inbox page
-
- $('.modal.aside-vc').ace_aside('flip').ace_aside('insideContainer');
-
-
- //mirror all icons and attributes that have a "fa-*-right|left" attrobute
- $container.find('.fa').each(function() {
- if(this.className.match(/ui-icon/) || $(this).closest('.fc-button').length > 0) return;
- //skip mirroring icons of plugins that have built in RTL support
- var l = this.attributes.length;
- for(var i = 0 ; i < l ; i++) {
- var val = this.attributes[i].value;
- if(val.match(/fa\-(?:[\w\-]+)\-left/))
- this.attributes[i].value = val.replace(/fa\-([\w\-]+)\-(left)/i , 'fa-$1-right')
- else if(val.match(/fa\-(?:[\w\-]+)\-right/))
- this.attributes[i].value = val.replace(/fa\-([\w\-]+)\-(right)/i , 'fa-$1-left')
- }
- });
-
- //browsers are incosistent with horizontal scroll and RTL
- //so let's make our scrollbars LTR and wrap the content inside RTL
- var rtl = $body.hasClass('rtl');
- if(rtl) {
- $container.find('.scroll-hz').addClass('make-ltr')
- .find('.scroll-content')
- .wrapInner('<div class="make-rtl" />');
- $('.sidebar[data-sidebar-hover=true]').ace_sidebar_hover('changeDir', 'right');
- }
- else {
- //remove the wrap
- $container.find('.scroll-hz').removeClass('make-ltr')
- .find('.make-rtl').children().unwrap();
- $('.sidebar[data-sidebar-hover=true]').ace_sidebar_hover('changeDir', 'left');
- }
- if($.fn.ace_scroll) $container.find('.scroll-hz').ace_scroll('reset') //to reset scrollLeft
- //redraw the traffic pie chart on homepage with a different parameter
- try {
- var placeholder = $('#piechart-placeholder');
- if(placeholder.length > 0) {
- var pos = $body.hasClass('rtl') ? 'nw' : 'ne';//draw on north-west or north-east?
- placeholder.data('draw').call(placeholder.get(0) , placeholder, placeholder.data('chart'), pos);
- }
- }catch(e) {}
-
-
- ace.helper.redraw(el, true);
- }
- }
- })(jQuery);
- ;/**
- <b>Select a different skin</b>. It's good for demo only.
- You should hard code skin-specific changes inside your HTML/server-side code.
- Please refer to documentation for more info.
- */
- (function($ , undefined) {
- try {
- $('#skin-colorpicker').ace_colorpicker({'auto_pos': false});
- } catch(e) {}
- $('#skin-colorpicker').on('change', function(){
- var skin_class = $(this).find('option:selected').data('skin');
- if($('#ace-skins-stylesheet').length == 0) {
- //let's load skins stylesheet only when needed!
- var ace_style = $('head').find('link.ace-main-stylesheet');
- if(ace_style.length == 0) {
- ace_style = $('head').find('link[href*="/ace.min.css"],link[href*="/ace-part2.min.css"]');
- if(ace_style.length == 0) {
- ace_style = $('head').find('link[href*="/ace.css"],link[href*="/ace-part2.css"]');
- }
- }
-
- var stylesheet_url = ace_style.first().attr('href').replace(/(\.min)?\.css$/i , '-skins$1.css');
- $.ajax({
- 'url': stylesheet_url
- }).done(function() {
- var new_link = jQuery('<link />', {type : 'text/css', rel: 'stylesheet', 'id': 'ace-skins-stylesheet'})
- if(ace_style.length > 0){
- new_link.insertAfter(ace_style.last());
- }
- else new_link.appendTo('head');
-
- new_link.attr('href', stylesheet_url);
- //we set "href" after insertion, for IE to work
-
- applyChanges(skin_class);
- if(window.Pace && Pace.running) Pace.stop();
- })
- }
- else {
- applyChanges(skin_class);
- }
- function applyChanges(skin_class) {
- //skin cookie tip
- var body = $(document.body);
- body.removeClass('no-skin skin-1 skin-2 skin-3');
- //if(skin_class != 'skin-0') {
- body.addClass(skin_class);
- ace.data.set('skin', skin_class);
- //save the selected skin to cookies
- //which can later be used by your server side app to set the skin
- //for example: <body class="<?php echo $_COOKIE['ace_skin']; ?>"
- //} else ace.data.remove('skin');
-
- var skin3_colors = ['red', 'blue', 'green', ''];
-
- //undo skin-1
- $('.ace-nav > li.grey').removeClass('dark');
-
- //undo skin-2
- $('.ace-nav > li').removeClass('no-border margin-1');
- $('.ace-nav > li:not(:last-child)').removeClass('light-pink').find('> a > '+ace.vars['.icon']).removeClass('pink').end().eq(0).find('.badge').removeClass('badge-warning');
- $('.sidebar-shortcuts .btn')
- .removeClass('btn-pink btn-white')
- .find(ace.vars['.icon']).removeClass('white');
-
- //undo skin-3
- $('.ace-nav > li.grey').removeClass('red').find('.badge').removeClass('badge-yellow');
- $('.sidebar-shortcuts .btn').removeClass('btn-primary btn-white')
- var i = 0;
- $('.sidebar-shortcuts .btn').each(function() {
- $(this).find(ace.vars['.icon']).removeClass(skin3_colors[i++]);
- })
-
-
-
- var skin0_buttons = ['btn-success', 'btn-info', 'btn-warning', 'btn-danger'];
- if(skin_class == 'no-skin') {
- var i = 0;
- $('.sidebar-shortcuts .btn').each(function() {
- $(this).attr('class', 'btn ' + skin0_buttons[i++%4]);
- })
-
- $('.sidebar[data-sidebar-scroll=true]').ace_sidebar_scroll('updateStyle', '');
- $('.sidebar[data-sidebar-hover=true]').ace_sidebar_hover('updateStyle', 'no-track scroll-thin');
- }
- else if(skin_class == 'skin-1') {
- $('.ace-nav > li.grey').addClass('dark');
- var i = 0;
- $('.sidebar-shortcuts')
- .find('.btn').each(function() {
- $(this).attr('class', 'btn ' + skin0_buttons[i++%4]);
- })
-
- $('.sidebar[data-sidebar-scroll=true]').ace_sidebar_scroll('updateStyle', 'scroll-white no-track');
- $('.sidebar[data-sidebar-hover=true]').ace_sidebar_hover('updateStyle', 'no-track scroll-thin scroll-white');
- }
- else if(skin_class == 'skin-2') {
- $('.ace-nav > li').addClass('no-border margin-1');
- $('.ace-nav > li:not(:last-child)').addClass('light-pink').find('> a > '+ace.vars['.icon']).addClass('pink').end().eq(0).find('.badge').addClass('badge-warning');
-
- $('.sidebar-shortcuts .btn').attr('class', 'btn btn-white btn-pink')
- .find(ace.vars['.icon']).addClass('white');
-
- $('.sidebar[data-sidebar-scroll=true]').ace_sidebar_scroll('updateStyle', 'scroll-white no-track');
- $('.sidebar[data-sidebar-hover=true]').ace_sidebar_hover('updateStyle', 'no-track scroll-thin scroll-white');
- }
- //skin-3
- //change shortcut buttons classes, this should be hard-coded if you want to choose this skin
- else if(skin_class == 'skin-3') {
- body.addClass('no-skin');//because skin-3 has many parts of no-skin as well
-
- $('.ace-nav > li.grey').addClass('red').find('.badge').addClass('badge-yellow');
-
- var i = 0;
- $('.sidebar-shortcuts .btn').each(function() {
- $(this).attr('class', 'btn btn-primary btn-white');
- $(this).find(ace.vars['.icon']).addClass(skin3_colors[i++]);
- })
-
- $('.sidebar[data-sidebar-scroll=true]').ace_sidebar_scroll('updateStyle', 'scroll-dark no-track');
- $('.sidebar[data-sidebar-hover=true]').ace_sidebar_hover('updateStyle', 'no-track scroll-thin');
- }
- //some sizing differences may be there in skins, so reset scrollbar size
- $('.sidebar[data-sidebar-scroll=true]').ace_sidebar_scroll('reset')
- //$('.sidebar[data-sidebar-hover=true]').ace_sidebar_hover('reset')
-
- if(ace.vars['old_ie']) ace.helper.redraw(document.body, true);
- }
- })
- })(jQuery);;/**
- The widget box reload button/event handler. You should use your own handler. An example is available at <i class="text-info">examples/widgets.html</i>.
- <u><i class="glyphicon glyphicon-flash"></i> You don't need this. Used for demo only</u>
- */
- (function($ , undefined) {
- //***default action for reload in this demo
- //you should remove this and add your own handler for each specific .widget-box
- //when data is finished loading or processing is done you can call $box.trigger('reloaded.ace.widget')
- $(document).on('reload.ace.widget', '.widget-box', function (ev) {
- var $box = $(this);
-
- //trigger the reloaded event to remove the spinner icon after 1-2 seconds
- setTimeout(function() {
- $box.trigger('reloaded.ace.widget');
- }, parseInt(Math.random() * 1000 + 1000));
- });
- //you may want to do something like this:
- /**
- $('#my-widget-box').on('reload.ace.widget', function(){
- //load new data here
- //and when finished trigger "reloaded" event
- $(this).trigger('reloaded.ace.widget');
- });
- */
- })(window.jQuery);;/**
- The autocomplete dropdown when typing inside search box.
- <u><i class="glyphicon glyphicon-flash"></i> You don't need this. Used for demo only</u>
- */
- (function($ , undefined) {
- ace.vars['US_STATES'] = ["Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Dakota","North Carolina","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming"]
- try {
- $('#nav-search-input').bs_typeahead({
- source: ace.vars['US_STATES'],
- updater:function (item) {
- //when an item is selected from dropdown menu, focus back to input element
- $('#nav-search-input').focus();
- return item;
- }
- });
- } catch(e) {}
- })(window.jQuery);
|