/* Copyright (C) 2007 - 2011 YOOtheme GmbH, YOOtheme Proprietary Use License (http://www.yootheme.com/license) */

(function(c){var d=function(){};c.extend(d.prototype,{name:"AliasEdit",options:{edit:!1},initialize:function(a,d){this.options=c.extend({},this.options,d);var b=this;this.input=a;this.trigger=a.find("a.trigger");this.panel=a.find("div.panel");this.text=this.panel.find("input:text");this.name=a.find('input[name="name"]');this.options.edit||this.name.bind("blur.name",function(){var a=c.String.slugify(c(this).val());a!=""&&(b.text.val(a),b.trigger.text(a),c(this).unbind("blur.name"))});this.trigger.bind("click",
function(a){a.preventDefault();c(this).hide();b.panel.addClass("active");b.text.focus();b.text.bind("keydown",function(a){a.stopPropagation();a.which==13&&b.setAlias();a.which==27&&b.remove()});b.input.find("input.accept").bind("click",function(a){a.preventDefault();b.setAlias()});b.input.find("a.cancel").bind("click",function(a){a.preventDefault();b.remove()})})},setAlias:function(){var a=c.String.slugify(this.text.val());a==""&&(a=(a=c.String.slugify(this.name.val()))?a:"42");this.text.val(a);this.trigger.text(a);
this.remove()},remove:function(){this.trigger.show();this.panel.removeClass("active")}});c.fn[d.prototype.name]=function(){var a=arguments,e=a[0]?a[0]:null;return this.each(function(){var b=c(this);if(d.prototype[e]&&b.data(d.prototype.name)&&e!="initialize")b.data(d.prototype.name)[e].apply(b.data(d.prototype.name),Array.prototype.slice.call(a,1));else if(!e||c.isPlainObject(e)){var f=new d;d.prototype.initialize&&f.initialize.apply(f,c.merge([b],a));b.data(d.prototype.name,f)}else c.error("Method "+
e+" does not exist on jQuery."+d.name)})}})(jQuery);
