<commit_before>/****************************************************************************
**
** Copyright (C) 2014 Jolla Ltd.
** Contact: <NAME> <<EMAIL>>
** Contact: <NAME> <<EMAIL>>
**
****************************************************************************/

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

import QtQuick 2.2
import Sailfish.Silica 1.0
import Sailfish.Browser 1.0
import "." as Browser

Column {
    id: toolBarRow

    property string url
    property string findText
    property real secondaryToolsHeight
    property bool secondaryToolsActive
    property bool findInPageActive
    readonly property bool showFindButtons: webView.findInPageHasResult && findInPageActive
    property alias bookmarked: secondaryBar.bookmarked
    readonly property alias toolsHeight: toolsRow.height

    signal showTabs
    signal showOverlay
    signal showSecondaryTools
    signal showChrome
    signal closeActiveTab

    // Used from SecondaryBar
    signal enterNewTabUrl
    signal findInPage
    signal shareActivePage
    signal bookmarkActivePage
    signal removeActivePageFromBookmarks

    function resetFind() {
        webView.sendAsyncMessage("embedui:find", { text: "", backwards: false, again: false })
        if (webView.contentItem) {
            webView.contentItem.forceChrome(false)
        }

        findInPageActive = false
    }

    width: parent.width

    onFindInPageActiveChanged: {
        // Down allow hiding of toolbar when finding text from the page.
        if (findInPageActive && webView.contentItem) {
            webView.contentItem.forceChrome(true)
        }
    }

    SecondaryBar {
        id: secondaryBar
        visible: opacity > 0.0 || height > 0.0
        opacity: secondaryToolsActive ? 1.0 : 0.0
        height: secondaryToolsHeight
        horizontalOffset: toolsRow.horizontalOffset
        iconWidth: toolsRow.iconWidth

        Behavior on opacity { FadeAnimation {} }
    }

    Row {
        id: toolsRow
        readonly property int horizontalOffset: Theme.paddingSmall
        readonly property int iconWidth: Theme.iconSizeMedium + 2 * Theme.paddingMedium

        width: parent.width
        height: isPortrait ? Settings.toolbarLarge : Settings.toolbarSmall

        // Container item for cross fading tabs, close, find in page button (and keep Row's width still).
        Item {
            id: tabButton

            width: toolsRow.iconWidth + toolsRow.horizontalOffset
            height: parent.height

            Browser.TabButton {
                id: tabs

                opacity: secondaryToolsActive || findInPageActive ? 0.0 : 1.0
                horizontalOffset: toolsRow.horizontalOffset
                label.text: webView.tabModel.count
                onTapped: toolBarRow.showTabs()

                SequentialAnimation {
                    id: animation
                    loops: 2
                    alwaysRunToEnd: true

                    ScaleAnimator {
                        target: tabs
                        from: 1.0
                        to: 1.3
                        duration: 500
                        easing.type: Easing.InOutQuad
                    }
                    ScaleAnimator {
                        target: tabs
                        from: 1.3
                        to: 1.0
                        duration: 500
                        easing.type: Easing.InOutQuad
                    }
                }

                Connections {
                    target: webView.tabModel
                    onNewTabRequested: animation.start()
                }
            }

            Browser.IconButton {
                opacity: secondaryToolsActive && !findInPageActive ? 1.0 : 0.0
                icon.source: "image://theme/icon-m-tab-close"
                icon.anchors.horizontalCenterOffset: toolsRow.horizontalOffset
                active: webView.tabModel.count > 0
                onTapped: closeActiveTab()
            }

            Browser.IconButton {
                opacity: !secondaryToolsActive && findInPageActive ? 1.0 : 0.0
                icon.source: "image://theme/icon-m-search"
                icon.anchors.horizontalCenterOffset: toolsRow.horizontalOffset
                onTapped: {
                    findInPageActive = true
                    findInPage()
                }
            }
        }

        Browser.ExpandingButton {
            id: backIcon
            expandedWidth: toolsRow.iconWidth
            icon.source: "image://theme/icon-m-back"
            active: webView.canGoBack && !toolBarRow.secondaryToolsActive && !findInPageActive
            onTapped: webView.goBack()<commit_msg>Change new tab scale animator to rotation animator<commit_after>/****************************************************************************
**
** Copyright (C) 2014 Jolla Ltd.
** Contact: <NAME> <<EMAIL>>
** Contact: <NAME> <<EMAIL>>
**
****************************************************************************/

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

import QtQuick 2.2
import Sailfish.Silica 1.0
import Sailfish.Browser 1.0
import "." as Browser

Column {
    id: toolBarRow

    property string url
    property string findText
    property real secondaryToolsHeight
    property bool secondaryToolsActive
    property bool findInPageActive
    readonly property bool showFindButtons: webView.findInPageHasResult && findInPageActive
    property alias bookmarked: secondaryBar.bookmarked
    readonly property alias toolsHeight: toolsRow.height

    signal showTabs
    signal showOverlay
    signal showSecondaryTools
    signal showChrome
    signal closeActiveTab

    // Used from SecondaryBar
    signal enterNewTabUrl
    signal findInPage
    signal shareActivePage
    signal bookmarkActivePage
    signal removeActivePageFromBookmarks

    function resetFind() {
        webView.sendAsyncMessage("embedui:find", { text: "", backwards: false, again: false })
        if (webView.contentItem) {
            webView.contentItem.forceChrome(false)
        }

        findInPageActive = false
    }

    width: parent.width

    onFindInPageActiveChanged: {
        // Down allow hiding of toolbar when finding text from the page.
        if (findInPageActive && webView.contentItem) {
            webView.contentItem.forceChrome(true)
        }
    }

    SecondaryBar {
        id: secondaryBar
        visible: opacity > 0.0 || height > 0.0
        opacity: secondaryToolsActive ? 1.0 : 0.0
        height: secondaryToolsHeight
        horizontalOffset: toolsRow.horizontalOffset
        iconWidth: toolsRow.iconWidth

        Behavior on opacity { FadeAnimation {} }
    }

    Row {
        id: toolsRow
        readonly property int horizontalOffset: Theme.paddingSmall
        readonly property int iconWidth: Theme.iconSizeMedium + 2 * Theme.paddingMedium

        width: parent.width
        height: isPortrait ? Settings.toolbarLarge : Settings.toolbarSmall

        // Container item for cross fading tabs, close, find in page button (and keep Row's width still).
        Item {
            id: tabButton

            width: toolsRow.iconWidth + toolsRow.horizontalOffset
            height: parent.height

            Browser.TabButton {
                id: tabs

                opacity: secondaryToolsActive || findInPageActive ? 0.0 : 1.0
                horizontalOffset: toolsRow.horizontalOffset
                label.text: webView.tabModel.count
                onTapped: toolBarRow.showTabs()

                RotationAnimator {
                    id: rotationAnimator
                    target: tabs.icon
                    duration: 1500
                    easing.type: Easing.InOutQuad
                    alwaysRunToEnd: true
                }

                Connections {
                    target: webView.tabModel
                    onNewTabRequested: {
                        // New tab request triggers 90 degrees clockwise rotation
                        // for the tab icon.
                        rotationAnimator.from = rotationAnimator.to
                        rotationAnimator.to = rotationAnimator.from + 90
                        rotationAnimator.restart()
                    }

                    onTabClosed: {
                        // Counter closewise when closing.
                        rotationAnimator.from = rotationAnimator.to
                        rotationAnimator.to = rotationAnimator.from - 90
                        rotationAnimator.restart()
                    }
                }
            }

            Browser.IconButton {
                opacity: secondaryToolsActive && !findInPageActive ? 1.0 : 0.0
                icon.source: "image://theme/icon-m-tab-close"
                icon.anchors.horizontalCenterOffset: toolsRow.horizontalOffset
                active: webView.tabModel.count > 0
                onTapped: closeActiveTab()
            }

            Browser.IconButton {
                opacity: !secondaryToolsActive && findInPageActive ? 1.0 : 0.0
                icon.source: "image://theme/icon-m-search"
                icon.anchors.horizontalCenterOffset: toolsRow.horizontalOffset
                onTapped: {
                    findInPageActive = true
                    findInPage()
                }
            }
        }

        Browser.ExpandingButton {
            id: backIcon
            expandedWidth: toolsRow.iconWidth
            icon.source: "image://theme/icon-m-back"
            active: webView.canGoBack && !toolBarRow.secondaryToolsActive && !findInPageActive
            onTapped: webView.goBack()
{'fraction_non_alphanumeric': 0.09746529873264936, 'fraction_numerical': 0.00975658821162744, 'mean_word_length': 1.7835946248600223, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7567435', 'n_tokens_mistral': 2564, 'n_tokens_neox': 2314, 'n_words': 620}