/**
* BlockHTML block resides inside a scene or timeline
* @class BlockHTML
* @extends Block
* @constructor
* @param {string} i_placement location where objects resides which can be scene or timeline
* @param {string} i_campaign_timeline_chanel_player_id required and set as block id when block is inserted onto timeline_channel
* @return {Object} Block instance
*/
define(['jquery', 'backbone', 'Block'], function ($, Backbone, Block) {
var BlockHTML = Block.extend({
/**
Constructor
@method initialize
**/
constructor: function (options) {
var self = this;
self.m_blockType = 3235;
_.extend(options, {blockType: self.m_blockType})
Block.prototype.constructor.call(this, options);
self._initSubPanel(Elements.BLOCK_HTML_COMMON_PROPERTIES);
self._listenInputChange();
},
/**
When user changes a URL link for the feed, update the msdb
@method _listenInputChange
@return none
**/
_listenInputChange: function () {
var self = this;
self.m_inputChangeHandler = _.debounce(function (e) {
if (!self.m_selected)
return;
var text = $(e.target).val();
if (!text.match('http://') && !text.match('https://'))
text = 'http://' + text;
if (BB.lib.isEmpty(text))
return;
var t2 = text;
text = BB.lib.cleanProbCharacters(text,1);
if (t2!=text)
bootbox.alert($(Elements.MSG_BOOTBOX_NON_ALLOWED_CHARACTERS).text());
var domPlayerData = self._getBlockPlayerData();
var xSnippet = $(domPlayerData).find('HTML');
xSnippet.attr('src', text);
self._setBlockPlayerData(domPlayerData, BB.CONSTS.NO_NOTIFICATION);
}, 150);
$(Elements.HTML_TEXT).on("input", self.m_inputChangeHandler);
},
/**
Load up property values in the common panel
@method _populate
@return none
**/
_populate: function () {
var self = this;
var domPlayerData = self._getBlockPlayerData();
var xSnippet = $(domPlayerData).find('HTML');
var src = xSnippet.attr('src');
$(Elements.HTML_TEXT).val(src);
},
/**
Populate the common block properties panel, called from base class if exists
@method _loadBlockSpecificProps
@return none
**/
_loadBlockSpecificProps: function () {
var self = this;
self._populate();
this._viewSubPanel(Elements.BLOCK_HTML_COMMON_PROPERTIES);
},
/**
Delete this block
@method deleteBlock
@params {Boolean} i_memoryOnly if true only remove from existance but not from msdb
**/
deleteBlock: function (i_memoryOnly) {
var self = this;
$(Elements.HTML_TEXT).off("input", self.m_inputChangeHandler);
self._deleteBlock(i_memoryOnly);
}
});
return BlockHTML;
});