unction(a){return function(b){return a.target.attr("target",a.selectTarget.val()),a.editor.inputManager.throttledValueChanged()}}(this))},c.prototype.show=function(){var a;return a=1<=arguments.length?P.call(arguments,0):[],c.__super__.show.apply(this,a),this.textEl.val(this.target.text()),this.urlEl.val(this.target.attr("href"))},c}(B),D.Toolbar.addButton(w),p=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="image",c.prototype.icon="picture-o",c.prototype.htmlTag="img",c.prototype.disableTag="pre, table",c.prototype.defaultImage="",c.prototype.needFocus=!1,c.prototype._init=function(){var b,d,e,f;if(this.editor.opts.imageButton)if(Array.isArray(this.editor.opts.imageButton))for(this.menu=[],f=this.editor.opts.imageButton,d=0,e=f.length;e>d;d++)b=f[d],this.menu.push({name:b+"-image",text:this._t(b+"Image")});else this.menu=!1;else null!=this.editor.uploader?this.menu=[{name:"upload-image",text:this._t("uploadImage")},{name:"external-image",text:this._t("externalImage")}]:this.menu=!1;return this.defaultImage=this.editor.opts.defaultImage,this.editor.body.on("click","img:not([data-non-image])",function(b){return function(c){var d,e;return d=a(c.currentTarget),e=document.createRange(),e.selectNode(d[0]),b.editor.selection.range(e),b.editor.util.support.onselectionchange||b.editor.trigger("selectionchanged"),!1}}(this)),this.editor.body.on("mouseup","img:not([data-non-image])",function(a){return!1}),this.editor.on("selectionchanged.image",function(b){return function(){var c,d,e;return e=b.editor.selection.range(),null!=e?(c=a(e.cloneContents()).contents(),1===c.length&&c.is("img:not([data-non-image])")?(d=a(e.startContainer).contents().eq(e.startOffset),b.popover.show(d)):b.popover.hide()):void 0}}(this)),this.editor.on("valuechanged.image",function(b){return function(){var c;return c=b.editor.wrapper.find(".simditor-image-loading"),c.length>0?c.each(function(c,d){var e,f,g;return f=a(d),e=f.data("img"),!(e&&e.parent().length>0)&&(f.remove(),e&&(g=e.data("file"),g&&(b.editor.uploader.cancel(g),b.editor.body.find("img.uploading").length<1)))?b.editor.uploader.trigger("uploadready",[g]):void 0}):void 0}}(this)),c.__super__._init.call(this)},c.prototype.render=function(){var a;return a=1<=arguments.length?P.call(arguments,0):[],c.__super__.render.apply(this,a),this.popover=new q({button:this}),"upload"===this.editor.opts.imageButton?this._initUploader(this.el):void 0},c.prototype.renderMenu=function(){return c.__super__.renderMenu.call(this),this._initUploader()},c.prototype._initUploader=function(b){var c,d,e;return null==b&&(b=this.menuEl.find(".menu-item-upload-image")),null==this.editor.uploader?void this.el.find(".btn-upload").remove():(c=null,d=function(d){return function(){return c&&c.remove(),c=a("<input/>",{type:"file",title:d._t("uploadImage"),multiple:!0,accept:"image/*"}).appendTo(b)}}(this),d(),b.on("click mousedown","input[type=file]",function(a){return a.stopPropagation()}),b.on("change","input[type=file]",function(a){return function(b){return a.editor.inputManager.focused?(a.editor.uploader.upload(c,{inline:!0}),d()):(a.editor.one("focus",function(b){return a.editor.uploader.upload(c,{inline:!0}),d()}),a.editor.focus()),a.wrapper.removeClass("menu-on")}}(this)),this.editor.uploader.on("beforeupload",function(b){return function(c,d){var e;if(d.inline)return d.img?e=a(d.img):(e=b.createImage(d.name),d.img=e),e.addClass("uploading"),e.data("file",d),b.editor.uploader.readImageFile(d.obj,function(a){var c;if(e.hasClass("uploading"))return c=a?a.src:b.defaultImage,b.loadImage(e,c,function(){return b.popover.active?(b.popover.refresh(),b.popover.srcEl.val(b._t("uploading")).prop("disabled",!0)):void 0})})}}(this)),e=a.proxy(this.editor.util.throttle(function(a,b,c,d){var e,f,g;if(b.inline&&(f=b.img.data("mask")))return e=f.data("img"),e.hasClass("uploading")&&e.parent().length>0?(g=c/d,g=(100*g).toFixed(0),g>99&&(g=99),f.find(".progress").height(100-g+"%")):void f.remove()},500),this),this.editor.uploader.on("uploadprogress",e),this.editor.uploader.on("uploadsuccess",function(b){return function(c,d,e){var f,g,h;if(d.inline&&(f=d.img,f.hasClass("uploading")&&f.parent().length>0)){if("object"!=typeof e)try{e=a.parseJSON(e)}catch(i){c=i,e={success:!1}}return e.success===!1?(h=e.msg||b._t("uploadFailed"),alert(h),g=b.defaultImage):g=e.file_path,b.loadImage(f,g,function(){var a;return f.removeData("file"),f.removeClass("uploading").removeClass("loading"),a=f.data("mask"),a&&a.remove(),f.removeData("mask"),b.editor.trigger("valuechanged"),b.editor.body.find("img.uploading").length<1?b.editor.uploader.trigger("uploadready",[d,e]):void 0}),b.popover.active?(b.popover.srcEl.prop("disabled",!1),b.popover.srcEl.val(e.file_path)):void 0}}}(this)),this.editor.uploader.on("uploaderror",function(b){return function(c,d,e){var f,g,h;if(d.inline&&"abort"!==e.statusText){if(e.responseText){try{h=a.parseJSON(e.responseText),g=h.msg}catch(i){c=i,g=b._t("uploadError")}alert(g)}if(f=d.img,f.hasClass("uploading")&&f.parent().length>0)return b.loadImage(f,b.defaultImage,function(){var a;return f.removeData("file"),f.removeClass("uploading").removeClass("loading"),a=f.data("mask"),a&&a.remove(),f.removeData("mask")}),b.popover.active&&(b.popover.srcEl.prop("disabled",!1),b.popover.srcEl.val(b.defaultImage)),b.editor.trigger("valuechanged"),b.editor.body.find("img.uploading").length<1?b.editor.uploader.trigger("uploadready",[d,h]):void 0}}}(this)))},c.prototype._status=function(){return this._disableStatus()},c.prototype.loadImage=function(b,c,d){var e,f,g;return g=function(a){return function(){var c,d;return c=b.offset(),d=a.editor.wrapper.offset(),e.css({top:c.top-d.top,left:c.left-d.left,width:b.width(),height:b.height()}).show()}}(this),b.addClass("loading"),e=b.data("mask"),e||(e=a('<div class="simditor-image-loading">\n <div class="progress"></div>\n</div>').hide().appendTo(this.editor.wrapper),g(),b.data("mask",e),e.data("img",b)),f=new Image,f.onload=function(h){return function(){var i,j;if(b.hasClass("loading")||b.hasClass("uploading"))return j=f.width,i=f.height,b.attr({src:c,width:j,height:i,"data-image-size":j+","+i}).removeClass("loading"),b.hasClass("uploading")?(h.editor.util.reflow(h.editor.body),g()):(e.remove(),b.removeData("mask")),a.isFunction(d)?d(f):void 0}}(this),f.onerror=function(){return a.isFunction(d)&&d(!1),e.remove(),b.removeData("mask").removeClass("loading")},f.src=c},c.prototype.createImage=function(b){var c,d;return null==b&&(b="Image"),this.editor.inputManager.focused||this.editor.focus(),d=this.editor.selection.range(),d.deleteContents(),this.editor.selection.range(d),c=a("<img/>").attr("alt",b),d.insertNode(c[0]),this.editor.selection.setRangeAfter(c,d),this.editor.trigger("valuechanged"),c},c.prototype.command=function(a){var b;return b=this.createImage(),this.loadImage(b,a||this.defaultImage,function(a){return function(){return a.editor.trigger("valuechanged"),a.editor.util.reflow(b),b.click(),a.popover.one("popovershow",function(){return a.popover.srcEl.focus(),a.popover.srcEl[0].select()})}}(this))},c}(h),q=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.offset={top:6,left:-4},c.prototype.render=function(){var b;return b='<div class="link-settings">\n <div class="settings-field">\n <label>'+this._t("imageUrl")+'</label>\n <input class="image-src" type="text" tabindex="1" />\n <a class="btn-upload" href="javascript:;"\n title="'+this._t("uploadImage")+'" tabindex="-1">\n <span class="simditor-icon simditor-icon-upload"></span>\n </a>\n </div>\n <div class=\'settings-field\'>\n <label>'+this._t("imageAlt")+'</label>\n <input class="image-alt" id="image-alt" type="text" tabindex="1" />\n </div>\n <div class="settings-field">\n <label>'+this._t("imageSize")+'</label>\n <input class="image-size" id="image-width" type="text" tabindex="2" />\n <span class="times">×</span>\n <input class="image-size" id="image-height" type="text" tabindex="3" />\n <a class="btn-restore" href="javascript:;"\n title="'+this._t("restoreImageSize")+'" tabindex="-1">\n <span class="simditor-icon simditor-icon-undo"></span>\n </a>\n </div>\n</div>',this.el.addClass("image-popover").append(b),this.srcEl=this.el.find(".image-src"),this.widthEl=this.el.find("#image-width"),this.heightEl=this.el.find("#image-height"),this.altEl=this.el.find("#image-alt"),this.srcEl.on("keydown",function(a){return function(b){var c;if(13===b.which&&!a.target.hasClass("uploading"))return b.preventDefault(),c=document.createRange(),a.button.editor.selection.setRangeAfter(a.target,c),a.hide()}}(this)),this.srcEl.on("blur",function(a){return function(b){return a._loadImage(a.srcEl.val())}}(this)),this.el.find(".image-size").on("blur",function(b){return function(c){return b._resizeImg(a(c.currentTarget)),b.el.data("popover").refresh()}}(this)),this.el.find(".image-size").on("keyup",function(b){return function(c){var d;return d=a(c.currentTarget),13!==c.which&&27!==c.which&&9!==c.which?b._resizeImg(d,!0):void 0}}(this)),this.el.find(".image-size").on("keydown",function(b){return function(c){var d,e,f;return e=a(c.currentTarget),13===c.which||27===c.which?(c.preventDefault(),13===c.which?b._resizeImg(e):b._restoreImg(),d=b.target,b.hide(),f=document.createRange(),b.button.editor.selection.setRangeAfter(d,f)):9===c.which?b.el.data("popover").refresh():void 0}}(this)),this.altEl.on("keydown",function(a){return function(b){var c;return 13===b.which?(b.preventDefault(),c=document.createRange(),a.button.editor.selection.setRangeAfter(a.target,c),a.hide()):void 0}}(this)),this.altEl.on("keyup",function(a){return function(b){return 13!==b.which&&27!==b.which&&9!==b.which?(a.alt=a.altEl.val(),a.target.attr("alt",a.alt)):void 0}}(this)),this.el.find(".btn-restore").on("click",function(a){return function(b){return a._restoreImg(),a.el.data("popover").refresh()}}(this)),this.editor.on("valuechanged",function(a){return function(b){return a.active?a.refresh():void 0}}(this)),this._initUploader()},c.prototype._initUploader=function(){var b,c;return b=this.el.find(".btn-upload"),null==this.editor.uploader?void b.remove():(c=function(c){return function(){return c.input&&c.input.remove(),c.input=a("<input/>",{type:"file",title:c._t("uploadImage"),multiple:!0,accept:"image/*"}).appendTo(b)}}(this),c(),this.el.on("click mousedown","input[type=file]",function(a){return a.stopPropagation()}),this.el.on("change","input[type=file]",function(a){return function(b){return a.editor.uploader.upload(a.input,{inline:!0,img:a.target}),c()}}(this)))},c.prototype._resizeImg=function(b,c){var d,e,f;return null==c&&(c=!1),e=1*b.val(),this.target&&(a.isNumeric(e)||0>e)?(b.is(this.widthEl)?(f=e,d=this.height*e/this.width,this.heightEl.val(d)):(d=e,f=this.width*e/this.height,this.widthEl.val(f)),c?void 0:(this.target.attr({width:f,height:d}),this.editor.trigger("valuechanged"))):void 0},c.prototype._restoreImg=function(){var a,b;return b=(null!=(a=this.target.data("image-size"))?a.split(","):void 0)||[this.width,this.height],this.target.attr({width:1*b[0],height:1*b[1]}),this.widthEl.val(b[0]),this.heightEl.val(b[1]),this.editor.trigger("valuechanged")},c.prototype._loadImage=function(a,b){if(/^data:image/.test(a)&&!this.editor.uploader)return void(b&&b(!1));if(this.target.attr("src")!==a)return this.button.loadImage(this.target,a,function(c){return function(d){var e;if(d)return c.active&&(c.width=d.width,c.height=d.height,c.widthEl.val(c.width),c.heightEl.val(c.height)),/^data:image/.test(a)?(e=c.editor.util.dataURLtoBlob(a),e.name="Base64 Image.png",c.editor.uploader.upload(e,{inline:!0,img:c.target})):c.editor.trigger("valuechanged"),b?b(d):void 0}}(this))},c.prototype.show=function(){var a,b;return b=1<=arguments.length?P.call(arguments,0):[],c.__super__.show.apply(this,b),a=this.target,this.width=a.width(),this.height=a.height(),this.alt=a.attr("alt"),a.hasClass("uploading")?this.srcEl.val(this._t("uploading")).prop("disabled",!0):(this.srcEl.val(a.attr("src")).prop("disabled",!1),this.widthEl.val(this.width),this.heightEl.val(this.height),this.altEl.val(this.alt))},c}(B),D.Toolbar.addButton(p),r=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return M(b,a),b.prototype.name="indent",b.prototype.icon="indent",b.prototype._init=function(){return this.title=this._t(this.name)+" (Tab)",b.__super__._init.call(this)},b.prototype._status=function(){},b.prototype.command=function(){return this.editor.indentation.indent()},b}(h),D.Toolbar.addButton(r),A=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return M(b,a),b.prototype.name="outdent",b.prototype.icon="outdent",b.prototype._init=function(){return this.title=this._t(this.name)+" (Shift + Tab)",b.__super__._init.call(this)},b.prototype._status=function(){},b.prototype.command=function(){return this.editor.indentation.indent(!0)},b}(h),D.Toolbar.addButton(A),o=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="hr",c.prototype.icon="minus",c.prototype.htmlTag="hr",c.prototype._status=function(){},c.prototype.command=function(){var b,c,d,e;return e=this.editor.selection.rootNodes().first(),d=e.next(),d.length>0?this.editor.selection.save():c=a("<p/>").append(this.editor.util.phBr),b=a("<hr/>").insertAfter(e),c?(c.insertAfter(b),this.editor.selection.setRangeAtStartOf(c)):this.editor.selection.restore(),this.editor.trigger("valuechanged")},c}(h),D.Toolbar.addButton(o),F=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="table",c.prototype.icon="table",c.prototype.htmlTag="table",c.prototype.disableTag="pre, li, blockquote",c.prototype.menu=!0,c.prototype._init=function(){return c.__super__._init.call(this),a.merge(this.editor.formatter._allowedTags,["thead","th","tbody","tr","td","colgroup","col"]),a.extend(this.editor.formatter._allowedAttributes,{td:["rowspan","colspan"],col:["width"]}),a.extend(this.editor.formatter._allowedStyles,{td:["text-align"],th:["text-align"]}),this._initShortcuts(),this.editor.on("decorate",function(b){return function(c,d){return d.find("table").each(function(c,d){return b.decorate(a(d))})}}(this)),this.editor.on("undecorate",function(b){return function(c,d){return d.find("table").each(function(c,d){return b.undecorate(a(d))})}}(this)),this.editor.on("selectionchanged.table",function(a){return function(b){var c,d;return a.editor.body.find(".simditor-table td, .simditor-table th").removeClass("active"),(d=a.editor.selection.range())?(c=a.editor.selection.containerNode(),d.collapsed&&c.is(".simditor-table")&&(c=a.editor.selection.rangeAtStartOf(c)?c.find("th:first"):c.find("td:last"),a.editor.selection.setRangeAtEndOf(c)),c.closest("td, th",a.editor.body).addClass("active")):void 0}}(this)),this.editor.on("blur.table",function(a){return function(b){return a.editor.body.find(".simditor-table td, .simditor-table th").removeClass("active")}}(this)),this.editor.keystroke.add("up","td",function(a){return function(b,c){return a._tdNav(c,"up"),!0}}(this)),this.editor.keystroke.add("up","th",function(a){return function(b,c){return a._tdNav(c,"up"),!0}}(this)),this.editor.keystroke.add("down","td",function(a){return function(b,c){return a._tdNav(c,"down"),!0}}(this)),this.editor.keystroke.add("down","th",function(a){return function(b,c){return a._tdNav(c,"down"),!0}}(this))},c.prototype._tdNav=function(a,b){var c,d,e,f,g,h,i;return null==b&&(b="up"),e="up"===b?"prev":"next",i="up"===b?["tbody","thead"]:["thead","tbody"],h=i[0],f=i[1],d=a.parent("tr"),c=this["_"+e+"Row"](d),c.length>0?(g=d.find("td, th").index(a),this.editor.selection.setRangeAtEndOf(c.find("td, th").eq(g))):!0},c.prototype._nextRow=function(a){var b;return b=a.next("tr"),b.length<1&&a.parent("thead").length>0&&(b=a.parent("thead").next("tbody").find("tr:first")),b},c.prototype._prevRow=function(a){var b;return b=a.prev("tr"),b.length<1&&a.parent("tbody").length>0&&(b=a.parent("tbody").prev("thead").find("tr")),b},c.prototype.initResize=function(b){var c,d,e;return e=b.parent(".simditor-table"),c=b.find("colgroup"),c.length<1&&(c=a("<colgroup/>").prependTo(b),b.find("thead tr th").each(function(b,d){var e;return e=a("<col/>").appendTo(c)}),this.refreshTableWidth(b)),d=a("<div />",{"class":"simditor-resize-handle",contenteditable:"false"}).appendTo(e),e.on("mousemove","td, th",function(b){var f,g,h,i,j,k;if(!e.hasClass("resizing"))return g=a(b.currentTarget),k=b.pageX-a(b.currentTarget).offset().left,5>k&&g.prev().length>0&&(g=g.prev()),g.next("td, th").length<1?void d.hide():(null!=(i=d.data("td"))?i.is(g):void 0)?void d.show():(h=g.parent().find("td, th").index(g),f=c.find("col").eq(h),(null!=(j=d.data("col"))?j.is(f):void 0)?void d.show():d.css("left",g.position().left+g.outerWidth()-5).data("td",g).data("col",f).show())}),e.on("mouseleave",function(a){return d.hide()}),e.on("mousedown",".simditor-resize-handle",function(b){var c,d,f,g,h,i,j,k,l,m,n;return c=a(b.currentTarget),f=c.data("td"),d=c.data("col"),h=f.next("td, th"),g=d.next("col"),m=b.pageX,k=1*f.outerWidth(),l=1*h.outerWidth(),j=parseFloat(c.css("left")),n=f.closest("table").width(),i=50,a(document).on("mousemove.simditor-resize-table",function(a){var b,e,f;return b=a.pageX-m,e=k+b,f=l-b,i>e?(e=i,b=i-k,f=l-b):i>f&&(f=i,b=l-i,e=k+b),d.attr("width",e/n*100+"%"),g.attr("width",f/n*100+"%"),c.css("left",j+b)}),a(document).one("mouseup.simditor-resize-table",function(b){return a(document).off(".simditor-resize-table"),e.removeClass("resizing")}),e.addClass("resizing"),!1})},c.prototype._initShortcuts=function(){return this.editor.hotkeys.add("ctrl+alt+up",function(a){return function(b){return a.editMenu.find(".menu-item[data-param=insertRowAbove]").click(),!1}}(this)),this.editor.hotkeys.add("ctrl+alt+down",function(a){return function(b){return a.editMenu.find(".menu-item[data-param=insertRowBelow]").click(),!1}}(this)),this.editor.hotkeys.add("ctrl+alt+left",function(a){return function(b){return a.editMenu.find(".menu-item[data-param=insertColLeft]").click(),!1}}(this)),this.editor.hotkeys.add("ctrl+alt+right",function(a){return function(b){return a.editMenu.find(".menu-item[data-param=insertColRight]").click(),!1}}(this))},c.prototype.decorate=function(b){var c,d,e;return b.parent(".simditor-table").length>0&&this.undecorate(b),b.wrap('<div class="simditor-table"></div>'),b.find("thead").length<1&&(e=a("<thead />"),c=b.find("tr").first(),e.append(c),this._changeCellTag(c,"th"),d=b.find("tbody"),d.length>0?d.before(e):b.prepend(e)),this.initResize(b),b.parent()},c.prototype.undecorate=function(a){return a.parent(".simditor-table").length>0?a.parent().replaceWith(a):void 0},c.prototype.renderMenu=function(){var b;return a('<div class="menu-create-table">\n</div>\n<div class="menu-edit-table">\n <ul>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="deleteRow">\n <span>'+this._t("deleteRow")+'</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertRowAbove">\n <span>'+this._t("insertRowAbove")+' ( Ctrl + Alt + ↑ )</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertRowBelow">\n <span>'+this._t("insertRowBelow")+' ( Ctrl + Alt + ↓ )</span>\n </a>\n </li>\n <li><span class="separator"></span></li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="deleteCol">\n <span>'+this._t("deleteColumn")+'</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertColLeft">\n <span>'+this._t("insertColumnLeft")+' ( Ctrl + Alt + ← )</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertColRight">\n <span>'+this._t("insertColumnRight")+' ( Ctrl + Alt + → )</span>\n </a>\n </li>\n <li><span class="separator"></span></li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="deleteTable">\n <span>'+this._t("deleteTable")+"</span>\n </a>\n </li>\n </ul>\n</div>").appendTo(this.menuWrapper),this.createMenu=this.menuWrapper.find(".menu-create-table"),this.editMenu=this.menuWrapper.find(".menu-edit-table"),b=this.createTable(6,6).appendTo(this.createMenu),this.createMenu.on("mouseenter","td, th",function(c){return function(d){var e,f,g,h;return c.createMenu.find("td, th").removeClass("selected"),e=a(d.currentTarget),f=e.parent(),h=f.find("td, th").index(e)+1,g=f.prevAll("tr").addBack(),f.parent().is("tbody")&&(g=g.add(b.find("thead tr"))),g.find("td:lt("+h+"), th:lt("+h+")").addClass("selected")}}(this)),this.createMenu.on("mouseleave",function(b){return a(b.currentTarget).find("td, th").removeClass("selected")}),this.createMenu.on("mousedown","td, th",function(c){return function(d){var e,f,g,h,i;return c.wrapper.removeClass("menu-on"),c.editor.inputManager.focused?(f=a(d.currentTarget),g=f.parent(),h=g.find("td").index(f)+1,i=g.prevAll("tr").length+1,g.parent().is("tbody")&&(i+=1),b=c.createTable(i,h,!0),e=c.editor.selection.blockNodes().last(),c.editor.util.isEmptyNode(e)?e.replaceWith(b):e.after(b),c.decorate(b),c.editor.selection.setRangeAtStartOf(b.find("th:first")), c.editor.trigger("valuechanged"),!1):void 0}}(this))},c.prototype.createTable=function(b,c,d){var e,f,g,h,i,j,k,l,m,n,o;for(e=a("<table/>"),h=a("<thead/>").appendTo(e),f=a("<tbody/>").appendTo(e),m=k=0,n=b;n>=0?n>k:k>n;m=n>=0?++k:--k)for(i=a("<tr/>"),i.appendTo(0===m?h:f),j=l=0,o=c;o>=0?o>l:l>o;j=o>=0?++l:--l)g=a(0===m?"<th/>":"<td/>").appendTo(i),d&&g.append(this.editor.util.phBr);return e},c.prototype.refreshTableWidth=function(b){var c,d;return d=b.width(),c=b.find("col"),b.find("thead tr th").each(function(b,e){var f;return f=c.eq(b),f.attr("width",a(e).outerWidth()/d*100+"%")})},c.prototype.setActive=function(a){return c.__super__.setActive.call(this,a),a?(this.createMenu.hide(),this.editMenu.show()):(this.createMenu.show(),this.editMenu.hide())},c.prototype._changeCellTag=function(b,c){return b.find("td, th").each(function(b,d){var e;return e=a(d),e.replaceWith("<"+c+">"+e.html()+"</"+c+">")})},c.prototype.deleteRow=function(a){var b,c,d;return c=a.parent("tr"),c.closest("table").find("tr").length<1?this.deleteTable(a):(b=this._nextRow(c),b.length>0||(b=this._prevRow(c)),d=c.find("td, th").index(a),c.parent().is("thead")&&(b.appendTo(c.parent()),this._changeCellTag(b,"th")),c.remove(),this.editor.selection.setRangeAtEndOf(b.find("td, th").eq(d)))},c.prototype.insertRow=function(b,c){var d,e,f,g,h,i,j,k,l;for(null==c&&(c="after"),f=b.parent("tr"),e=f.closest("table"),h=0,e.find("tr").each(function(b,c){return h=Math.max(h,a(c).find("td").length)}),j=f.find("td, th").index(b),d=a("<tr/>"),g="td","after"===c&&f.parent().is("thead")?f.parent().next("tbody").prepend(d):"before"===c&&f.parent().is("thead")?(f.before(d),f.parent().next("tbody").prepend(f),this._changeCellTag(f,"td"),g="th"):f[c](d),i=k=1,l=h;l>=1?l>=k:k>=l;i=l>=1?++k:--k)a("<"+g+"/>").append(this.editor.util.phBr).appendTo(d);return this.editor.selection.setRangeAtStartOf(d.find("td, th").eq(j))},c.prototype.deleteCol=function(b){var c,d,e,f,g,h;return e=b.parent("tr"),h=e.closest("table").find("tr").length<2,g=b.siblings("td, th").length<1,h&&g?this.deleteTable(b):(f=e.find("td, th").index(b),c=b.next("td, th"),c.length>0||(c=e.prev("td, th")),d=e.closest("table"),d.find("col").eq(f).remove(),d.find("tr").each(function(b,c){return a(c).find("td, th").eq(f).remove()}),this.refreshTableWidth(d),this.editor.selection.setRangeAtEndOf(c))},c.prototype.insertCol=function(b,c){var d,e,f,g,h,i,j,k;return null==c&&(c="after"),h=b.parent("tr"),i=h.find("td, th").index(b),g=b.closest("table"),d=g.find("col").eq(i),g.find("tr").each(function(b){return function(d,e){var f,g;return g=a(e).parent().is("thead")?"th":"td",f=a("<"+g+"/>").append(b.editor.util.phBr),a(e).find("td, th").eq(i)[c](f)}}(this)),e=a("<col/>"),d[c](e),j=g.width(),k=Math.max(parseFloat(d.attr("width"))/2,50/j*100),d.attr("width",k+"%"),e.attr("width",k+"%"),this.refreshTableWidth(g),f="after"===c?b.next("td, th"):b.prev("td, th"),this.editor.selection.setRangeAtStartOf(f)},c.prototype.deleteTable=function(a){var b,c;return c=a.closest(".simditor-table"),b=c.next("p"),c.remove(),b.length>0?this.editor.selection.setRangeAtStartOf(b):void 0},c.prototype.command=function(a){var b;if(b=this.editor.selection.containerNode().closest("td, th"),b.length>0){if("deleteRow"===a)this.deleteRow(b);else if("insertRowAbove"===a)this.insertRow(b,"before");else if("insertRowBelow"===a)this.insertRow(b);else if("deleteCol"===a)this.deleteCol(b);else if("insertColLeft"===a)this.insertCol(b,"before");else if("insertColRight"===a)this.insertCol(b);else{if("deleteTable"!==a)return;this.deleteTable(b)}return this.editor.trigger("valuechanged")}},c}(h),D.Toolbar.addButton(F),E=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="strikethrough",c.prototype.icon="strikethrough",c.prototype.htmlTag="strike",c.prototype.disableTag="pre",c.prototype._activeStatus=function(){var a;return a=document.queryCommandState("strikethrough")===!0,this.setActive(a),this.active},c.prototype.command=function(){return document.execCommand("strikethrough"),this.editor.util.support.oninput||this.editor.trigger("valuechanged"),a(document).trigger("selectionchange")},c}(h),D.Toolbar.addButton(E),e=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return M(b,a),b.prototype.name="alignment",b.prototype.icon="align-left",b.prototype.htmlTag="p, h1, h2, h3, h4, td, th",b.prototype._init=function(){return this.menu=[{name:"left",text:this._t("alignLeft"),icon:"align-left",param:"left"},{name:"center",text:this._t("alignCenter"),icon:"align-center",param:"center"},{name:"right",text:this._t("alignRight"),icon:"align-right",param:"right"}],b.__super__._init.call(this)},b.prototype.setActive=function(a,c){return null==c&&(c="left"),"left"!==c&&"center"!==c&&"right"!==c&&(c="left"),"left"===c?b.__super__.setActive.call(this,!1):b.__super__.setActive.call(this,a),this.el.removeClass("align-left align-center align-right"),a&&this.el.addClass("align-"+c),this.setIcon("align-"+c),this.menuEl.find(".menu-item").show().end().find(".menu-item-"+c).hide()},b.prototype._status=function(){return this.nodes=this.editor.selection.nodes().filter(this.htmlTag),this.nodes.length<1?(this.setDisabled(!0),this.setActive(!1)):(this.setDisabled(!1),this.setActive(!0,this.nodes.first().css("text-align")))},b.prototype.command=function(a){if("left"!==a&&"center"!==a&&"right"!==a)throw new Error("simditor alignment button: invalid align "+a);return this.nodes.css({"text-align":"left"===a?"":a}),this.editor.trigger("valuechanged"),this.editor.inputManager.throttledSelectionChanged()},b}(h),D.Toolbar.addButton(e),D});(function(root,factory){if(typeof define==="function"&&define.amd){define("simditor-checklist",["jquery","simditor"],function(a0,b1){return(root["ChecklistButton"]=factory(a0,b1))})}else{if(typeof exports==="object"){module.exports=factory(require("jquery"),require("simditor"))}else{root["ChecklistButton"]=factory(jQuery,Simditor)}}}(this,function($,Simditor){var ChecklistButton,extend=function(child,parent){for(var key in parent){if(hasProp.call(parent,key)){child[key]=parent[key]}}function ctor(){this.constructor=child}ctor.prototype=parent.prototype;child.prototype=new ctor();child.__super__=parent.prototype;return child},hasProp={}.hasOwnProperty,slice=[].slice;ChecklistButton=(function(superClass){extend(ChecklistButton,superClass);ChecklistButton.prototype.type="ul.simditor-checklist";ChecklistButton.prototype.name="checklist";ChecklistButton.prototype.icon="checklist";ChecklistButton.prototype.htmlTag="li";ChecklistButton.prototype.disableTag="pre, table";function ChecklistButton(){var args;args=1<=arguments.length?slice.call(arguments,0):[];ChecklistButton.__super__.constructor.apply(this,args);if("input"&&$.inArray("input",this.editor.formatter._allowedTags)<0){this.editor.formatter._allowedTags.push("input")}$.extend(this.editor.formatter._allowedAttributes,{input:["type","checked"]})}ChecklistButton.prototype._init=function(){ChecklistButton.__super__._init.call(this);this.editor.on("decorate",(function(_this){return function(e,$el){return $el.find("ul > li input[type=checkbox]").each(function(i,checkbox){return _this._decorate($(checkbox))})}})(this));this.editor.on("undecorate",(function(_this){return function(e,$el){return $el.find(".simditor-checklist > li").each(function(i,node){return _this._undecorate($(node))})}})(this));this.editor.body.on("click",".simditor-checklist > li",(function(_this){return function(e){var $node,range;e.preventDefault();e.stopPropagation();$node=$(e.currentTarget);range=document.createRange();_this.editor.selection.save();range.setStart($node[0],0);range.setEnd($node[0],_this.editor.util.getNodeLength($node[0]));_this.editor.selection.range(range);document.execCommand("strikethrough");$node.attr("checked",!$node.attr("checked"));_this.editor.selection.restore();return _this.editor.trigger("valuechanged")}})(this));return this.editor.keystroke.add("13","li",(function(_this){return function(e,$node){return setTimeout(function(){var $li;$li=_this.editor.selection.blockNodes().last().next();if($li.length){$li[0].removeAttribute("checked");if(document.queryCommandState("strikethrough")){return document.execCommand("strikethrough")}}},0)}})(this))};ChecklistButton.prototype._status=function(){var $node;ChecklistButton.__super__._status.call(this);$node=this.editor.selection.rootNodes();if($node.is(".simditor-checklist")){this.editor.toolbar.findButton("ul").setActive(false);this.editor.toolbar.findButton("ol").setActive(false);this.editor.toolbar.findButton("ul").setDisabled(true);return this.editor.toolbar.findButton("ol").setDisabled(true)}else{return this.editor.toolbar.findButton("checklist").setActive(false)}};ChecklistButton.prototype.command=function(param){var $list,$rootNodes;$rootNodes=this.editor.selection.blockNodes();this.editor.selection.save();$list=null;$rootNodes.each((function(_this){return function(i,node){var $node;$node=$(node);if($node.is("blockquote, li")||$node.is(_this.disableTag)||!$.contains(document,node)){return}if($node.is(".simditor-checklist")){$node.children("li").each(function(i,li){var $childList,$li;$li=$(li);$childList=$li.children("ul, ol").insertAfter($node);return $("<p/>").append($(li).html()||_this.editor.util.phBr).insertBefore($node)});return $node.remove()}else{if($node.is("ul, ol")){return $('<ul class="simditor-checklist" />').append($node.contents()).replaceAll($node)}else{if($list&&$node.prev().is($list)){$("<li/>").append($node.html()||_this.editor.util.phBr).appendTo($list);return $node.remove()}else{$list=$('<ul class="simditor-checklist"><li></li></ul>');$list.find("li").append($node.html()||_this.editor.util.phBr);return $list.replaceAll($node)}}}}})(this));this.editor.selection.restore();return this.editor.trigger("valuechanged")};ChecklistButton.prototype._decorate=function($checkbox){var $node,checked;checked=!!$checkbox.attr("checked");$node=$checkbox.closest("li");$checkbox.remove();$node.attr("checked",checked);return $node.closest("ul").addClass("simditor-checklist")};ChecklistButton.prototype._undecorate=function($node){var $checkbox,checked;checked=!!$node.attr("checked");$checkbox=$('<input type="checkbox">').attr("checked",checked);return $node.attr("checked","").prepend($checkbox)};return ChecklistButton})(Simditor.Button);Simditor.Toolbar.addButton(ChecklistButton);return ChecklistButton})); get_query_value · 1ae491b9f1 - Gogs: Go Git Service

get_query_value

Brightcells лет %!s(int64=8): %!d(string=назад)
Родитель
Сommit
1ae491b9f1
2 измененных файлов с 5 добавлено и 3 удалено
  1. 4 3
      page/screen_views.py
  2. 1 0
      requirements_dj.txt

+ 4 - 3
page/screen_views.py

@@ -3,6 +3,7 @@
3 3
 import shortuuid
4 4
 from django.conf import settings
5 5
 from django_logit import logit
6
+from django_query import get_query_value
6 7
 from django_response import response
7 8
 from json_render import json_render
8 9
 
@@ -39,7 +40,7 @@ def screen_admin_oauth(request):
39 40
 
40 41
 @logit
41 42
 def screen_admin_loginqr(request):
42
-    brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID)
43
+    brand_id = get_query_value(request, 'brand_id', settings.KODO_DEFAULT_BRAND_ID)
43 44
 
44 45
     token = shortuuid.uuid()
45 46
 
@@ -70,8 +71,8 @@ def screen_admin_login(request):
70 71
 
71 72
 @logit
72 73
 def screen_admin_loginrst(request):
73
-    brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID)
74
-    token = request.POST.get('token', '')
74
+    brand_id = get_query_value(request, 'brand_id', settings.KODO_DEFAULT_BRAND_ID)
75
+    token = get_query_value(request, 'token', '')
75 76
 
76 77
     admin_login_key = SCREEN_ADMIN_LOGIN % (brand_id, token)
77 78
 

+ 1 - 0
requirements_dj.txt

@@ -13,6 +13,7 @@ django-mobi==0.1.7
13 13
 django-models-ext==1.1.8
14 14
 django-multidomain==1.1.4
15 15
 django-paginator2==1.0.4
16
+django-query==1.0.3
16 17
 django-redis-connector==1.0.1
17 18
 django-response==1.1.1
18 19
 django-rlog==1.0.7