/**
Attaches stand-alone container with editable-form to HTML element. Element is used only for positioning, value is not stored anywhere.
This method applied internally in $().editable(). You should subscribe on it's events (save / cancel) to get profit of it.
Final realization can be different: bootstrap-popover, jqueryui-tooltip, poshytip, inline-div. It depends on which js file you include.
Applied as jQuery method.
@class editableContainer
@uses editableform
**/
(function ($) {
var EditableContainer = function (element, options) {
this.init(element, options);
};
//methods
EditableContainer.prototype = {
containerName: null, //tbd in child class
innerCss: null, //tbd in child class
init: function(element, options) {
this.$element = $(element);
this.options = $.extend({}, $.fn.editableContainer.defaults, $.fn.editableform.utils.getConfigData(this.$element), options);
this.options.trigger = 'manual';
this.initContainer();
//bind 'destroyed' listener to destroy container when element is removed from dom
this.$element.on('destroyed', $.proxy(function(){
this.destroy();
}, this));
},
initContainer: function(){
this.call(this.options);
},
initForm: function() {
this.$form = $('
top|right|bottom|left. Not used for inline container.
@property placement
@type string
@default 'top'
**/
placement: 'top',
/**
Wether to hide container on save/cancel.
@property autohide
@type boolean
@default true
@private
**/
autohide: true
};
/*
* workaround to have 'destroyed' event to destroy popover when element is destroyed
* see http://stackoverflow.com/questions/2200494/jquery-trigger-event-when-an-element-is-removed-from-the-dom
*/
jQuery.event.special.destroyed = {
remove: function(o) {
if (o.handler) {
o.handler();
}
}
};
}(window.jQuery));