ace-editable.min.js
7.25 KB
(function(b){var a=function(c){this.init("image",c,a.defaults);if("on_error" in c.image){this.on_error=c.image.on_error;delete c.image.on_error}if("on_success" in c.image){this.on_success=c.image.on_success;delete c.image.on_success}if("max_size" in c.image){this.max_size=c.image.max_size;delete c.image.max_size}this.initImage(c,a.defaults)};b.fn.editableutils.inherit(a,b.fn.editabletypes.abstractinput);b.extend(a.prototype,{initImage:function(c,d){this.options.image=b.extend({},d.image,c.image);this.name=this.options.image.name||"editable-image-input"},render:function(){var c=this;this.$input=this.$tpl.find("input[type=hidden]:eq(0)");this.$file=this.$tpl.find("input[type=file]:eq(0)");this.$file.attr({name:this.name});this.$input.attr({name:this.name+"-hidden"});this.options.image.allowExt=this.options.image.allowExt||["jpg","jpeg","png","gif"];this.options.image.allowMime=this.options.image.allowMime||["image/jpg","image/jpeg","image/png","image/gif"];this.options.image.maxSize=c.max_size||this.options.image.maxSize||false;this.options.image.before_remove=this.options.image.before_remove||function(){c.$input.val(null);return true};this.$file.ace_file_input(this.options.image).on("change",function(){var d=(c.$file.val()||c.$file.data("ace_input_files"))?Math.random()+""+(new Date()).getTime():null;c.$input.val(d)}).closest(".ace-file-input").css({width:"150px"}).closest(".editable-input").addClass("editable-image");this.$file.off("file.error.ace").on("file.error.ace",function(f,d){if(!c.on_error){return}if(d.error_count.ext>0||d.error_count.mime>0){c.on_error(1)}else{if(d.error_count.size>0){c.on_error(2)}}})}});a.defaults=b.extend({},b.fn.editabletypes.abstractinput.defaults,{tpl:'<span><input type="hidden" /></span><span><input type="file" /></span>',inputclass:"",image:{style:"well",btn_choose:"Change Image",btn_change:null,no_icon:"fa fa-picture-o",thumbnail:"large"}});b.fn.editabletypes.image=a}(window.jQuery));(function(a){var b=function(c){this.init("wysiwyg",c,b.defaults);this.options.wysiwyg=a.extend({},b.defaults.wysiwyg,c.wysiwyg)};a.fn.editableutils.inherit(b,a.fn.editabletypes.abstractinput);a.extend(b.prototype,{render:function(){this.$editor=this.$input.nextAll(".wysiwyg-editor:eq(0)");this.$tpl.parent().find(".wysiwyg-editor").show().ace_wysiwyg({toolbar:["bold","italic","strikethrough","underline",null,"foreColor",null,"insertImage"]}).prev().addClass("wysiwyg-style2").closest(".editable-input").addClass("editable-wysiwyg").closest(".editable-container").css({display:"block"});if(this.options.wysiwyg&&this.options.wysiwyg.css){this.$tpl.closest(".editable-wysiwyg").css(this.options.wysiwyg.css)}},value2html:function(d,c){a(c).html(d);return false},html2value:function(c){return c},value2input:function(c){this.$editor.html(c)},input2value:function(){return this.$editor.html()},activate:function(){}});b.defaults=a.extend({},a.fn.editabletypes.abstractinput.defaults,{tpl:'<input type="hidden" /><div class="wysiwyg-editor"></div>',inputclass:"editable-wysiwyg",wysiwyg:{}});a.fn.editabletypes.wysiwyg=b}(window.jQuery));(function(b){var a=function(c){this.init("spinner",c,a.defaults);this.initSpinner(c,a.defaults);this.nativeUI=false;try{var f=document.createElement("INPUT");f.type="number";this.nativeUI=f.type==="number"&&this.options.spinner.nativeUI===true}catch(d){}};b.fn.editableutils.inherit(a,b.fn.editabletypes.abstractinput);b.extend(a.prototype,{initSpinner:function(c,d){this.options.spinner=b.extend({},d.spinner,c.spinner)},render:function(){},activate:function(){if(this.$input.is(":visible")){this.$input.focus();b.fn.editableutils.setCursorPosition(this.$input.get(0),this.$input.val().length);if(!this.nativeUI){var e=parseInt(this.$input.val());var c=b.extend({value:e},this.options.spinner);this.$input.ace_spinner(c)}else{this.$input.get(0).type="number";var c=["min","max","step"];for(var d=0;d<c.length;d++){if(c[d] in this.options.spinner){this.$input.attr(c[d],this.options.spinner[c[d]])}}}}},autosubmit:function(){this.$input.keydown(function(c){if(c.which===13){b(this).closest("form").submit()}})}});a.defaults=b.extend({},b.fn.editabletypes.abstractinput.defaults,{tpl:'<input type="text" />',inputclass:"",spinner:{min:0,max:100,step:1,icon_up:"fa fa-plus",icon_down:"fa fa-minus",btn_up_class:"btn-success",btn_down_class:"btn-danger"}});b.fn.editabletypes.spinner=a}(window.jQuery));(function(b){var a=function(c){this.init("slider",c,a.defaults);this.initSlider(c,a.defaults);this.nativeUI=false;try{var f=document.createElement("INPUT");f.type="range";this.nativeUI=f.type==="range"&&this.options.slider.nativeUI===true}catch(d){}};b.fn.editableutils.inherit(a,b.fn.editabletypes.abstractinput);b.extend(a.prototype,{initSlider:function(c,d){this.options.slider=b.extend({},d.slider,c.slider)},render:function(){},activate:function(){if(this.$input.is(":visible")){this.$input.focus();b.fn.editableutils.setCursorPosition(this.$input.get(0),this.$input.val().length);if(!this.nativeUI){var c=this;var g=parseInt(this.$input.val());var e=this.options.slider.width||200;var d=b.extend(this.options.slider,{value:g,slide:function(h,i){var j=parseInt(i.value);c.$input.val(j);if(i.handle.firstChild==null){b(i.handle).prepend("<div class='tooltip top in' style='display:none; top:-38px; left:-5px;'><div class='tooltip-arrow'></div><div class='tooltip-inner'></div></div>")}b(i.handle.firstChild).show().children().eq(1).text(j)}});this.$input.parent().addClass("editable-slider").css("width",e+"px").slider(d)}else{this.$input.get(0).type="range";var d=["min","max","step"];for(var f=0;f<d.length;f++){if(d[f] in this.options.slider){this.$input[0][d[f]]=this.options.slider[d[f]]}}var e=this.options.slider.width||200;this.$input.parent().addClass("editable-slider").css("width",e+"px")}}},value2html:function(d,c){},autosubmit:function(){this.$input.keydown(function(c){if(c.which===13){b(this).closest("form").submit()}})}});a.defaults=b.extend({},b.fn.editabletypes.abstractinput.defaults,{tpl:'<input type="text" /><span class="inline ui-slider-green"><span class="slider-display"></span></span>',inputclass:"",slider:{min:1,max:100,step:1,range:"min"}});b.fn.editabletypes.slider=a}(window.jQuery));(function(b){var a=function(c){this.init("adate",c,a.defaults);this.initDate(c,a.defaults);this.nativeUI=false;try{var f=document.createElement("INPUT");f.type="date";this.nativeUI=f.type==="date"&&this.options.date.nativeUI===true}catch(d){}};b.fn.editableutils.inherit(a,b.fn.editabletypes.abstractinput);b.extend(a.prototype,{initDate:function(c,d){this.options.date=b.extend({},d.date,c.date)},render:function(){this.$input=this.$tpl.find("input.date")},activate:function(){if(this.$input.is(":visible")){this.$input.focus()}if(!this.nativeUI){var d=this.$input;this.$input.datepicker(this.options.date);var c=d.data("datepicker");if(c){d.on("click",function(){c.show()}).siblings(".input-group-addon").on("click",function(){c.show()})}}else{this.$input.get(0).type="date"}},autosubmit:function(){this.$input.keydown(function(c){if(c.which===13){b(this).closest("form").submit()}})}});a.defaults=b.extend({},b.fn.editabletypes.abstractinput.defaults,{tpl:'<div class="input-group input-group-compact"><input type="text" class="input-medium date" /><span class="input-group-addon"><i class="fa fa-calendar"></i></span></div>',date:{weekStart:0,startView:0,minViewMode:0}});b.fn.editabletypes.adate=a}(window.jQuery));