<commit_before>﻿/// <reference path="../../../ext/ext-core-debug.js"/>
/// <reference path="../../../reui/reui.js"/>
/// <reference path="../../../platform/Application.js"/>
/// <reference path="../../../platform/View.js"/>
/// <reference path="Application.js"/>

Ext.namespace("Mobile.SalesLogix");

/// this is a very simple home view.
Mobile.SalesLogix.ContextDialog = Ext.extend(Sage.Platform.Mobile.View, {
    titleText: '',
    cancelText: 'Cancel',
    activitiesText: 'Activities',
    notesText: 'Notes',
    viewTemplate: new Simplate([
        '<form id="{%= id %}" class="dialog">',
            '<fieldset>',
                '<ul>',
                    '<li><a href="" class="button activities blueButton">{%= $.activitiesText %}</a></li>',
                    '<li><a href="" class="button notes blueButton">{%= $.notesText %}</a></li>',
                    '<li><a type="cancel" class="button dismissButton redButton">{%= $.cancelText %}</a></li>',
                '</ul>',
            '</fieldset>',
        '</form>'
    ]),
    constructor: function(o) {
        Mobile.SalesLogix.ContextDialog.superclass.constructor.call(this);

        Ext.apply(this, o, {
            id: 'context_dialog',
            title: this.titleText,
            expose: false
        });
    },
    init: function() {
        Mobile.SalesLogix.ContextDialog.superclass.init.call(this);

        this.el
            .on('submit', function(evt, el, o) {
                return false;
            }, this, { preventDefault: true, stopPropagation: true })
            .dom.onsubmit = false; // fix for iui shenanigans

        this.el.select('.dismissButton')
            .on('click', function(evt, el, o) {
                this.dismissDialog();
            }, this, { preventDefault: true, stopPropagation: true });

        this.el.select('.activities')
            .on('click', function(evt, el, o) {
                this.dismissDialog();
            }, this, { preventDefault: true, stopPropagation: true });

        this.el.select('.notes')
            .on('click', function(evt, el, o) {
                this.dismissDialog();
            }, this, { preventDefault: true, stopPropagation: true });
    },
    dismissDialog: function() {
        this.el.dom.removeAttribute('selected');
        // UGLY Hack... Find another way to show/hide Search box.
        // May be it should not use "selected" attribute.
        Ext.select('#search_dialog').item(0).dom.setAttribute('selected', 'true');
    }
});<commit_msg>[#4208426] Modified ContextDialog.js for Account List Long click<commit_after>﻿/// <reference path="../../../ext/ext-core-debug.js"/>
/// <reference path="../../../reui/reui.js"/>
/// <reference path="../../../platform/Application.js"/>
/// <reference path="../../../platform/View.js"/>
/// <reference path="Application.js"/>

Ext.namespace("Mobile.SalesLogix");

/// this is a very simple home view.
Mobile.SalesLogix.ContextDialog = Ext.extend(Sage.Platform.Mobile.View, {
    titleText: '',
    cancelText: 'Cancel',
    activitiesText: 'Activities',
    notesText: 'Notes',
    detailView: '',
    relatedKey: '',
    viewTemplate: new Simplate([
        '<form id="{%= id %}" class="dialog">',
            '<fieldset>',
                '<ul>',
                    '<li><a href="" class="button activities blueButton">{%= $.activitiesText %}</a></li>',
                    '<li><a href="" class="button notes blueButton">{%= $.notesText %}</a></li>',
                    '<li><a type="cancel" class="button dismissButton redButton">{%= $.cancelText %}</a></li>',
                '</ul>',
            '</fieldset>',
        '</form>'
    ]),
    constructor: function(o) {
        Mobile.SalesLogix.ContextDialog.superclass.constructor.call(this);

        Ext.apply(this, o, {
            id: 'context_dialog',
            title: this.titleText,
            expose: false
        });
    },
    init: function() {
        Mobile.SalesLogix.ContextDialog.superclass.init.call(this);
        var getRelatedOptionsFromLayout = function(detailView, type) {
            for (var i = detailView.layout.length - 1; i >= 0; i--) {
                var as = detailView.layout[i].as;
                if (!as) continue;
                for (var j = as.length - 1; j >= 0; j--) {
                    if (as[j].view == type) {
                        return as[j];
                    }
                }
            }
        };

        var handlerForRelatedType = function(evt, el, o, scope, related_view) {
            scope.dismissDialog();

            var detailView = App.getView(scope.detailView),
                o = {},
                activityRelatedOptions = getRelatedOptionsFromLayout(detailView, related_view);
            o.where = detailView.expandExpression(activityRelatedOptions.where, {"$key": scope.relatedKey});

            detailView.navigateToRelated(related_view, o);
            //Reset key and descriptor
            scope.detailView = '';
            scope.relatedKey = '';
        };

        this.el
            .on('submit', function(evt, el, o) {
                return false;
            }, this, { preventDefault: true, stopPropagation: true })
            .dom.onsubmit = false; // fix for iui shenanigans

        this.el.select('.dismissButton')
            .on('click', function(evt, el, o) {
                this.dismissDialog();
            }, this, { preventDefault: true, stopPropagation: true });

        this.el.select('.activities')
            .on('click', function(evt, el, o) {
                handlerForRelatedType(evt, el, o, this, "activity_related");
            }, this, { preventDefault: true, stopPropagation: true });

        this.el.select('.notes')
            .on('click', function(evt, el, o) {
                handlerForRelatedType(evt, el, o, this, "note_related");
            }, this, { preventDefault: true, stopPropagation: true });
    },

    show: function(el) {
        Mobile.SalesLogix.ContextDialog.superclass.show.call(this);
        el = new Ext.Element(el);
        var link = el.parent('a');
        this.detailView = link.dom.hash.substring(1);
        this.relatedKey = link.getAttribute("m:key");
    },

    dismissDialog: function() {
        this.el.dom.removeAttribute('selected');
        // UGLY Hack... Find another way to show/hide Search box.
        // May be it should not use "selected" attribute.
        Ext.select('#search_dialog').item(0).dom.setAttribute('selected', 'true');
    }
});
{'fraction_non_alphanumeric': 0.17318952234206472, 'fraction_numerical': 0.0021571648690292757, 'mean_word_length': 2.006484483557202, 'pattern_counts': {'":': 1, '<': 49, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4009095', 'n_tokens_mistral': 1858, 'n_tokens_neox': 1813, 'n_words': 384}