bootstrap-editable.min.js 51.1 KB
/*! X-editable - v1.5.1 
* In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
* http://github.com/vitalets/x-editable
* Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */
(function(b){var a=function(d,c){this.options=b.extend({},b.fn.editableform.defaults,c);this.$div=b(d);if(!this.options.scope){this.options.scope=this}};a.prototype={constructor:a,initInput:function(){this.input=this.options.input;this.value=this.input.str2value(this.options.value);this.input.prerender()},initTemplate:function(){this.$form=b(b.fn.editableform.template)},initButtons:function(){var c=this.$form.find(".editable-buttons");c.append(b.fn.editableform.buttons);if(this.options.showbuttons==="bottom"){c.addClass("editable-buttons-bottom")}},render:function(){this.$loading=b(b.fn.editableform.loading);this.$div.empty().append(this.$loading);this.initTemplate();if(this.options.showbuttons){this.initButtons()}else{this.$form.find(".editable-buttons").remove()}this.showLoading();this.isSaving=false;this.$div.triggerHandler("rendering");this.initInput();this.$form.find("div.editable-input").append(this.input.$tpl);this.$div.append(this.$form);b.when(this.input.render()).then(b.proxy(function(){if(!this.options.showbuttons){this.input.autosubmit()}this.$form.find(".editable-cancel").click(b.proxy(this.cancel,this));if(this.input.error){this.error(this.input.error);this.$form.find(".editable-submit").attr("disabled",true);this.input.$input.attr("disabled",true);this.$form.submit(function(d){d.preventDefault()})}else{this.error(false);this.input.$input.removeAttr("disabled");this.$form.find(".editable-submit").removeAttr("disabled");var c=(this.value===null||this.value===undefined||this.value==="")?this.options.defaultValue:this.value;this.input.value2input(c);this.$form.submit(b.proxy(this.submit,this))}this.$div.triggerHandler("rendered");this.showForm();if(this.input.postrender){this.input.postrender()}},this))},cancel:function(){this.$div.triggerHandler("cancel")},showLoading:function(){var c,d;if(this.$form){c=this.$form.outerWidth();d=this.$form.outerHeight();if(c){this.$loading.width(c)}if(d){this.$loading.height(d)}this.$form.hide()}else{c=this.$loading.parent().width();if(c){this.$loading.width(c)}}this.$loading.show()},showForm:function(c){this.$loading.hide();this.$form.show();if(c!==false){this.input.activate()}this.$div.triggerHandler("show")},error:function(g){var e=this.$form.find(".control-group"),f=this.$form.find(".editable-error-block"),c;if(g===false){e.removeClass(b.fn.editableform.errorGroupClass);f.removeClass(b.fn.editableform.errorBlockClass).empty().hide()}else{if(g){c=(""+g).split("\n");for(var d=0;d<c.length;d++){c[d]=b("<div>").text(c[d]).html()}g=c.join("<br>")}e.addClass(b.fn.editableform.errorGroupClass);f.addClass(b.fn.editableform.errorBlockClass).html(g).show()}},submit:function(g){g.stopPropagation();g.preventDefault();var f=this.input.input2value();var c=this.validate(f);if(b.type(c)==="object"&&c.newValue!==undefined){f=c.newValue;this.input.value2input(f);if(typeof c.msg==="string"){this.error(c.msg);this.showForm();return}}else{if(c){this.error(c);this.showForm();return}}if(!this.options.savenochange&&this.input.value2str(f)==this.input.value2str(this.value)){this.$div.triggerHandler("nochange");return}var d=this.input.value2submit(f);this.isSaving=true;b.when(this.save(d)).done(b.proxy(function(e){this.isSaving=false;var h=typeof this.options.success==="function"?this.options.success.call(this.options.scope,e,f):null;if(h===false){this.error(false);this.showForm(false);return}if(typeof h==="string"){this.error(h);this.showForm();return}if(h&&typeof h==="object"&&h.hasOwnProperty("newValue")){f=h.newValue}this.error(false);this.value=f;this.$div.triggerHandler("save",{newValue:f,submitValue:d,response:e})},this)).fail(b.proxy(function(h){this.isSaving=false;var e;if(typeof this.options.error==="function"){e=this.options.error.call(this.options.scope,h,f)}else{e=typeof h==="string"?h:h.responseText||h.statusText||"Unknown error!"}this.error(e);this.showForm()},this))},save:function(d){this.options.pk=b.fn.editableutils.tryParseJson(this.options.pk,true);var c=(typeof this.options.pk==="function")?this.options.pk.call(this.options.scope):this.options.pk,e=!!(typeof this.options.url==="function"||(this.options.url&&((this.options.send==="always")||(this.options.send==="auto"&&c!==null&&c!==undefined)))),f;if(e){this.showLoading();f={name:this.options.name||"",value:d,pk:c};if(typeof this.options.params==="function"){f=this.options.params.call(this.options.scope,f)}else{this.options.params=b.fn.editableutils.tryParseJson(this.options.params,true);b.extend(f,this.options.params)}if(typeof this.options.url==="function"){return this.options.url.call(this.options.scope,f)}else{return b.ajax(b.extend({url:this.options.url,data:f,type:"POST"},this.options.ajaxOptions))}}},validate:function(c){if(c===undefined){c=this.value}if(typeof this.options.validate==="function"){return this.options.validate.call(this.options.scope,c)}},option:function(c,d){if(c in this.options){this.options[c]=d}if(c==="value"){this.setValue(d)}},setValue:function(c,d){if(d){this.value=this.input.str2value(c)}else{this.value=c}if(this.$form&&this.$form.is(":visible")){this.input.value2input(this.value)}}};b.fn.editableform=function(d){var c=arguments;return this.each(function(){var g=b(this),f=g.data("editableform"),e=typeof d==="object"&&d;if(!f){g.data("editableform",(f=new a(this,e)))}if(typeof d==="string"){f[d].apply(f,Array.prototype.slice.call(c,1))}})};b.fn.editableform.Constructor=a;b.fn.editableform.defaults={type:"text",url:null,params:null,name:null,pk:null,value:null,defaultValue:null,send:"auto",validate:null,success:null,error:null,ajaxOptions:null,showbuttons:true,scope:null,savenochange:false};b.fn.editableform.template='<form class="form-inline editableform"><div class="control-group"><div><div class="editable-input"></div><div class="editable-buttons"></div></div><div class="editable-error-block"></div></div></form>';b.fn.editableform.loading='<div class="editableform-loading"></div>';b.fn.editableform.buttons='<button type="submit" class="editable-submit">ok</button><button type="button" class="editable-cancel">cancel</button>';b.fn.editableform.errorGroupClass=null;b.fn.editableform.errorBlockClass="editable-error";b.fn.editableform.engine="jquery"}(window.jQuery));(function(a){a.fn.editableutils={inherit:function(c,b){var d=function(){};d.prototype=b.prototype;c.prototype=new d();c.prototype.constructor=c;c.superclass=b.prototype},setCursorPosition:function(c,d){if(c.setSelectionRange){c.setSelectionRange(d,d)}else{if(c.createTextRange){var b=c.createTextRange();b.collapse(true);b.moveEnd("character",d);b.moveStart("character",d);b.select()}}},tryParseJson:function(b,c){if(typeof b==="string"&&b.length&&b.match(/^[\{\[].*[\}\]]$/)){if(c){try{b=(new Function("return "+b))()}catch(d){}finally{return b}}else{b=(new Function("return "+b))()}}return b},sliceObj:function(h,g,b){var f,e,c={};if(!a.isArray(g)||!g.length){return c}for(var d=0;d<g.length;d++){f=g[d];if(h.hasOwnProperty(f)){c[f]=h[f]}if(b===true){continue}e=f.toLowerCase();if(h.hasOwnProperty(e)){c[f]=h[e]}}return c},getConfigData:function(b){var c={};a.each(b.data(),function(e,d){if(typeof d!=="object"||(d&&typeof d==="object"&&(d.constructor===Object||d.constructor===Array))){c[e]=d}});return c},objectKeys:function(d){if(Object.keys){return Object.keys(d)}else{if(d!==Object(d)){throw new TypeError("Object.keys called on a non-object")}var b=[],c;for(c in d){if(Object.prototype.hasOwnProperty.call(d,c)){b.push(c)}}return b}},escape:function(b){return a("<div>").text(b).html()},itemsByValue:function(h,g,e){if(!g||h===null){return[]}if(typeof(e)!=="function"){var c=e||"value";e=function(i){return i[c]}}var d=a.isArray(h),b=[],f=this;a.each(g,function(j,l){if(l.children){b=b.concat(f.itemsByValue(h,l.children,e))}else{if(d){if(a.grep(h,function(i){return i==(l&&typeof l==="object"?e(l):l)}).length){b.push(l)}}else{var k=(l&&(typeof l==="object"))?e(l):l;if(h==k){b.push(l)}}}});return b},createInput:function(c){var e,f,b,d=c.type;if(d==="date"){if(c.mode==="inline"){if(a.fn.editabletypes.datefield){d="datefield"}else{if(a.fn.editabletypes.dateuifield){d="dateuifield"}}}else{if(a.fn.editabletypes.date){d="date"}else{if(a.fn.editabletypes.dateui){d="dateui"}}}if(d==="date"&&!a.fn.editabletypes.date){d="combodate"}}if(d==="datetime"&&c.mode==="inline"){d="datetimefield"}if(d==="wysihtml5"&&!a.fn.editabletypes[d]){d="textarea"}if(typeof a.fn.editabletypes[d]==="function"){e=a.fn.editabletypes[d];f=this.sliceObj(c,this.objectKeys(e.defaults));b=new e(f);return b}else{a.error("Unknown type: "+d);return false}},supportsTransitions:function(){var c=document.body||document.documentElement,f=c.style,g="transition",d=["Moz","Webkit","Khtml","O","ms"];if(typeof f[g]==="string"){return true}g=g.charAt(0).toUpperCase()+g.substr(1);for(var e=0;e<d.length;e++){if(typeof f[d[e]+g]==="string"){return true}}return false}}}(window.jQuery));(function(c){var b=function(e,d){this.init(e,d)};var a=function(e,d){this.init(e,d)};b.prototype={containerName:null,containerDataName:null,innerCss:null,containerClass:"editable-container editable-popup",defaults:{},init:function(e,d){this.$element=c(e);this.options=c.extend({},c.fn.editableContainer.defaults,d);this.splitOptions();this.formOptions.scope=this.$element[0];this.initContainer();this.delayedHide=false;this.$element.on("destroyed",c.proxy(function(){this.destroy()},this));if(!c(document).data("editable-handlers-attached")){c(document).on("keyup.editable",function(f){if(f.which===27){c(".editable-open").editableContainer("hide")}});c(document).on("click.editable",function(j){var f=c(j.target),g,h=[".editable-container",".ui-datepicker-header",".datepicker",".modal-backdrop",".bootstrap-wysihtml5-insert-image-modal",".bootstrap-wysihtml5-insert-link-modal"];if(c(".select2-drop-mask").is(":visible")){return}if(!c.contains(document.documentElement,j.target)){return}if(f.is(document)){return}for(g=0;g<h.length;g++){if(f.is(h[g])||f.parents(h[g]).length){return}}b.prototype.closeOthers(j.target)});c(document).data("editable-handlers-attached",true)}},splitOptions:function(){this.containerOptions={};this.formOptions={};if(!c.fn[this.containerName]){throw new Error(this.containerName+" not found. Have you included corresponding js file?")}for(var d in this.options){if(d in this.defaults){this.containerOptions[d]=this.options[d]}else{this.formOptions[d]=this.options[d]}}},tip:function(){return this.container()?this.container().$tip:null},container:function(){var d;if(this.containerDataName){if(d=this.$element.data(this.containerDataName)){return d}}d=this.$element.data(this.containerName);return d},call:function(){this.$element[this.containerName].apply(this.$element,arguments)},initContainer:function(){this.call(this.containerOptions)},renderForm:function(){this.$form.editableform(this.formOptions).on({save:c.proxy(this.save,this),nochange:c.proxy(function(){this.hide("nochange")},this),cancel:c.proxy(function(){this.hide("cancel")},this),show:c.proxy(function(){if(this.delayedHide){this.hide(this.delayedHide.reason);this.delayedHide=false}else{this.setPosition()}},this),rendering:c.proxy(this.setPosition,this),resize:c.proxy(this.setPosition,this),rendered:c.proxy(function(){this.$element.triggerHandler("shown",c(this.options.scope).data("editable"))},this)}).editableform("render")},show:function(d){this.$element.addClass("editable-open");if(d!==false){this.closeOthers(this.$element[0])}this.innerShow();this.tip().addClass(this.containerClass);if(this.$form){}this.$form=c("<div>");if(this.tip().is(this.innerCss)){this.tip().append(this.$form)}else{this.tip().find(this.innerCss).append(this.$form)}this.renderForm()},hide:function(d){if(!this.tip()||!this.tip().is(":visible")||!this.$element.hasClass("editable-open")){return}if(this.$form.data("editableform").isSaving){this.delayedHide={reason:d};return}else{this.delayedHide=false}this.$element.removeClass("editable-open");this.innerHide();this.$element.triggerHandler("hidden",d||"manual")},innerShow:function(){},innerHide:function(){},toggle:function(d){if(this.container()&&this.tip()&&this.tip().is(":visible")){this.hide()}else{this.show(d)}},setPosition:function(){},save:function(d,f){this.$element.triggerHandler("save",f);this.hide("save")},option:function(d,e){this.options[d]=e;if(d in this.containerOptions){this.containerOptions[d]=e;this.setContainerOption(d,e)}else{this.formOptions[d]=e;if(this.$form){this.$form.editableform("option",d,e)}}},setContainerOption:function(d,e){this.call("option",d,e)},destroy:function(){this.hide();this.innerDestroy();this.$element.off("destroyed");this.$element.removeData("editableContainer")},innerDestroy:function(){},closeOthers:function(d){c(".editable-open").each(function(g,h){if(h===d||c(h).find(d).length){return}var f=c(h),e=f.data("editableContainer");if(!e){return}if(e.options.onblur==="cancel"){f.data("editableContainer").hide("onblur")}else{if(e.options.onblur==="submit"){f.data("editableContainer").tip().find("form").submit()}}})},activate:function(){if(this.tip&&this.tip().is(":visible")&&this.$form){this.$form.data("editableform").input.activate()}}};c.fn.editableContainer=function(e){var d=arguments;return this.each(function(){var h=c(this),j="editableContainer",g=h.data(j),f=typeof e==="object"&&e,i=(f.mode==="inline")?a:b;if(!g){h.data(j,(g=new i(this,f)))}if(typeof e==="string"){g[e].apply(g,Array.prototype.slice.call(d,1))}})};c.fn.editableContainer.Popup=b;c.fn.editableContainer.Inline=a;c.fn.editableContainer.defaults={value:null,placement:"top",autohide:true,onblur:"cancel",anim:false,mode:"popup"};jQuery.event.special.destroyed={remove:function(d){if(d.handler){d.handler()}}}}(window.jQuery));(function(a){a.extend(a.fn.editableContainer.Inline.prototype,a.fn.editableContainer.Popup.prototype,{containerName:"editableform",innerCss:".editable-inline",containerClass:"editable-container editable-inline",initContainer:function(){this.$tip=a("<span></span>");if(!this.options.anim){this.options.anim=0}},splitOptions:function(){this.containerOptions={};this.formOptions=this.options},tip:function(){return this.$tip},innerShow:function(){this.$element.hide();this.tip().insertAfter(this.$element).show()},innerHide:function(){this.$tip.hide(this.options.anim,a.proxy(function(){this.$element.show();this.innerDestroy()},this))},innerDestroy:function(){if(this.tip()){this.tip().empty().remove()}}})}(window.jQuery));(function(b){var a=function(d,c){this.$element=b(d);this.options=b.extend({},b.fn.editable.defaults,c,b.fn.editableutils.getConfigData(this.$element));if(this.options.selector){this.initLive()}else{this.init()}if(this.options.highlight&&!b.fn.editableutils.supportsTransitions()){this.options.highlight=false}};a.prototype={constructor:a,init:function(){var c=false,d,e;this.options.name=this.options.name||this.$element.attr("id");this.options.scope=this.$element[0];this.input=b.fn.editableutils.createInput(this.options);if(!this.input){return}if(this.options.value===undefined||this.options.value===null){this.value=this.input.html2value(b.trim(this.$element.html()));c=true}else{this.options.value=b.fn.editableutils.tryParseJson(this.options.value,true);if(typeof this.options.value==="string"){this.value=this.input.str2value(this.options.value)}else{this.value=this.options.value}}this.$element.addClass("editable");if(this.input.type==="textarea"){this.$element.addClass("editable-pre-wrapped")}if(this.options.toggle!=="manual"){this.$element.addClass("editable-click");this.$element.on(this.options.toggle+".editable",b.proxy(function(g){if(!this.options.disabled){g.preventDefault()}if(this.options.toggle==="mouseenter"){this.show()}else{var f=(this.options.toggle!=="click");this.toggle(f)}},this))}else{this.$element.attr("tabindex",-1)}if(typeof this.options.display==="function"){this.options.autotext="always"}switch(this.options.autotext){case"always":d=true;break;case"auto":d=!b.trim(this.$element.text()).length&&this.value!==null&&this.value!==undefined&&!c;break;default:d=false}b.when(d?this.render():true).then(b.proxy(function(){if(this.options.disabled){this.disable()}else{this.enable()}this.$element.triggerHandler("init",this)},this))},initLive:function(){var c=this.options.selector;this.options.selector=false;this.options.autotext="never";this.$element.on(this.options.toggle+".editable",c,b.proxy(function(f){var d=b(f.target);if(!d.data("editable")){if(d.hasClass(this.options.emptyclass)){d.empty()}d.editable(this.options).trigger(f)}},this))},render:function(c){if(this.options.display===false){return}if(this.input.value2htmlFinal){return this.input.value2html(this.value,this.$element[0],this.options.display,c)}else{if(typeof this.options.display==="function"){return this.options.display.call(this.$element[0],this.value,c)}else{return this.input.value2html(this.value,this.$element[0])}}},enable:function(){this.options.disabled=false;this.$element.removeClass("editable-disabled");this.handleEmpty(this.isEmpty);if(this.options.toggle!=="manual"){if(this.$element.attr("tabindex")==="-1"){this.$element.removeAttr("tabindex")}}},disable:function(){this.options.disabled=true;this.hide();this.$element.addClass("editable-disabled");this.handleEmpty(this.isEmpty);this.$element.attr("tabindex",-1)},toggleDisabled:function(){if(this.options.disabled){this.enable()}else{this.disable()}},option:function(c,d){if(c&&typeof c==="object"){b.each(c,b.proxy(function(f,e){this.option(b.trim(f),e)},this));return}this.options[c]=d;if(c==="disabled"){return d?this.disable():this.enable()}if(c==="value"){this.setValue(d)}if(this.container){this.container.option(c,d)}if(this.input.option){this.input.option(c,d)}},handleEmpty:function(c){if(this.options.display===false){return}if(c!==undefined){this.isEmpty=c}else{if(typeof(this.input.isEmpty)==="function"){this.isEmpty=this.input.isEmpty(this.$element)}else{this.isEmpty=b.trim(this.$element.html())===""}}if(!this.options.disabled){if(this.isEmpty){this.$element.html(this.options.emptytext);if(this.options.emptyclass){this.$element.addClass(this.options.emptyclass)}}else{if(this.options.emptyclass){this.$element.removeClass(this.options.emptyclass)}}}else{if(this.isEmpty){this.$element.empty();if(this.options.emptyclass){this.$element.removeClass(this.options.emptyclass)}}}},show:function(c){if(this.options.disabled){return}if(!this.container){var d=b.extend({},this.options,{value:this.value,input:this.input});this.$element.editableContainer(d);this.$element.on("save.internal",b.proxy(this.save,this));this.container=this.$element.data("editableContainer")}else{if(this.container.tip().is(":visible")){return}}this.container.show(c)},hide:function(){if(this.container){this.container.hide()}},toggle:function(c){if(this.container&&this.container.tip().is(":visible")){this.hide()}else{this.show(c)}},save:function(g,h){if(this.options.unsavedclass){var d=false;d=d||typeof this.options.url==="function";d=d||this.options.display===false;d=d||h.response!==undefined;d=d||(this.options.savenochange&&this.input.value2str(this.value)!==this.input.value2str(h.newValue));if(d){this.$element.removeClass(this.options.unsavedclass)}else{this.$element.addClass(this.options.unsavedclass)}}if(this.options.highlight){var c=this.$element,f=c.css("background-color");c.css("background-color",this.options.highlight);setTimeout(function(){if(f==="transparent"){f=""}c.css("background-color",f);c.addClass("editable-bg-transition");setTimeout(function(){c.removeClass("editable-bg-transition")},1700)},10)}this.setValue(h.newValue,false,h.response)},validate:function(){if(typeof this.options.validate==="function"){return this.options.validate.call(this,this.value)}},setValue:function(d,e,c){if(e){this.value=this.input.str2value(d)}else{this.value=d}if(this.container){this.container.option("value",this.value)}b.when(this.render(c)).then(b.proxy(function(){this.handleEmpty()},this))},activate:function(){if(this.container){this.container.activate()}},destroy:function(){this.disable();if(this.container){this.container.destroy()}this.input.destroy();if(this.options.toggle!=="manual"){this.$element.removeClass("editable-click");this.$element.off(this.options.toggle+".editable")}this.$element.off("save.internal");this.$element.removeClass("editable editable-open editable-disabled");this.$element.removeData("editable")}};b.fn.editable=function(i){var m={},j=arguments,h="editable";switch(i){case"validate":this.each(function(){var p=b(this),o=p.data(h),n;if(o&&(n=o.validate())){m[o.options.name]=n}});return m;case"getValue":if(arguments.length===2&&arguments[1]===true){m=this.eq(0).data(h).value}else{this.each(function(){var o=b(this),n=o.data(h);if(n&&n.value!==undefined&&n.value!==null){m[n.options.name]=n.input.value2submit(n.value)}})}return m;case"submit":var e=arguments[1]||{},c=this,k=this.editable("validate");if(b.isEmptyObject(k)){var f={};if(c.length===1){var d=c.data("editable");var g={name:d.options.name||"",value:d.input.value2submit(d.value),pk:(typeof d.options.pk==="function")?d.options.pk.call(d.options.scope):d.options.pk};if(typeof d.options.params==="function"){g=d.options.params.call(d.options.scope,g)}else{d.options.params=b.fn.editableutils.tryParseJson(d.options.params,true);b.extend(g,d.options.params)}f={url:d.options.url,data:g,type:"POST"};e.success=e.success||d.options.success;e.error=e.error||d.options.error}else{var l=this.editable("getValue");f={url:e.url,data:l,type:"POST"}}f.success=typeof e.success==="function"?function(n){e.success.call(c,n,e)}:b.noop;f.error=typeof e.error==="function"?function(){e.error.apply(c,arguments)}:b.noop;if(e.ajaxOptions){b.extend(f,e.ajaxOptions)}if(e.data){b.extend(f.data,e.data)}b.ajax(f)}else{if(typeof e.error==="function"){e.error.call(c,k)}}return this}return this.each(function(){var p=b(this),o=p.data(h),n=typeof i==="object"&&i;if(n&&n.selector){o=new a(this,n);return}if(!o){p.data(h,(o=new a(this,n)))}if(typeof i==="string"){o[i].apply(o,Array.prototype.slice.call(j,1))}})};b.fn.editable.defaults={type:"text",disabled:false,toggle:"click",emptytext:"Empty",autotext:"auto",value:null,display:null,emptyclass:"editable-empty",unsavedclass:"editable-unsaved",selector:null,highlight:"#FFFF80"}}(window.jQuery));(function(b){b.fn.editabletypes={};var a=function(){};a.prototype={init:function(d,c,e){this.type=d;this.options=b.extend({},e,c)},prerender:function(){this.$tpl=b(this.options.tpl);this.$input=this.$tpl;this.$clear=null;this.error=null},render:function(){},value2html:function(d,c){b(c)[this.options.escape?"text":"html"](b.trim(d))},html2value:function(c){return b("<div>").html(c).text()},value2str:function(c){return c},str2value:function(c){return c},value2submit:function(c){return c},value2input:function(c){this.$input.val(c)},input2value:function(){return this.$input.val()},activate:function(){if(this.$input.is(":visible")){this.$input.focus()}},clear:function(){this.$input.val(null)},escape:function(c){return b("<div>").text(c).html()},autosubmit:function(){},destroy:function(){},setClass:function(){if(this.options.inputclass){this.$input.addClass(this.options.inputclass)}},setAttr:function(c){if(this.options[c]!==undefined&&this.options[c]!==null){this.$input.attr(c,this.options[c])}},option:function(c,d){this.options[c]=d}};a.defaults={tpl:"",inputclass:null,escape:true,scope:null,showbuttons:true};b.extend(b.fn.editabletypes,{abstractinput:a})}(window.jQuery));(function(b){var a=function(c){};b.fn.editableutils.inherit(a,b.fn.editabletypes.abstractinput);b.extend(a.prototype,{render:function(){var c=b.Deferred();this.error=null;this.onSourceReady(function(){this.renderList();c.resolve()},function(){this.error=this.options.sourceError;c.resolve()});return c.promise()},html2value:function(c){return null},value2html:function(f,e,g,d){var c=b.Deferred(),h=function(){if(typeof g==="function"){g.call(e,f,this.sourceData,d)}else{this.value2htmlFinal(f,e)}c.resolve()};if(f===null){h.call(this)}else{this.onSourceReady(h,function(){c.resolve()})}return c.promise()},onSourceReady:function(j,f){var g;if(b.isFunction(this.options.source)){g=this.options.source.call(this.options.scope);this.sourceData=null}else{g=this.options.source}if(this.options.sourceCache&&b.isArray(this.sourceData)){j.call(this);return}try{g=b.fn.editableutils.tryParseJson(g,false)}catch(i){f.call(this);return}if(typeof g==="string"){if(this.options.sourceCache){var h=g,d;if(!b(document).data(h)){b(document).data(h,{})}d=b(document).data(h);if(d.loading===false&&d.sourceData){this.sourceData=d.sourceData;this.doPrepend();j.call(this);return}else{if(d.loading===true){d.callbacks.push(b.proxy(function(){this.sourceData=d.sourceData;this.doPrepend();j.call(this)},this));d.err_callbacks.push(b.proxy(f,this));return}else{d.loading=true;d.callbacks=[];d.err_callbacks=[]}}}var c=b.extend({url:g,type:"get",cache:false,dataType:"json",success:b.proxy(function(e){if(d){d.loading=false}this.sourceData=this.makeArray(e);if(b.isArray(this.sourceData)){if(d){d.sourceData=this.sourceData;b.each(d.callbacks,function(){this.call()})}this.doPrepend();j.call(this)}else{f.call(this);if(d){b.each(d.err_callbacks,function(){this.call()})}}},this),error:b.proxy(function(){f.call(this);if(d){d.loading=false;b.each(d.err_callbacks,function(){this.call()})}},this)},this.options.sourceOptions);b.ajax(c)}else{this.sourceData=this.makeArray(g);if(b.isArray(this.sourceData)){this.doPrepend();j.call(this)}else{f.call(this)}}},doPrepend:function(){if(this.options.prepend===null||this.options.prepend===undefined){return}if(!b.isArray(this.prependData)){if(b.isFunction(this.options.prepend)){this.options.prepend=this.options.prepend.call(this.options.scope)}this.options.prepend=b.fn.editableutils.tryParseJson(this.options.prepend,true);if(typeof this.options.prepend==="string"){this.options.prepend={"":this.options.prepend}}this.prependData=this.makeArray(this.options.prepend)}if(b.isArray(this.prependData)&&b.isArray(this.sourceData)){this.sourceData=this.prependData.concat(this.sourceData)}},renderList:function(){},value2htmlFinal:function(d,c){},makeArray:function(h){var g,j,c=[],f,d;if(!h||typeof h==="string"){return null}if(b.isArray(h)){d=function(l,i){j={value:l,text:i};if(g++>=2){return false}};for(var e=0;e<h.length;e++){f=h[e];if(typeof f==="object"){g=0;b.each(f,d);if(g===1){c.push(j)}else{if(g>1){if(f.children){f.children=this.makeArray(f.children)}c.push(f)}}}else{c.push({value:f,text:f})}}}else{b.each(h,function(l,i){c.push({value:l,text:i})})}return c},option:function(c,d){this.options[c]=d;if(c==="source"){this.sourceData=null}if(c==="prepend"){this.prependData=null}}});a.defaults=b.extend({},b.fn.editabletypes.abstractinput.defaults,{source:null,prepend:false,sourceError:"Error when loading list",sourceCache:true,sourceOptions:null});b.fn.editabletypes.list=a}(window.jQuery));(function(b){var a=function(c){this.init("text",c,a.defaults)};b.fn.editableutils.inherit(a,b.fn.editabletypes.abstractinput);b.extend(a.prototype,{render:function(){this.renderClear();this.setClass();this.setAttr("placeholder")},activate:function(){if(this.$input.is(":visible")){this.$input.focus();b.fn.editableutils.setCursorPosition(this.$input.get(0),this.$input.val().length);if(this.toggleClear){this.toggleClear()}}},renderClear:function(){if(this.options.clear){this.$clear=b('<span class="editable-clear-x"></span>');this.$input.after(this.$clear).css("padding-right",24).keyup(b.proxy(function(d){if(~b.inArray(d.keyCode,[40,38,9,13,27])){return}clearTimeout(this.t);var c=this;this.t=setTimeout(function(){c.toggleClear(d)},100)},this)).parent().css("position","relative");this.$clear.click(b.proxy(this.clear,this))}},postrender:function(){},toggleClear:function(d){if(!this.$clear){return}var c=this.$input.val().length,f=this.$clear.is(":visible");if(c&&!f){this.$clear.show()}if(!c&&f){this.$clear.hide()}},clear:function(){this.$clear.hide();this.$input.val("").focus()}});a.defaults=b.extend({},b.fn.editabletypes.abstractinput.defaults,{tpl:'<input type="text">',placeholder:null,clear:true});b.fn.editabletypes.text=a}(window.jQuery));(function(b){var a=function(c){this.init("textarea",c,a.defaults)};b.fn.editableutils.inherit(a,b.fn.editabletypes.abstractinput);b.extend(a.prototype,{render:function(){this.setClass();this.setAttr("placeholder");this.setAttr("rows");this.$input.keydown(function(c){if(c.ctrlKey&&c.which===13){b(this).closest("form").submit()}})},activate:function(){b.fn.editabletypes.text.prototype.activate.call(this)}});a.defaults=b.extend({},b.fn.editabletypes.abstractinput.defaults,{tpl:"<textarea></textarea>",inputclass:"input-large",placeholder:null,rows:7});b.fn.editabletypes.textarea=a}(window.jQuery));(function(a){var b=function(c){this.init("select",c,b.defaults)};a.fn.editableutils.inherit(b,a.fn.editabletypes.list);a.extend(b.prototype,{renderList:function(){this.$input.empty();var c=function(f,g){var d;if(a.isArray(g)){for(var e=0;e<g.length;e++){d={};if(g[e].children){d.label=g[e].text;f.append(c(a("<optgroup>",d),g[e].children))}else{d.value=g[e].value;if(g[e].disabled){d.disabled=true}f.append(a("<option>",d).text(g[e].text))}}}return f};c(this.$input,this.sourceData);this.setClass();this.$input.on("keydown.editable",function(d){if(d.which===13){a(this).closest("form").submit()}})},value2htmlFinal:function(e,d){var f="",c=a.fn.editableutils.itemsByValue(e,this.sourceData);if(c.length){f=c[0].text}a.fn.editabletypes.abstractinput.prototype.value2html.call(this,f,d)},autosubmit:function(){this.$input.off("keydown.editable").on("change.editable",function(){a(this).closest("form").submit()})}});b.defaults=a.extend({},a.fn.editabletypes.list.defaults,{tpl:"<select></select>"});a.fn.editabletypes.select=b}(window.jQuery));(function(b){var a=function(c){this.init("checklist",c,a.defaults)};b.fn.editableutils.inherit(a,b.fn.editabletypes.list);b.extend(a.prototype,{renderList:function(){var c,d;this.$tpl.empty();if(!b.isArray(this.sourceData)){return}for(var e=0;e<this.sourceData.length;e++){c=b("<label>").append(b("<input>",{type:"checkbox",value:this.sourceData[e].value})).append(b("<span>").text(" "+this.sourceData[e].text));b("<div>").append(c).appendTo(this.$tpl)}this.$input=this.$tpl.find('input[type="checkbox"]');this.setClass()},value2str:function(c){return b.isArray(c)?c.sort().join(b.trim(this.options.separator)):""},str2value:function(e){var c,d=null;if(typeof e==="string"&&e.length){c=new RegExp("\\s*"+b.trim(this.options.separator)+"\\s*");d=e.split(c)}else{if(b.isArray(e)){d=e}else{d=[e]}}return d},value2input:function(c){this.$input.prop("checked",false);if(b.isArray(c)&&c.length){this.$input.each(function(e,f){var d=b(f);b.each(c,function(g,h){if(d.val()==h){d.prop("checked",true)}})})}},input2value:function(){var c=[];this.$input.filter(":checked").each(function(d,e){c.push(b(e).val())});return c},value2htmlFinal:function(g,d){var c=[],f=b.fn.editableutils.itemsByValue(g,this.sourceData),e=this.options.escape;if(f.length){b.each(f,function(j,h){var k=e?b.fn.editableutils.escape(h.text):h.text;c.push(k)});b(d).html(c.join("<br>"))}else{b(d).empty()}},activate:function(){this.$input.first().focus()},autosubmit:function(){this.$input.on("keydown",function(c){if(c.which===13){b(this).closest("form").submit()}})}});a.defaults=b.extend({},b.fn.editabletypes.list.defaults,{tpl:'<div class="editable-checklist"></div>',inputclass:null,separator:","});b.fn.editabletypes.checklist=a}(window.jQuery));(function(b){var a=function(c){this.init("password",c,a.defaults)};b.fn.editableutils.inherit(a,b.fn.editabletypes.text);b.extend(a.prototype,{value2html:function(d,c){if(d){b(c).text("[hidden]")}else{b(c).empty()}},html2value:function(c){return null}});a.defaults=b.extend({},b.fn.editabletypes.text.defaults,{tpl:'<input type="password">'});b.fn.editabletypes.password=a}(window.jQuery));(function(a){var b=function(c){this.init("email",c,b.defaults)};a.fn.editableutils.inherit(b,a.fn.editabletypes.text);b.defaults=a.extend({},a.fn.editabletypes.text.defaults,{tpl:'<input type="email">'});a.fn.editabletypes.email=b}(window.jQuery));(function(a){var b=function(c){this.init("url",c,b.defaults)};a.fn.editableutils.inherit(b,a.fn.editabletypes.text);b.defaults=a.extend({},a.fn.editabletypes.text.defaults,{tpl:'<input type="url">'});a.fn.editabletypes.url=b}(window.jQuery));(function(a){var b=function(c){this.init("tel",c,b.defaults)};a.fn.editableutils.inherit(b,a.fn.editabletypes.text);b.defaults=a.extend({},a.fn.editabletypes.text.defaults,{tpl:'<input type="tel">'});a.fn.editabletypes.tel=b}(window.jQuery));(function(a){var b=function(c){this.init("number",c,b.defaults)};a.fn.editableutils.inherit(b,a.fn.editabletypes.text);a.extend(b.prototype,{render:function(){b.superclass.render.call(this);this.setAttr("min");this.setAttr("max");this.setAttr("step")},postrender:function(){if(this.$clear){this.$clear.css({right:24})}}});b.defaults=a.extend({},a.fn.editabletypes.text.defaults,{tpl:'<input type="number">',inputclass:"input-mini",min:null,max:null,step:null});a.fn.editabletypes.number=b}(window.jQuery));(function(a){var b=function(c){this.init("range",c,b.defaults)};a.fn.editableutils.inherit(b,a.fn.editabletypes.number);a.extend(b.prototype,{render:function(){this.$input=this.$tpl.filter("input");this.setClass();this.setAttr("min");this.setAttr("max");this.setAttr("step");this.$input.on("input",function(){a(this).siblings("output").text(a(this).val())})},activate:function(){this.$input.focus()}});b.defaults=a.extend({},a.fn.editabletypes.number.defaults,{tpl:'<input type="range"><output style="width: 30px; display: inline-block"></output>',inputclass:"input-medium"});a.fn.editabletypes.range=b}(window.jQuery));(function(b){var a=function(c){this.init("time",c,a.defaults)};b.fn.editableutils.inherit(a,b.fn.editabletypes.abstractinput);b.extend(a.prototype,{render:function(){this.setClass()}});a.defaults=b.extend({},b.fn.editabletypes.abstractinput.defaults,{tpl:'<input type="time">'});b.fn.editabletypes.time=a}(window.jQuery));(function(a){var b=function(d){this.init("select2",d,b.defaults);d.select2=d.select2||{};this.sourceData=null;if(d.placeholder){d.select2.placeholder=d.placeholder}if(!d.select2.tags&&d.source){var e=d.source;if(a.isFunction(d.source)){e=d.source.call(d.scope)}if(typeof e==="string"){d.select2.ajax=d.select2.ajax||{};if(!d.select2.ajax.data){d.select2.ajax.data=function(f){return{query:f}}}if(!d.select2.ajax.results){d.select2.ajax.results=function(f){return{results:f}}}d.select2.ajax.url=e}else{this.sourceData=this.convertSource(e);d.select2.data=this.sourceData}}this.options.select2=a.extend({},b.defaults.select2,d.select2);this.isMultiple=this.options.select2.tags||this.options.select2.multiple;this.isRemote=("ajax" in this.options.select2);this.idFunc=this.options.select2.id;if(typeof(this.idFunc)!=="function"){var c=this.idFunc||"id";this.idFunc=function(f){return f[c]}}this.formatSelection=this.options.select2.formatSelection;if(typeof(this.formatSelection)!=="function"){this.formatSelection=function(f){return f.text}}};a.fn.editableutils.inherit(b,a.fn.editabletypes.abstractinput);a.extend(b.prototype,{render:function(){this.setClass();if(this.isRemote){this.$input.on("select2-loaded",a.proxy(function(c){this.sourceData=c.items.results},this))}if(this.isMultiple){this.$input.on("change",function(){a(this).closest("form").parent().triggerHandler("resize")})}},value2html:function(f,c){var g="",e,d=this;if(this.options.select2.tags){e=f}else{if(this.sourceData){e=a.fn.editableutils.itemsByValue(f,this.sourceData,this.idFunc)}else{}}if(a.isArray(e)){g=[];a.each(e,function(i,h){g.push(h&&typeof h==="object"?d.formatSelection(h):h)})}else{if(e){g=d.formatSelection(e)}}g=a.isArray(g)?g.join(this.options.viewseparator):g;b.superclass.value2html.call(this,g,c)},html2value:function(c){return this.options.select2.tags?this.str2value(c,this.options.viewseparator):null},value2input:function(f){if(a.isArray(f)){f=f.join(this.getSeparator())}if(!this.$input.data("select2")){this.$input.val(f);this.$input.select2(this.options.select2)}else{this.$input.val(f).trigger("change",true)}if(this.isRemote&&!this.isMultiple&&!this.options.select2.initSelection){var g=this.options.select2.id,c=this.options.select2.formatSelection;if(!g&&!c){var d=a(this.options.scope);if(!d.data("editable").isEmpty){var e={id:f,text:d.text()};this.$input.select2("data",e)}}}},input2value:function(){return this.$input.select2("val")},str2value:function(g,e){if(typeof g!=="string"||!this.isMultiple){return g}e=e||this.getSeparator();var f,d,c;if(g===null||g.length<1){return null}f=g.split(e);for(d=0,c=f.length;d<c;d=d+1){f[d]=a.trim(f[d])}return f},autosubmit:function(){this.$input.on("change",function(d,c){if(!c){a(this).closest("form").submit()}})},getSeparator:function(){return this.options.select2.separator||a.fn.select2.defaults.separator},convertSource:function(d){if(a.isArray(d)&&d.length&&d[0].value!==undefined){for(var c=0;c<d.length;c++){if(d[c].value!==undefined){d[c].id=d[c].value;delete d[c].value}}}return d},destroy:function(){if(this.$input.data("select2")){this.$input.select2("destroy")}}});b.defaults=a.extend({},a.fn.editabletypes.abstractinput.defaults,{tpl:'<input type="hidden">',select2:null,placeholder:null,source:null,viewseparator:", "});a.fn.editabletypes.select2=b}(window.jQuery));(function(b){var a=function(d,c){this.$element=b(d);if(!this.$element.is("input")){b.error("Combodate should be applied to INPUT element");return}this.options=b.extend({},b.fn.combodate.defaults,c,this.$element.data());this.init()};a.prototype={constructor:a,init:function(){this.map={day:["D","date"],month:["M","month"],year:["Y","year"],hour:["[Hh]","hours"],minute:["m","minutes"],second:["s","seconds"],ampm:["[Aa]",""]};this.$widget=b('<span class="combodate"></span>').html(this.getTemplate());this.initCombos();this.$widget.on("change","select",b.proxy(function(c){this.$element.val(this.getValue()).change();if(this.options.smartDays){if(b(c.target).is(".month")||b(c.target).is(".year")){this.fillCombo("day")}}},this));this.$widget.find("select").css("width","auto");this.$element.hide().after(this.$widget);this.setValue(this.$element.val()||this.options.value)},getTemplate:function(){var c=this.options.template;b.each(this.map,function(e,d){d=d[0];var g=new RegExp(d+"+"),f=d.length>1?d.substring(1,2):d;c=c.replace(g,"{"+f+"}")});c=c.replace(/ /g,"&nbsp;");b.each(this.map,function(e,d){d=d[0];var f=d.length>1?d.substring(1,2):d;c=c.replace("{"+f+"}",'<select class="'+e+'"></select>')});return c},initCombos:function(){for(var c in this.map){var d=this.$widget.find("."+c);this["$"+c]=d.length?d:null;this.fillCombo(c)}},fillCombo:function(d){var g=this["$"+d];if(!g){return}var j="fill"+d.charAt(0).toUpperCase()+d.slice(1);var c=this[j]();var h=g.val();g.empty();for(var e=0;e<c.length;e++){g.append('<option value="'+c[e][0]+'">'+c[e][1]+"</option>")}g.val(h)},fillCommon:function(d){var c=[],e;if(this.options.firstItem==="name"){e=moment.relativeTime||moment.langData()._relativeTime;var f=typeof e[d]==="function"?e[d](1,true,d,false):e[d];f=f.split(" ").reverse()[0];c.push(["",f])}else{if(this.options.firstItem==="empty"){c.push(["",""])}}return c},fillDay:function(){var d=this.fillCommon("d"),e,f,c=this.options.template.indexOf("DD")!==-1,h=31;if(this.options.smartDays&&this.$month&&this.$year){var j=parseInt(this.$month.val(),10);var g=parseInt(this.$year.val(),10);if(!isNaN(j)&&!isNaN(g)){h=moment([g,j]).daysInMonth()}}for(f=1;f<=h;f++){e=c?this.leadZero(f):f;d.push([f,e])}return d},fillMonth:function(){var d=this.fillCommon("M"),e,f,h=this.options.template.indexOf("MMMM")!==-1,g=this.options.template.indexOf("MMM")!==-1,c=this.options.template.indexOf("MM")!==-1;for(f=0;f<=11;f++){if(h){e=moment().date(1).month(f).format("MMMM")}else{if(g){e=moment().date(1).month(f).format("MMM")}else{if(c){e=this.leadZero(f+1)}else{e=f+1}}}d.push([f,e])}return d},fillYear:function(){var c=[],d,e,f=this.options.template.indexOf("YYYY")!==-1;for(e=this.options.maxYear;e>=this.options.minYear;e--){d=f?e:(e+"").substring(2);c[this.options.yearDescending?"push":"unshift"]([e,d])}c=this.fillCommon("y").concat(c);return c},fillHour:function(){var e=this.fillCommon("h"),f,h,k=this.options.template.indexOf("h")!==-1,j=this.options.template.indexOf("H")!==-1,d=this.options.template.toLowerCase().indexOf("hh")!==-1,g=k?1:0,c=k?12:23;for(h=g;h<=c;h++){f=d?this.leadZero(h):h;e.push([h,f])}return e},fillMinute:function(){var d=this.fillCommon("m"),e,f,c=this.options.template.indexOf("mm")!==-1;for(f=0;f<=59;f+=this.options.minuteStep){e=c?this.leadZero(f):f;d.push([f,e])}return d},fillSecond:function(){var d=this.fillCommon("s"),e,f,c=this.options.template.indexOf("ss")!==-1;for(f=0;f<=59;f+=this.options.secondStep){e=c?this.leadZero(f):f;d.push([f,e])}return d},fillAmpm:function(){var d=this.options.template.indexOf("a")!==-1,e=this.options.template.indexOf("A")!==-1,c=[["am",d?"am":"AM"],["pm",d?"pm":"PM"]];return c},getValue:function(f){var e,c={},d=this,g=false;b.each(this.map,function(i,h){if(i==="ampm"){return}var j=i==="day"?1:0;c[i]=d["$"+i]?parseInt(d["$"+i].val(),10):j;if(isNaN(c[i])){g=true;return false}});if(g){return""}if(this.$ampm){if(c.hour===12){c.hour=this.$ampm.val()==="am"?0:12}else{c.hour=this.$ampm.val()==="am"?c.hour:c.hour+12}}e=moment([c.year,c.month,c.day,c.hour,c.minute,c.second]);this.highlight(e);f=f===undefined?this.options.format:f;if(f===null){return e.isValid()?e:null}else{return e.isValid()?e.format(f):""}},setValue:function(f){if(!f){return}var e=typeof f==="string"?moment(f,this.options.format):moment(f),d=this,c={};function g(h,i){var j={};h.children("option").each(function(l,k){var m=b(k).attr("value"),n;if(m===""){return}n=Math.abs(m-i);if(typeof j.distance==="undefined"||n<j.distance){j={value:m,distance:n}}});return j.value}if(e.isValid()){b.each(this.map,function(i,h){if(i==="ampm"){return}c[i]=e[h[1]]()});if(this.$ampm){if(c.hour>=12){c.ampm="pm";if(c.hour>12){c.hour-=12}}else{c.ampm="am";if(c.hour===0){c.hour=12}}}b.each(c,function(i,h){if(d["$"+i]){if(i==="minute"&&d.options.minuteStep>1&&d.options.roundTime){h=g(d["$"+i],h)}if(i==="second"&&d.options.secondStep>1&&d.options.roundTime){h=g(d["$"+i],h)}d["$"+i].val(h)}});if(this.options.smartDays){this.fillCombo("day")}this.$element.val(e.format(this.options.format)).change()}},highlight:function(c){if(!c.isValid()){if(this.options.errorClass){this.$widget.addClass(this.options.errorClass)}else{if(!this.borderColor){this.borderColor=this.$widget.find("select").css("border-color")}this.$widget.find("select").css("border-color","red")}}else{if(this.options.errorClass){this.$widget.removeClass(this.options.errorClass)}else{this.$widget.find("select").css("border-color",this.borderColor)}}},leadZero:function(c){return c<=9?"0"+c:c},destroy:function(){this.$widget.remove();this.$element.removeData("combodate").show()}};b.fn.combodate=function(e){var f,c=Array.apply(null,arguments);c.shift();if(e==="getValue"&&this.length&&(f=this.eq(0).data("combodate"))){return f.getValue.apply(f,c)}return this.each(function(){var h=b(this),g=h.data("combodate"),d=typeof e=="object"&&e;if(!g){h.data("combodate",(g=new a(this,d)))}if(typeof e=="string"&&typeof g[e]=="function"){g[e].apply(g,c)}})};b.fn.combodate.defaults={format:"DD-MM-YYYY HH:mm",template:"D / MMM / YYYY   H : mm",value:null,minYear:1970,maxYear:2015,yearDescending:true,minuteStep:5,secondStep:1,firstItem:"empty",errorClass:null,roundTime:true,smartDays:false}}(window.jQuery));(function(a){var b=function(c){this.init("combodate",c,b.defaults);if(!this.options.viewformat){this.options.viewformat=this.options.format}c.combodate=a.fn.editableutils.tryParseJson(c.combodate,true);this.options.combodate=a.extend({},b.defaults.combodate,c.combodate,{format:this.options.format,template:this.options.template})};a.fn.editableutils.inherit(b,a.fn.editabletypes.abstractinput);a.extend(b.prototype,{render:function(){this.$input.combodate(this.options.combodate);if(a.fn.editableform.engine==="bs3"){this.$input.siblings().find("select").addClass("form-control")}if(this.options.inputclass){this.$input.siblings().find("select").addClass(this.options.inputclass)}},value2html:function(d,c){var e=d?d.format(this.options.viewformat):"";b.superclass.value2html.call(this,e,c)},html2value:function(c){return c?moment(c,this.options.viewformat):null},value2str:function(c){return c?c.format(this.options.format):""},str2value:function(c){return c?moment(c,this.options.format):null},value2submit:function(c){return this.value2str(c)},value2input:function(c){this.$input.combodate("setValue",c)},input2value:function(){return this.$input.combodate("getValue",null)},activate:function(){this.$input.siblings(".combodate").find("select").eq(0).focus()},autosubmit:function(){}});b.defaults=a.extend({},a.fn.editabletypes.abstractinput.defaults,{tpl:'<input type="text">',inputclass:null,format:"YYYY-MM-DD",viewformat:null,template:"D / MMM / YYYY",combodate:null});a.fn.editabletypes.combodate=b}(window.jQuery));(function(b){var a=b.fn.editableform.Constructor.prototype.initInput;b.extend(b.fn.editableform.Constructor.prototype,{initTemplate:function(){this.$form=b(b.fn.editableform.template);this.$form.find(".control-group").addClass("form-group");this.$form.find(".editable-error-block").addClass("help-block")},initInput:function(){a.apply(this);var h=this.input.options.inputclass===null||this.input.options.inputclass===false;var c="input-sm";var d="text,select,textarea,password,email,url,tel,number,range,time,typeaheadjs".split(",");if(~b.inArray(this.input.type,d)){this.input.$input.addClass("form-control");if(h){this.input.options.inputclass=c;this.input.$input.addClass(c)}}var g=this.$form.find(".editable-buttons");var f=h?[c]:this.input.options.inputclass.split(" ");for(var e=0;e<f.length;e++){if(f[e].toLowerCase()==="input-lg"){g.find("button").removeClass("btn-sm").addClass("btn-lg")}}}});b.fn.editableform.buttons='<button type="submit" class="btn btn-primary btn-sm editable-submit"><i class="glyphicon glyphicon-ok"></i></button><button type="button" class="btn btn-default btn-sm editable-cancel"><i class="glyphicon glyphicon-remove"></i></button>';b.fn.editableform.errorGroupClass="has-error";b.fn.editableform.errorBlockClass=null;b.fn.editableform.engine="bs3"}(window.jQuery));(function(a){a.extend(a.fn.editableContainer.Popup.prototype,{containerName:"popover",containerDataName:"bs.popover",innerCss:".popover-content",defaults:a.fn.popover.Constructor.DEFAULTS,initContainer:function(){a.extend(this.containerOptions,{trigger:"manual",selector:false,content:" ",template:this.defaults.template});var b;if(this.$element.data("template")){b=this.$element.data("template");this.$element.removeData("template")}this.call(this.containerOptions);if(b){this.$element.data("template",b)}},innerShow:function(){this.call("show")},innerHide:function(){this.call("hide")},innerDestroy:function(){this.call("destroy")},setContainerOption:function(b,c){this.container().options[b]=c},setPosition:function(){(function(){var g=this.tip();var f=typeof this.options.placement=="function"?this.options.placement.call(this,g[0],this.$element[0]):this.options.placement;var n=/\s?auto?\s?/i;var o=n.test(f);if(o){f=f.replace(n,"")||"top"}var k=this.getPosition();var b=g[0].offsetWidth;var i=g[0].offsetHeight;if(o){var e=this.$element.parent();var d=f;var l=document.documentElement.scrollTop||document.body.scrollTop;var m=this.options.container=="body"?window.innerWidth:e.outerWidth();var j=this.options.container=="body"?window.innerHeight:e.outerHeight();var h=this.options.container=="body"?0:e.offset().left;f=f=="bottom"&&k.top+k.height+i-l>j?"top":f=="top"&&k.top-l-i<0?"bottom":f=="right"&&k.right+b>m?"left":f=="left"&&k.left-b<h?"right":f;g.removeClass(d).addClass(f)}var c=this.getCalculatedOffset(f,k,b,i);this.applyPlacement(c,f)}).call(this.container())}})}(window.jQuery));(function(a){var b=function(c){this.init("datetime",c,b.defaults);this.initPicker(c,b.defaults)};a.fn.editableutils.inherit(b,a.fn.editabletypes.abstractinput);a.extend(b.prototype,{initPicker:function(c,d){if(!this.options.viewformat){this.options.viewformat=this.options.format}c.datetimepicker=a.fn.editableutils.tryParseJson(c.datetimepicker,true);this.options.datetimepicker=a.extend({},d.datetimepicker,c.datetimepicker,{format:this.options.viewformat});this.options.datetimepicker.language=this.options.datetimepicker.language||"en";this.dpg=a.fn.datetimepicker.DPGlobal;this.parsedFormat=this.dpg.parseFormat(this.options.format,this.options.formatType);this.parsedViewFormat=this.dpg.parseFormat(this.options.viewformat,this.options.formatType)},render:function(){this.$input.datetimepicker(this.options.datetimepicker);this.$input.on("changeMode",function(d){var c=a(this).closest("form").parent();setTimeout(function(){c.triggerHandler("resize")},0)});if(this.options.clear){this.$clear=a('<a href="#"></a>').html(this.options.clear).click(a.proxy(function(c){c.preventDefault();c.stopPropagation();this.clear()},this));this.$tpl.parent().append(a('<div class="editable-clear">').append(this.$clear))}},value2html:function(d,c){var e=d?this.dpg.formatDate(this.toUTC(d),this.parsedViewFormat,this.options.datetimepicker.language,this.options.formatType):"";if(c){b.superclass.value2html.call(this,e,c)}else{return e}},html2value:function(c){var d=this.parseDate(c,this.parsedViewFormat);return d?this.fromUTC(d):null},value2str:function(c){return c?this.dpg.formatDate(this.toUTC(c),this.parsedFormat,this.options.datetimepicker.language,this.options.formatType):""},str2value:function(d){var c=this.parseDate(d,this.parsedFormat);return c?this.fromUTC(c):null},value2submit:function(c){return this.value2str(c)},value2input:function(c){if(c){this.$input.data("datetimepicker").setDate(c)}},input2value:function(){var c=this.$input.data("datetimepicker");return c.date?c.getDate():null},activate:function(){},clear:function(){this.$input.data("datetimepicker").date=null;this.$input.find(".active").removeClass("active");if(!this.options.showbuttons){this.$input.closest("form").submit()}},autosubmit:function(){this.$input.on("mouseup",".minute",function(d){var c=a(this).closest("form");setTimeout(function(){c.submit()},200)})},toUTC:function(c){return c?new Date(c.valueOf()-c.getTimezoneOffset()*60000):c},fromUTC:function(c){return c?new Date(c.valueOf()+c.getTimezoneOffset()*60000):c},parseDate:function(f,d){var c=null,e;if(f){c=this.dpg.parseDate(f,d,this.options.datetimepicker.language,this.options.formatType);if(typeof f==="string"){e=this.dpg.formatDate(c,d,this.options.datetimepicker.language,this.options.formatType);if(f!==e){c=null}}}return c}});b.defaults=a.extend({},a.fn.editabletypes.abstractinput.defaults,{tpl:'<div class="editable-date well"></div>',inputclass:null,format:"yyyy-mm-dd hh:ii",formatType:"standard",viewformat:null,datetimepicker:{todayHighlight:false,autoclose:false},clear:"&times; clear"});a.fn.editabletypes.datetime=b}(window.jQuery));(function(b){var a=function(c){this.init("datetimefield",c,a.defaults);this.initPicker(c,a.defaults)};b.fn.editableutils.inherit(a,b.fn.editabletypes.datetime);b.extend(a.prototype,{render:function(){this.$input=this.$tpl.find("input");this.setClass();this.setAttr("placeholder");this.$tpl.datetimepicker(this.options.datetimepicker);this.$input.off("focus keydown");this.$input.keyup(b.proxy(function(){this.$tpl.removeData("date");this.$tpl.datetimepicker("update")},this))},value2input:function(c){this.$input.val(this.value2html(c));this.$tpl.datetimepicker("update")},input2value:function(){return this.html2value(this.$input.val())},activate:function(){b.fn.editabletypes.text.prototype.activate.call(this)},autosubmit:function(){}});a.defaults=b.extend({},b.fn.editabletypes.datetime.defaults,{tpl:'<div class="input-group date"><input type="text"/><span class="input-group-addon"><i class="fa fa-th"></i></span></div>',inputclass:"input-medium",datetimepicker:{todayHighlight:false,autoclose:true}});b.fn.editabletypes.datetimefield=a}(window.jQuery));