/*globals define*/ /*jslint nomen: true*/ define('de_epages/shop/linkpicker/externalurlview', [ 'jquery', 'backbone', '$tmpl!de_epages/shop/linkpicker/externalurlview', '$dict!../dictionary' /** * External url view * @param {Function} $ jQuery * @param {Function} Backbone Backbone * @param {Function} template Template for rendering the external url view * @return {Backbone View} External url view */ ], function ($, Backbone, template, dict) { 'use strict'; return Backbone.View.extend({ /** * Tag used for $el * @type {String} */ tagName: 'div', /** * Rendered template with translations * @type {String} */ template: template({}).dictParse(dict, true), /** * Events the view listens to * @type {Object} */ events: { 'keyup input': '_publishLinkUrl', 'change input': '_publishLinkUrl', 'paste input': '_publishLinkUrl' }, /** * Appends the template to the specified dom node * @return {Backbone view} */ render: function () { this.$el.html(this.template); return this; }, /** * Clears the value of the external url input field */ clearLinkData: function () { $('#ep-linkpicker-externalUrl').val(''); }, /** * Sets the url in case it must be altered from the outside (CorrectUrl) * @param {String} _url [Url to be set] */ setUrl: function (_url) { $('#ep-linkpicker-externalUrl').val(_url); }, /** * Trigger the 'linkurlchanged' event and publish the link's url * @param {Event} _event [Event that was fired] * @private */ _publishLinkUrl: function (_event) { this.trigger('linkurlchanged', $(_event.target).val()); } }); });