diff --git a/src/definitions/modules/modal.js b/src/definitions/modules/modal.js index 420ecc250b..d9f98fcd3e 100755 --- a/src/definitions/modules/modal.js +++ b/src/definitions/modules/modal.js @@ -58,6 +58,7 @@ $.fn.modal = function(parameters) { selector = settings.selector, className = settings.className, namespace = settings.namespace, + fields = settings.fields, error = settings.error, eventNamespace = '.' + namespace, @@ -74,7 +75,7 @@ $.fn.modal = function(parameters) { $dimmer, element = this, - instance = $module.data(moduleNamespace), + instance = $module.hasClass('modal') ? $module.data(moduleNamespace) : undefined, ignoreRepeatedEvents = false, @@ -91,6 +92,41 @@ $.fn.modal = function(parameters) { module = { initialize: function() { + if(!$module.hasClass('modal')) { + module.create.modal(); + if(!$.isFunction(settings.onHidden)) { + settings.onHidden = function () { + module.destroy(); + $module.remove(); + }; + } + } + $module.addClass(settings.class); + if (settings.title !== '') { + $module.find(selector.title).html(module.helpers.escape(settings.title, settings.preserveHTML)).addClass(settings.classTitle); + } + if (settings.content !== '') { + $module.find(selector.content).html(module.helpers.escape(settings.content, settings.preserveHTML)).addClass(settings.classContent); + } + if(module.has.configActions()){ + var $actions = $module.find(selector.actions).addClass(settings.classActions); + settings.actions.forEach(function (el) { + var icon = el[fields.icon] ? '' : '', + text = module.helpers.escape(el[fields.text] || '', settings.preserveHTML), + cls = module.helpers.deQuote(el[fields.class] || ''), + click = el[fields.click] && $.isFunction(el[fields.click]) ? el[fields.click] : function () {}; + $actions.append($('