<commit_before>/*
 * Licensed to Jasig under one or more contributor license
 * agreements. See the NOTICE file distributed with this work
 * for additional information regarding copyright ownership.
 * Jasig licenses this file to you under the Apache License,
 * Version 2.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a
 * copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

(function () {
    var win = Titanium.UI.currentWindow,
        app = win.app,
        activityIndicator = app.views.GlobalActivityIndicator,
        portletViewOpts,
        portletView,
        titleBar,
        initialized,
        pathToRoot = '../../';

    function init() {
        titleBar = new app.views.GenericTitleBar({
            windowKey: 'portlet',
            app: app,
            title: app.localDictionary.uMobile,
            settingsButton: true,
            homeButton: true
        });
        win.add(titleBar);   
        
        portletViewOpts = app.styles.portletView;
        portletView = Titanium.UI.createWebView(portletViewOpts);
        win.add(portletView);
        
        portletView.addEventListener('load', onPortletLoad);
        portletView.addEventListener('beforeload', onBeforePortletLoad);
        Ti.App.addEventListener('includePortlet', onIncludePortlet);
        
        win.add(activityIndicator);
        
        win.initialized = true;
    }
    
    function onIncludePortlet (portlet) {
        if (portletView) {
            Ti.API.debug('portletView exists, removing it.');
            portletView.stopLoading();
            portletView.hide();
        }
        portletView.url = app.UPM.BASE_PORTAL_URL + portlet.url;
        titleBar.updateTitle(portlet.title);
    }
    
    function onBeforePortletLoad (e) {
        Ti.API.debug("Loading portlet");
        activityIndicator.message = app.localDictionary.loading;
        activityIndicator.show();
    }
    
    function onPortletLoad(e) {
        Ti.API.debug("Porlet loaded");
        activityIndicator.hide();
        portletView.show();
    }
    
    if(!win.initialized) {
        init();
    }
    
})();<commit_msg>UMOBILE-7 Adding navigation bar for URLs that appear to be outside the portal<commit_after>/*
 * Licensed to Jasig under one or more contributor license
 * agreements. See the NOTICE file distributed with this work
 * for additional information regarding copyright ownership.
 * Jasig licenses this file to you under the Apache License,
 * Version 2.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a
 * copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

(function () {
    var win = Titanium.UI.currentWindow,
        app = win.app,
        activityIndicator = app.views.GlobalActivityIndicator,
        portletViewOpts,
        portletView,
        titleBar,
        navBar,
        initialized,
        pathToRoot = '../../';

    function init() {
        titleBar = new app.views.GenericTitleBar({
            windowKey: 'portlet',
            app: app,
            title: app.localDictionary.uMobile,
            settingsButton: true,
            homeButton: true
        });
        win.add(titleBar);   
        
        portletViewOpts = app.styles.portletView;
        portletView = Titanium.UI.createWebView(portletViewOpts);
        portletView.top = 40;
        win.add(portletView);
        
        portletView.addEventListener('load', onPortletLoad);
        portletView.addEventListener('beforeload', onBeforePortletLoad);
        Ti.App.addEventListener('includePortlet', onIncludePortlet);

        // initialize navigation back button for URLs outside of the portal
        navBarOptions = app.styles.secondaryNavBarButton;
        navBarOptions.title = app.localDictionary.back;
        navBackButton = Titanium.UI.createButton(navBarOptions);

        // initialize navigation bar for URLs outside the portal
        navBar = new app.views.SecondaryNavBar(app,{
            backButton: navBackButton
        });
        navBar.top = 40;
        navBar.visible = false;
        win.add(navBar);
        navBackButton.addEventListener('click', function() { portletView.goBack(); });

        win.add(activityIndicator);
        
        win.initialized = true;
    }
    
    function onIncludePortlet (portlet) {
        if (portletView) {
            Ti.API.debug('portletView exists, removing it.');
            portletView.stopLoading();
            portletView.hide();
        }
        portletView.url = app.UPM.BASE_PORTAL_URL + portlet.url;
        titleBar.updateTitle(portlet.title);
    }
    
    function onBeforePortletLoad (e) {
        Ti.API.debug("Loading portlet");
        activityIndicator.message = app.localDictionary.loading;
        activityIndicator.show();
    }
    
    function onPortletLoad(e) {
        Ti.API.debug("Porlet loaded");
        activityIndicator.hide();
        
        var newUrl = e.url;
        if (newUrl.indexOf('localhost:8080/uPortal') >= 0) {
            navBar.visible = false;
            portletView.top = 40;
        } else {
            Ti.API.info("making visible");
            navBar.visible = true;
            portletView.top = 80;
        }

        portletView.show();
    }
    
    if(!win.initialized) {
        init();
    }
    
})();
{'fraction_non_alphanumeric': 0.0953480699439129, 'fraction_numerical': 0.003629165291982844, 'mean_word_length': 2.322191780821918, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7314977', 'n_tokens_mistral': 1633, 'n_tokens_neox': 1625, 'n_words': 433}