"use strict";!function(d,u){angular.module("widgetkit").run(["$rootScope","$rootElement","$timeout","$filter",function(t,e,o,n){u.parent.document.updateUploader=u.parent.document.updateUploader||function(){};var a=d("body.com_widgetkit"),i=a.find(".header .container-title").append('<h1 class="page-title"><span class="icon-widgetkit"></span>Widgetkit: <span></span></h1>').find(".page-title span").eq(1),s=a.find(".subhead .btn-toolbar"),c='<div class="btn-wrapper" id="toolbar-create"><button class="btn btn-small btn-success"></span>'+n("trans")("New")+"</button></div>",l='<div class="btn-wrapper" id="toolbar-apply"><button class="btn btn-small btn-success"><span class="icon-apply icon-white"></span> '+n("trans")("Save")+'</button></div>                           <div class="btn-wrapper" id="toolbar-save"><button class="btn btn-small"><span class="icon-save"></span> '+n("trans")("Save & Close")+'</button></div>                           <div class="btn-wrapper" id="toolbar-cancel"><button class="btn btn-small"><span class="icon-cancel"></span> '+n("trans")("Close")+"</button></div>",r='<div class="btn-wrapper" id="toolbar-options"><button class="btn btn-small"><span class="icon-options"></span> '+n("trans")("Options")+"</button></div>";function p(){s.find("#toolbar-apply button, #toolbar-save button").prop("disabled",e.find("form.ng-invalid").length)}s.on("click","#toolbar-create button",function(){e.scope().vm.createContent()}).on("click","#toolbar-apply",function(){e.scope().vm.saveContent()}).on("click","#toolbar-save",function(){var t=e.scope();t.vm.saveContent().$promise.then(function(){t.vm.setView("content")})}).on("click","#toolbar-cancel",function(){var t=e.scope();t.vm.setView("content"),t.$apply()}).on("click","#toolbar-options",function(){location.href="index.php?option=com_config&view=component&component=com_widgetkit"}),a.on("keyup",'[ng-model="content.name"]',p),t.$on("wk.change.view",function(t,n){o(function(){i.text(e.find("h2.js-header").text()),s.empty().html("content"===n?c:"contentEdit"===n?l:"").append(r),p()})})}]),d(function(){d(document).on("click",'[rel="widgetkit"], [aria-label="Widgetkit"]',function(t){t.preventDefault(),t.stopPropagation();for(var n=d(this);n.length&&!n.has("textarea").length;)n=n.parent();u.widgetkit.env.editor(n.find("textarea:first"))});var n=d(".view-module .widgetkit-widget, #modules-form .widgetkit-widget, #module-form .widgetkit-widget"),e=n.nextAll("input"),o={value:function(){try{return JSON.parse(e.val())}catch(t){return{}}},update:function(){var t=this.value().name;n.text(t?Translator.trans("Widget: %widget%",{widget:t}):Translator.trans("Select Widget"))}};n.on("click",function(t){t.preventDefault(),u.widgetkit.env.init("widget",o.value(),function(t){e.val(JSON.stringify(t)),o.update()})}),o.update()}),d(function(){if(u.MooTools){var t=Element.prototype.hide;Element.prototype.hide=function(){return d(this).is('[class*="uk-"]')?this:t.apply(this,[])}}})}(window.jQuery,window);