<commit_before>// Copyright 2016 Documize Inc. <<EMAIL>>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under 
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <<EMAIL>>. 
//
// https://documize.com

import Ember from 'ember';
import stringUtil from '../utils/string';

export default Ember.Component.extend({
    target: null,
    open: "click",
    position: 'bottom right',
    contentId: "",
    drop: null,

    didReceiveAttrs() {
        this.set("contentId", 'dropdown-menu-' + stringUtil.makeId(10));

        // if (this.session.get('isMobile')) {
        // 	this.set('open', "click");
        // }
    },

    didInsertElement() {
        this._super(...arguments);
        let self = this;

        let drop = new Drop({
            target: document.getElementById(self.get('target')),
            content: self.$(".dropdown-menu")[0],
            classes: 'drop-theme-menu',
            position: self.get('position'),
            openOn: self.get('open'),
            tetherOptions: {
                offset: "5px 0",
                targetOffset: "10px 0"
            }
        });

        self.set('drop', drop);
    },

    willDestroyElement() {
        this.get('drop').destroy();
    }
});<commit_msg>Use tether service in dropdown menu<commit_after>// Copyright 2016 Documize Inc. <<EMAIL>>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <<EMAIL>>.
//
// https://documize.com

import Ember from 'ember';
import stringUtil from '../utils/string';

export default Ember.Component.extend({
	target: null,
	open: "click",
	position: 'bottom right',
	contentId: "",
	drop: null,
	tether: Ember.inject.service(),

	didReceiveAttrs() {
		this.set("contentId", 'dropdown-menu-' + stringUtil.makeId(10));

		// if (this.session.get('isMobile')) {
		// 	this.set('open', "click");
		// }
	},

	didInsertElement() {
		this._super(...arguments);
		let self = this;

		let drop = this.get('tether').createDrop({
			target: document.getElementById(self.get('target')),
			content: self.$(".dropdown-menu")[0],
			classes: 'drop-theme-menu',
			position: self.get('position'),
			openOn: self.get('open'),
			tetherOptions: {
				offset: "5px 0",
				targetOffset: "10px 0"
			}
		});

		self.set('drop', drop);
	},

	willDestroyElement() {
		let drop = this.get('drop');
		if (drop) {
			drop.destroy();
		}
	}
});
{'fraction_non_alphanumeric': 0.16678700361010831, 'fraction_numerical': 0.010830324909747292, 'mean_word_length': 2.7095046854083, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, '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': '6182807', 'n_tokens_mistral': 922, 'n_tokens_neox': 850, 'n_words': 213}