diff --git a/app/controllers/api/ApiNoteController.go b/app/controllers/api/ApiNoteController.go index 09439b5..d251494 100644 --- a/app/controllers/api/ApiNoteController.go +++ b/app/controllers/api/ApiNoteController.go @@ -8,8 +8,9 @@ import ( "gopkg.in/mgo.v2/bson" "os" "os/exec" - "strings" + // "strings" "time" + "regexp" // "github.com/leanote/leanote/app/types" // "io/ioutil" // "fmt" @@ -158,11 +159,31 @@ func (c ApiNote) fixPostNotecontent(noteOrContent *info.ApiNote) { if noteOrContent.Content == "" { return } + files := noteOrContent.Files if files != nil && len(files) > 0 { for _, file := range files { if file.LocalFileId != "" { - noteOrContent.Content = strings.Replace(noteOrContent.Content, "fileId="+file.LocalFileId, "fileId="+file.FileId, -1) + LogJ(file) + if !file.IsAttach { + reg, _ := regexp.Compile(`"https*://[^/]*?/api/file/getImage\?fileId=`+file.LocalFileId) + // Log(reg) + noteOrContent.Content = reg.ReplaceAllString(noteOrContent.Content, `"/api/file/getImage?fileId=`+file.FileId) + + // // "http://a.com/api/file/getImage?fileId=localId" => /api/file/getImage?fileId=serverId + // noteOrContent.Content = strings.Replace(noteOrContent.Content, + // baseUrl + "/api/file/getImage?fileId="+file.LocalFileId, + // "/api/file/getImage?fileId="+file.FileId, -1) + } else { + reg, _ := regexp.Compile(`"https*://[^/]*?/api/file/getAttach\?fileId=`+file.LocalFileId) + Log(reg) + noteOrContent.Content = reg.ReplaceAllString(noteOrContent.Content, `"/api/file/getAttach?fileId=`+file.FileId) + /* + noteOrContent.Content = strings.Replace(noteOrContent.Content, + baseUrl + "/api/file/getAttach?fileId="+file.LocalFileId, + "/api/file/getAttach?fileId="+file.FileId, -1) + */ + } } } } @@ -352,6 +373,7 @@ func (c ApiNote) UpdateNote(noteOrContent info.ApiNote) revel.Result { Log("conflict") return c.RenderJson(re) } + Log("没有冲突") // 如果传了files // TODO 测试 diff --git a/app/service/AttachService.go b/app/service/AttachService.go index 31d1c0c..f3769ac 100644 --- a/app/service/AttachService.go +++ b/app/service/AttachService.go @@ -119,6 +119,7 @@ func (this *AttachService) DeleteAllAttachs(noteId, userId string) bool { } // delete attach +// 删除附件为什么要incrNoteUsn ? 因为可能没有内容要修改的 func (this *AttachService) DeleteAttach(attachId, userId string) (bool, string) { attach := info.Attach{} db.Get(db.Attachs, attachId, &attach) diff --git a/app/service/NoteService.go b/app/service/NoteService.go index ef22248..6e8e449 100644 --- a/app/service/NoteService.go +++ b/app/service/NoteService.go @@ -415,9 +415,15 @@ func (this *NoteService) UpdateNote(updatedUserId, noteId string, needUpdate bso } } + /* + // 这里不再判断, 因为controller已经判断了, 删除附件会新增, 所以不用判断 if usn > 0 && note.Usn != usn { + Log("有冲突!!") + Log(note.Usn) + Log(usn) return false, "conflict", 0 } + */ // 是否已自定义 if note.IsBlog && note.HasSelfDefined { @@ -1017,6 +1023,8 @@ func (this *NoteService) FixContentBad(content string, isMarkdown bool) string { return content } +// 得到笔记的内容, 此时将笔记内的链接转成标准的Leanote Url +// 将笔记的图片, 附件链接转换成 site.url/file/getImage?fileId=xxx, site.url/file/getAttach?fileId=xxxx // 性能更好, 5倍的差距 func (this *NoteService) FixContent(content string, isMarkdown bool) string { baseUrl := configService.GetSiteUrl() @@ -1029,12 +1037,19 @@ func (this *NoteService) FixContent(content string, isMarkdown bool) string { } else { baseUrlPattern = strings.Replace(baseUrl, "http://", "https*://", 1) } + baseUrlPattern = "(?:" + baseUrlPattern + ")*" + + Log(baseUrlPattern) patterns := []map[string]string{ + map[string]string{"src": "src", "middle": "/api/file/getImage", "param": "fileId", "to": "getImage?fileId="}, map[string]string{"src": "src", "middle": "/file/outputImage", "param": "fileId", "to": "getImage?fileId="}, + map[string]string{"src": "href", "middle": "/attach/download", "param": "attachId", "to": "getAttach?fileId="}, + map[string]string{"src": "href", "middle": "/api/file/getAtach", "param": "fileId", "to": "getAttach?fileId="}, + // 该链接已失效, 不再支持 - map[string]string{"src": "href", "middle": "/attach/downloadAll", "param": "noteId", "to": "getAllAttachs?noteId="}, + // map[string]string{"src": "href", "middle": "/attach/downloadAll", "param": "noteId", "to": "getAllAttachs?noteId="}, } for _, eachPattern := range patterns { @@ -1056,6 +1071,8 @@ func (this *NoteService) FixContent(content string, isMarkdown bool) string { reg2, _ = regexp.Compile("]+?)(" + eachPattern["src"] + `=['"]*` + baseUrlPattern + eachPattern["middle"] + `\?` + eachPattern["param"] + `=([a-z0-9A-Z]{24})["']*)[^>]*>`) } + Log(reg2) + content = reg.ReplaceAllStringFunc(content, func(str string) string { // str=这样的 // diff --git a/app/tests/note_content_test.go b/app/tests/note_content_test.go new file mode 100644 index 0000000..d7234a3 --- /dev/null +++ b/app/tests/note_content_test.go @@ -0,0 +1,32 @@ +package tests + +import ( + "github.com/leanote/leanote/app/db" + "github.com/revel/revel" + "testing" + // . "github.com/leanote/leanote/app/lea" + "github.com/leanote/leanote/app/service" + // "regexp" + // "gopkg.in/mgo.v2" + // "fmt" + // "strings" +) + + +// 可在server端调试 + +func init() { + revel.Init("dev", "github.com/leanote/leanote", "/Users/life/Documents/Go/package_base/src") + db.Init("mongodb://localhost:27017/leanote", "leanote") + service.InitService() + service.ConfigS.InitGlobalConfigs() +} + +func TestApiFixNoteContent2(t *testing.T) { + note2 := service.NoteS.GetNote("585df83771c1b17e8a000000", "585df81199c37b6176000004") + note := service.NoteS.GetNoteContent("585df83771c1b17e8a000000", "585df81199c37b6176000004") + contentFixed := service.NoteS.FixContent(note.Content, false) + t.Log(note2.Title) + t.Log(note.Content) + t.Log(contentFixed) +} \ No newline at end of file diff --git a/app/tests/reg_test.go b/app/tests/reg_test.go new file mode 100644 index 0000000..706b0c8 --- /dev/null +++ b/app/tests/reg_test.go @@ -0,0 +1,26 @@ +package tests + +import ( + // "github.com/leanote/leanote/app/db" + "testing" + // . "github.com/leanote/leanote/app/lea" + // "github.com/leanote/leanote/app/service" + // "gopkg.in/mgo.v2" + // "fmt" + "regexp" +) + + +// 测试登录 +func TestReg(t *testing.T) { + a := `proxy.go` + reg, _ := regexp.Compile(`"https*://[^/]*?/api/file/getAttach\?fileId=585e0e9c270a35609300000c`) + + a2 := reg.ReplaceAllString(a, `"`) + t.Log(a2) +} + + + + + diff --git a/app/views/album/index.html b/app/views/album/index.html index a800bce..226313e 100644 --- a/app/views/album/index.html +++ b/app/views/album/index.html @@ -161,6 +161,6 @@ var UrlPrefix = '{{.siteUrl}}'; --> - + \ No newline at end of file diff --git a/bin/release.sh b/bin/release.sh index ca054ad..560ecb0 100644 --- a/bin/release.sh +++ b/bin/release.sh @@ -9,7 +9,7 @@ SP=$(cd "$(dirname "$0")"; pwd) tmp="/Users/life/Desktop/leanote_release" # version -V="v2.0" +V="v2.1" ##================================= # 1. 先build 成 3个平台, 2种bit = 6种 diff --git a/public/album/js/main.all.js b/public/album/js/main.all.js index f09fd10..4e1afdc 100644 --- a/public/album/js/main.all.js +++ b/public/album/js/main.all.js @@ -4,4 +4,4 @@ return c(e,"previousSibling")},nextAll:function(e){return se.dir(e,"nextSibling" if("undefined"==typeof jQuery)throw new Error("Bootstrap requires jQuery");+function(t){"use strict";function e(){var t=document.createElement("bootstrap"),e={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var i in e)if(void 0!==t.style[i])return{end:e[i]}}t.fn.emulateTransitionEnd=function(e){var i=!1,o=this;t(this).one(t.support.transition.end,function(){i=!0});var n=function(){i||t(o).trigger(t.support.transition.end)};return setTimeout(n,e),this},t(function(){t.support.transition=e()})}(jQuery),+function(t){"use strict";var e='[data-dismiss="alert"]',i=function(i){t(i).on("click",e,this.close)};i.prototype.close=function(e){function i(){s.trigger("closed.bs.alert").remove()}var o=t(this),n=o.attr("data-target");n||(n=o.attr("href"),n=n&&n.replace(/.*(?=#[^\s]*$)/,""));var s=t(n);e&&e.preventDefault(),s.length||(s=o.hasClass("alert")?o:o.parent()),s.trigger(e=t.Event("close.bs.alert")),e.isDefaultPrevented()||(s.removeClass("in"),t.support.transition&&s.hasClass("fade")?s.one(t.support.transition.end,i).emulateTransitionEnd(150):i())};var o=t.fn.alert;t.fn.alert=function(e){return this.each(function(){var o=t(this),n=o.data("bs.alert");n||o.data("bs.alert",n=new i(this)),"string"==typeof e&&n[e].call(o)})},t.fn.alert.Constructor=i,t.fn.alert.noConflict=function(){return t.fn.alert=o,this},t(document).on("click.bs.alert.data-api",e,i.prototype.close)}(jQuery),+function(t){"use strict";var e=function(i,o){this.$element=t(i),this.options=t.extend({},e.DEFAULTS,o)};e.DEFAULTS={loadingText:"loading..."},e.prototype.setState=function(t){var e="disabled",i=this.$element,o=i.is("input")?"val":"html",n=i.data();t+="Text",n.resetText||i.data("resetText",i[o]()),i[o](n[t]||this.options[t]),setTimeout(function(){"loadingText"==t?i.addClass(e).attr(e,e):i.removeClass(e).removeAttr(e)},0)},e.prototype.toggle=function(){var t=this.$element.closest('[data-toggle="buttons"]');if(t.length){var e=this.$element.find("input").prop("checked",!this.$element.hasClass("active")).trigger("change");"radio"===e.prop("type")&&t.find(".active").removeClass("active")}this.$element.toggleClass("active")};var i=t.fn.button;t.fn.button=function(i){return this.each(function(){var o=t(this),n=o.data("bs.button"),s="object"==typeof i&&i;n||o.data("bs.button",n=new e(this,s)),"toggle"==i?n.toggle():i&&n.setState(i)})},t.fn.button.Constructor=e,t.fn.button.noConflict=function(){return t.fn.button=i,this},t(document).on("click.bs.button.data-api","[data-toggle^=button]",function(e){var i=t(e.target);i.hasClass("btn")||(i=i.closest(".btn")),i.button("toggle"),e.preventDefault()})}(jQuery),+function(t){"use strict";var e=function(e,i){this.$element=t(e),this.$indicators=this.$element.find(".carousel-indicators"),this.options=i,this.paused=this.sliding=this.interval=this.$active=this.$items=null,"hover"==this.options.pause&&this.$element.on("mouseenter",t.proxy(this.pause,this)).on("mouseleave",t.proxy(this.cycle,this))};e.DEFAULTS={interval:5e3,pause:"hover",wrap:!0},e.prototype.cycle=function(e){return e||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(t.proxy(this.next,this),this.options.interval)),this},e.prototype.getActiveIndex=function(){return this.$active=this.$element.find(".item.active"),this.$items=this.$active.parent().children(),this.$items.index(this.$active)},e.prototype.to=function(e){var i=this,o=this.getActiveIndex();return e>this.$items.length-1||0>e?void 0:this.sliding?this.$element.one("slid",function(){i.to(e)}):o==e?this.pause().cycle():this.slide(e>o?"next":"prev",t(this.$items[e]))},e.prototype.pause=function(e){return e||(this.paused=!0),this.$element.find(".next, .prev").length&&t.support.transition.end&&(this.$element.trigger(t.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},e.prototype.next=function(){return this.sliding?void 0:this.slide("next")},e.prototype.prev=function(){return this.sliding?void 0:this.slide("prev")},e.prototype.slide=function(e,i){var o=this.$element.find(".item.active"),n=i||o[e](),s=this.interval,a="next"==e?"left":"right",r="next"==e?"first":"last",l=this;if(!n.length){if(!this.options.wrap)return;n=this.$element.find(".item")[r]()}this.sliding=!0,s&&this.pause();var h=t.Event("slide.bs.carousel",{relatedTarget:n[0],direction:a});if(!n.hasClass("active")){if(this.$indicators.length&&(this.$indicators.find(".active").removeClass("active"),this.$element.one("slid",function(){var e=t(l.$indicators.children()[l.getActiveIndex()]);e&&e.addClass("active")})),t.support.transition&&this.$element.hasClass("slide")){if(this.$element.trigger(h),h.isDefaultPrevented())return;n.addClass(e),n[0].offsetWidth,o.addClass(a),n.addClass(a),o.one(t.support.transition.end,function(){n.removeClass([e,a].join(" ")).addClass("active"),o.removeClass(["active",a].join(" ")),l.sliding=!1,setTimeout(function(){l.$element.trigger("slid")},0)}).emulateTransitionEnd(600)}else{if(this.$element.trigger(h),h.isDefaultPrevented())return;o.removeClass("active"),n.addClass("active"),this.sliding=!1,this.$element.trigger("slid")}return s&&this.cycle(),this}};var i=t.fn.carousel;t.fn.carousel=function(i){return this.each(function(){var o=t(this),n=o.data("bs.carousel"),s=t.extend({},e.DEFAULTS,o.data(),"object"==typeof i&&i),a="string"==typeof i?i:s.slide;n||o.data("bs.carousel",n=new e(this,s)),"number"==typeof i?n.to(i):a?n[a]():s.interval&&n.pause().cycle()})},t.fn.carousel.Constructor=e,t.fn.carousel.noConflict=function(){return t.fn.carousel=i,this},t(document).on("click.bs.carousel.data-api","[data-slide], [data-slide-to]",function(e){var i,o=t(this),n=t(o.attr("data-target")||(i=o.attr("href"))&&i.replace(/.*(?=#[^\s]+$)/,"")),s=t.extend({},n.data(),o.data()),a=o.attr("data-slide-to");a&&(s.interval=!1),n.carousel(s),(a=o.attr("data-slide-to"))&&n.data("bs.carousel").to(a),e.preventDefault()}),t(window).on("load",function(){t('[data-ride="carousel"]').each(function(){var e=t(this);e.carousel(e.data())})})}(jQuery),+function(t){"use strict";var e=function(i,o){this.$element=t(i),this.options=t.extend({},e.DEFAULTS,o),this.transitioning=null,this.options.parent&&(this.$parent=t(this.options.parent)),this.options.toggle&&this.toggle()};e.DEFAULTS={toggle:!0},e.prototype.dimension=function(){var t=this.$element.hasClass("width");return t?"width":"height"},e.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var e=t.Event("show.bs.collapse");if(this.$element.trigger(e),!e.isDefaultPrevented()){var i=this.$parent&&this.$parent.find("> .panel > .in");if(i&&i.length){var o=i.data("bs.collapse");if(o&&o.transitioning)return;i.collapse("hide"),o||i.data("bs.collapse",null)}var n=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[n](0),this.transitioning=1;var s=function(){this.$element.removeClass("collapsing").addClass("in")[n]("auto"),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!t.support.transition)return s.call(this);var a=t.camelCase(["scroll",n].join("-"));this.$element.one(t.support.transition.end,t.proxy(s,this)).emulateTransitionEnd(350)[n](this.$element[0][a])}}},e.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var e=t.Event("hide.bs.collapse");if(this.$element.trigger(e),!e.isDefaultPrevented()){var i=this.dimension();this.$element[i](this.$element[i]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse").removeClass("in"),this.transitioning=1;var o=function(){this.transitioning=0,this.$element.trigger("hidden.bs.collapse").removeClass("collapsing").addClass("collapse")};return t.support.transition?void this.$element[i](0).one(t.support.transition.end,t.proxy(o,this)).emulateTransitionEnd(350):o.call(this)}}},e.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()};var i=t.fn.collapse;t.fn.collapse=function(i){return this.each(function(){var o=t(this),n=o.data("bs.collapse"),s=t.extend({},e.DEFAULTS,o.data(),"object"==typeof i&&i);n||o.data("bs.collapse",n=new e(this,s)),"string"==typeof i&&n[i]()})},t.fn.collapse.Constructor=e,t.fn.collapse.noConflict=function(){return t.fn.collapse=i,this},t(document).on("click.bs.collapse.data-api","[data-toggle=collapse]",function(e){var i,o=t(this),n=o.attr("data-target")||e.preventDefault()||(i=o.attr("href"))&&i.replace(/.*(?=#[^\s]+$)/,""),s=t(n),a=s.data("bs.collapse"),r=a?"toggle":o.data(),l=o.attr("data-parent"),h=l&&t(l);a&&a.transitioning||(h&&h.find('[data-toggle=collapse][data-parent="'+l+'"]').not(o).addClass("collapsed"),o[s.hasClass("in")?"addClass":"removeClass"]("collapsed")),s.collapse(r)})}(jQuery),+function(t){"use strict";function e(){t(o).remove(),t(n).each(function(e){var o=i(t(this));o.hasClass("open")&&(o.trigger(e=t.Event("hide.bs.dropdown")),e.isDefaultPrevented()||o.removeClass("open").trigger("hidden.bs.dropdown"))})}function i(e){var i=e.attr("data-target");i||(i=e.attr("href"),i=i&&/#/.test(i)&&i.replace(/.*(?=#[^\s]*$)/,""));var o=i&&t(i);return o&&o.length?o:e.parent()}var o=".dropdown-backdrop",n="[data-toggle=dropdown]",s=function(e){t(e).on("click.bs.dropdown",this.toggle)};s.prototype.toggle=function(o){var n=t(this);if(!n.is(".disabled, :disabled")){var s=i(n),a=s.hasClass("open");if(e(),!a){if("ontouchstart"in document.documentElement&&!s.closest(".navbar-nav").length&&t(''}),e.prototype=t.extend({},t.fn.tooltip.Constructor.prototype),e.prototype.constructor=e,e.prototype.getDefaults=function(){return e.DEFAULTS},e.prototype.setContent=function(){var t=this.tip(),e=this.getTitle(),i=this.getContent();t.find(".popover-title")[this.options.html?"html":"text"](e),t.find(".popover-content")[this.options.html?"html":"text"](i),t.removeClass("fade top bottom left right in"),t.find(".popover-title").html()||t.find(".popover-title").hide()},e.prototype.hasContent=function(){return this.getTitle()||this.getContent()},e.prototype.getContent=function(){var t=this.$element,e=this.options;return t.attr("data-content")||("function"==typeof e.content?e.content.call(t[0]):e.content)},e.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")},e.prototype.tip=function(){return this.$tip||(this.$tip=t(this.options.template)),this.$tip};var i=t.fn.popover;t.fn.popover=function(i){return this.each(function(){var o=t(this),n=o.data("bs.popover"),s="object"==typeof i&&i;n||o.data("bs.popover",n=new e(this,s)),"string"==typeof i&&n[i]()})},t.fn.popover.Constructor=e,t.fn.popover.noConflict=function(){return t.fn.popover=i,this}}(jQuery),+function(t){"use strict";function e(i,o){var n,s=t.proxy(this.process,this);this.$element=t(t(i).is("body")?window:i),this.$body=t("body"),this.$scrollElement=this.$element.on("scroll.bs.scroll-spy.data-api",s),this.options=t.extend({},e.DEFAULTS,o),this.selector=(this.options.target||(n=t(i).attr("href"))&&n.replace(/.*(?=#[^\s]+$)/,"")||"")+" .nav li > a",this.offsets=t([]),this.targets=t([]),this.activeTarget=null,this.refresh(),this.process()}e.DEFAULTS={offset:10},e.prototype.refresh=function(){var e=this.$element[0]==window?"offset":"position";this.offsets=t([]),this.targets=t([]);var i=this;this.$body.find(this.selector).map(function(){var o=t(this),n=o.data("target")||o.attr("href"),s=/^#\w/.test(n)&&t(n);return s&&s.length&&[[s[e]().top+(!t.isWindow(i.$scrollElement.get(0))&&i.$scrollElement.scrollTop()),n]]||null}).sort(function(t,e){return t[0]-e[0]}).each(function(){i.offsets.push(this[0]),i.targets.push(this[1])})},e.prototype.process=function(){var t,e=this.$scrollElement.scrollTop()+this.options.offset,i=this.$scrollElement[0].scrollHeight||this.$body[0].scrollHeight,o=i-this.$scrollElement.height(),n=this.offsets,s=this.targets,a=this.activeTarget;if(e>=o)return a!=(t=s.last()[0])&&this.activate(t);for(t=n.length;t--;)a!=s[t]&&e>=n[t]&&(!n[t+1]||e<=n[t+1])&&this.activate(s[t])},e.prototype.activate=function(e){this.activeTarget=e,t(this.selector).parents(".active").removeClass("active");var i=this.selector+'[data-target="'+e+'"],'+this.selector+'[href="'+e+'"]',o=t(i).parents("li").addClass("active");o.parent(".dropdown-menu").length&&(o=o.closest("li.dropdown").addClass("active")),o.trigger("activate")};var i=t.fn.scrollspy;t.fn.scrollspy=function(i){return this.each(function(){var o=t(this),n=o.data("bs.scrollspy"),s="object"==typeof i&&i;n||o.data("bs.scrollspy",n=new e(this,s)),"string"==typeof i&&n[i]()})},t.fn.scrollspy.Constructor=e,t.fn.scrollspy.noConflict=function(){return t.fn.scrollspy=i,this},t(window).on("load",function(){t('[data-spy="scroll"]').each(function(){var e=t(this);e.scrollspy(e.data())})})}(jQuery),+function(t){"use strict";var e=function(e){this.element=t(e)};e.prototype.show=function(){var e=this.element,i=e.closest("ul:not(.dropdown-menu)"),o=e.data("target");if(o||(o=e.attr("href"),o=o&&o.replace(/.*(?=#[^\s]*$)/,"")),!e.parent("li").hasClass("active")){var n=i.find(".active:last a")[0],s=t.Event("show.bs.tab",{relatedTarget:n});if(e.trigger(s),!s.isDefaultPrevented()){var a=t(o);this.activate(e.parent("li"),i),this.activate(a,a.parent(),function(){e.trigger({type:"shown.bs.tab",relatedTarget:n})})}}},e.prototype.activate=function(e,i,o){function n(){s.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),e.addClass("active"),a?(e[0].offsetWidth,e.addClass("in")):e.removeClass("fade"),e.parent(".dropdown-menu")&&e.closest("li.dropdown").addClass("active"),o&&o()}var s=i.find("> .active"),a=o&&t.support.transition&&s.hasClass("fade");a?s.one(t.support.transition.end,n).emulateTransitionEnd(150):n(),s.removeClass("in")};var i=t.fn.tab;t.fn.tab=function(i){return this.each(function(){var o=t(this),n=o.data("bs.tab");n||o.data("bs.tab",n=new e(this)),"string"==typeof i&&n[i]()})},t.fn.tab.Constructor=e,t.fn.tab.noConflict=function(){return t.fn.tab=i,this},t(document).on("click.bs.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(e){e.preventDefault(),t(this).tab("show")})}(jQuery),+function(t){"use strict";var e=function(i,o){this.options=t.extend({},e.DEFAULTS,o),this.$window=t(window).on("scroll.bs.affix.data-api",t.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",t.proxy(this.checkPositionWithEventLoop,this)),this.$element=t(i),this.affixed=this.unpin=null,this.checkPosition()};e.RESET="affix affix-top affix-bottom",e.DEFAULTS={offset:0},e.prototype.checkPositionWithEventLoop=function(){setTimeout(t.proxy(this.checkPosition,this),1)},e.prototype.checkPosition=function(){if(this.$element.is(":visible")){var i=t(document).height(),o=this.$window.scrollTop(),n=this.$element.offset(),s=this.options.offset,a=s.top,r=s.bottom;"object"!=typeof s&&(r=a=s),"function"==typeof a&&(a=s.top()),"function"==typeof r&&(r=s.bottom());var l=null!=this.unpin&&o+this.unpin<=n.top?!1:null!=r&&n.top+this.$element.height()>=i-r?"bottom":null!=a&&a>=o?"top":!1;this.affixed!==l&&(this.unpin&&this.$element.css("top",""),this.affixed=l,this.unpin="bottom"==l?n.top-o:null,this.$element.removeClass(e.RESET).addClass("affix"+(l?"-"+l:"")),"bottom"==l&&this.$element.offset({top:document.body.offsetHeight-r-this.$element.height()}))}};var i=t.fn.affix;t.fn.affix=function(i){return this.each(function(){var o=t(this),n=o.data("bs.affix"),s="object"==typeof i&&i;n||o.data("bs.affix",n=new e(this,s)),"string"==typeof i&&n[i]()})},t.fn.affix.Constructor=e,t.fn.affix.noConflict=function(){return t.fn.affix=i,this},t(window).on("load",function(){t('[data-spy="affix"]').each(function(){var e=t(this),i=e.data();i.offset=i.offset||{},i.offsetBottom&&(i.offset.bottom=i.offsetBottom),i.offsetTop&&(i.offset.top=i.offsetTop),e.affix(i)})})}(jQuery); !function(e){"use strict";e(window.jQuery)}(function(e){"use strict";var t=0;e.ajaxTransport("iframe",function(i){if(i.async){var n,r,o;return{send:function(s,a){n=e('
'),n.attr("accept-charset",i.formAcceptCharset),o=/\?/.test(i.url)?"&":"?","DELETE"===i.type?(i.url=i.url+o+"_method=DELETE",i.type="POST"):"PUT"===i.type?(i.url=i.url+o+"_method=PUT",i.type="POST"):"PATCH"===i.type&&(i.url=i.url+o+"_method=PATCH",i.type="POST"),r=e('').bind("load",function(){var t,o=e.isArray(i.paramName)?i.paramName:[i.paramName];r.unbind("load").bind("load",function(){var t;try{if(t=r.contents(),!t.length||!t[0].firstChild)throw new Error}catch(i){t=void 0}a(200,"success",{iframe:t}),e('').appendTo(n),n.remove()}),n.prop("target",r.prop("name")).prop("action",i.url).prop("method",i.type),i.formData&&e.each(i.formData,function(t,i){e('').prop("name",i.name).val(i.value).appendTo(n)}),i.fileInput&&i.fileInput.length&&"POST"===i.type&&(t=i.fileInput.clone(),i.fileInput.after(function(e){return t[e]}),i.paramName&&i.fileInput.each(function(t){e(this).prop("name",o[t]||i.paramName)}),n.append(i.fileInput).prop("enctype","multipart/form-data").prop("encoding","multipart/form-data")),n.submit(),t&&t.length&&i.fileInput.each(function(i,n){var r=e(t[i]);e(n).prop("name",r.prop("name")),r.replaceWith(n)})}),n.append(r).appendTo(document.body)},abort:function(){r&&r.unbind("load").prop("src","javascript".concat(":false;")),n&&n.remove()}}}}),e.ajaxSetup({converters:{"iframe text":function(t){return t&&e(t[0].body).text()},"iframe json":function(t){return t&&e.parseJSON(e(t[0].body).text())},"iframe html":function(t){return t&&e(t[0].body).html()},"iframe script":function(t){return t&&e.globalEval(e(t[0].body).text())}}})}),!function(e){e(jQuery)}(function(e,t){var i=0,n=Array.prototype.slice,r=e.cleanData;e.cleanData=function(t){for(var i,n=0;null!=(i=t[n]);n++)try{e(i).triggerHandler("remove")}catch(o){}r(t)},e.widget=function(t,i,n){var r,o,s,a,l={},p=t.split(".")[0];t=t.split(".")[1],r=p+"-"+t,n||(n=i,i=e.Widget),e.expr[":"][r.toLowerCase()]=function(t){return!!e.data(t,r)},e[p]=e[p]||{},o=e[p][t],s=e[p][t]=function(e,t){return this._createWidget?void(arguments.length&&this._createWidget(e,t)):new s(e,t)},e.extend(s,o,{version:n.version,_proto:e.extend({},n),_childConstructors:[]}),a=new i,a.options=e.widget.extend({},a.options),e.each(n,function(t,n){return e.isFunction(n)?void(l[t]=function(){var e=function(){return i.prototype[t].apply(this,arguments)},r=function(e){return i.prototype[t].apply(this,e)};return function(){var t,i=this._super,o=this._superApply;return this._super=e,this._superApply=r,t=n.apply(this,arguments),this._super=i,this._superApply=o,t}}()):void(l[t]=n)}),s.prototype=e.widget.extend(a,{widgetEventPrefix:o?a.widgetEventPrefix:t},l,{constructor:s,namespace:p,widgetName:t,widgetFullName:r}),o?(e.each(o._childConstructors,function(t,i){var n=i.prototype;e.widget(n.namespace+"."+n.widgetName,s,i._proto)}),delete o._childConstructors):i._childConstructors.push(s),e.widget.bridge(t,s)},e.widget.extend=function(i){for(var r,o,s=n.call(arguments,1),a=0,l=s.length;l>a;a++)for(r in s[a])o=s[a][r],s[a].hasOwnProperty(r)&&o!==t&&(e.isPlainObject(o)?i[r]=e.isPlainObject(i[r])?e.widget.extend({},i[r],o):e.widget.extend({},o):i[r]=o);return i},e.widget.bridge=function(i,r){var o=r.prototype.widgetFullName||i;e.fn[i]=function(s){var a="string"==typeof s,l=n.call(arguments,1),p=this;return s=!a&&l.length?e.widget.extend.apply(null,[s].concat(l)):s,a?this.each(function(){var n,r=e.data(this,o);return r?e.isFunction(r[s])&&"_"!==s.charAt(0)?(n=r[s].apply(r,l),n!==r&&n!==t?(p=n&&n.jquery?p.pushStack(n.get()):n,!1):void 0):e.error("no such method '"+s+"' for "+i+" widget instance"):e.error("cannot call methods on "+i+" prior to initialization; attempted to call method '"+s+"'")}):this.each(function(){var t=e.data(this,o);t?t.option(s||{})._init():e.data(this,o,new r(s,this))}),p}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",options:{disabled:!1,create:null},_createWidget:function(t,n){n=e(n||this.defaultElement||this)[0],this.element=e(n),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this.bindings=e(),this.hoverable=e(),this.focusable=e(),n!==this&&(e.data(n,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===n&&this.destroy()}}),this.document=e(n.style?n.ownerDocument:n.document||n),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(i,n){var r,o,s,a=i;if(0===arguments.length)return e.widget.extend({},this.options);if("string"==typeof i)if(a={},r=i.split("."),i=r.shift(),r.length){for(o=a[i]=e.widget.extend({},this.options[i]),s=0;si)&&(this.bitrate=(t-this.loaded)*(1e3/n)*8,this.loaded=t,this.timestamp=e),this.bitrate}},_isXHRUpload:function(t){return!t.forceIframeTransport&&(!t.multipart&&e.support.xhrFileUpload||e.support.xhrFormDataFileUpload)},_getFormData:function(t){var i;return"function"==typeof t.formData?t.formData(t.form):e.isArray(t.formData)?t.formData:t.formData?(i=[],e.each(t.formData,function(e,t){i.push({name:e,value:t})}),i):[]},_getTotal:function(t){var i=0;return e.each(t,function(e,t){i+=t.size||1}),i},_initProgressObject:function(e){e._progress={loaded:0,total:0,bitrate:0}},_onProgress:function(e,t){if(e.lengthComputable){var i,n=+new Date;if(t._time&&t.progressInterval&&n-t._time").prop("href",t.url).prop("host")!==location.host&&t.formData.push({name:t.redirectParamName||"redirect",value:t.redirect})},_initDataSettings:function(e){this._isXHRUpload(e)?(this._chunkedUpload(e,!0)||(e.data||this._initXHRData(e),this._initProgressListener(e)),e.postMessage&&(e.dataType="postmessage "+(e.dataType||""))):this._initIframeSettings(e,"iframe")},_getParamName:function(t){var i=e(t.fileInput),n=t.paramName;return n?e.isArray(n)||(n=[n]):(n=[],i.each(function(){for(var t=e(this),i=t.prop("name")||"files[]",r=(t.prop("files")||[1]).length;r;)n.push(i),r-=1}),n.length||(n=[i.prop("name")||"files[]"])),n},_initFormSettings:function(t){t.form&&t.form.length||(t.form=e(t.fileInput.prop("form")),t.form.length||(t.form=e(this.options.fileInput.prop("form")))),t.paramName=this._getParamName(t),t.urlFunc&&(t.url=t.urlFunc()),t.url||(t.url=t.form.prop("action")||location.href),t.type=(t.type||t.form.prop("method")||"").toUpperCase(),"POST"!==t.type&&"PUT"!==t.type&&"PATCH"!==t.type&&(t.type="POST"),t.formAcceptCharset||(t.formAcceptCharset=t.form.attr("accept-charset"))},_getAJAXSettings:function(t){var i=e.extend({},this.options,t);return this._initFormSettings(i),this._initDataSettings(i),i},_getDeferredState:function(e){return e.state?e.state():e.isResolved()?"resolved":e.isRejected()?"rejected":"pending"},_enhancePromise:function(e){return e.success=e.done,e.error=e.fail,e.complete=e.always,e},_getXHRPromise:function(t,i,n){var r=e.Deferred(),o=r.promise();return i=i||this.options.context||o,t===!0?r.resolveWith(i,n):t===!1&&r.rejectWith(i,n),o.abort=r.promise,this._enhancePromise(o)},_addConvenienceMethods:function(e,t){var i=this;t.submit=function(){return"pending"!==this.state()&&(t.jqXHR=this.jqXHR=i._trigger("submit",e,this)!==!1&&i._onSend(e,this)),this.jqXHR||i._getXHRPromise()},t.abort=function(){return this.jqXHR?this.jqXHR.abort():this._getXHRPromise()},t.state=function(){return this.jqXHR?i._getDeferredState(this.jqXHR):void 0},t.progress=function(){return this._progress}},_getUploadedBytes:function(e){var t=e.getResponseHeader("Range"),i=t&&t.split("-"),n=i&&i.length>1&&parseInt(i[1],10);return n&&n+1},_chunkedUpload:function(t,i){var n,r,o=this,s=t.files[0],a=s.size,l=t.uploadedBytes=t.uploadedBytes||0,p=t.maxChunkSize||a,u=s.slice||s.webkitSlice||s.mozSlice,d=e.Deferred(),h=d.promise();return this._isXHRUpload(t)&&u&&(l||a>p)&&!t.data?i?!0:l>=a?(s.error="Uploaded bytes exceed file size",this._getXHRPromise(!1,t.context,[null,"error",s.error])):(r=function(){var i=e.extend({},t),h=i._progress.loaded;i.blob=u.call(s,l,l+p,s.type),i.chunkSize=i.blob.size,i.contentRange="bytes "+l+"-"+(l+i.chunkSize-1)+"/"+a,o._initXHRData(i),o._initProgressListener(i),n=(o._trigger("chunksend",null,i)!==!1&&e.ajax(i)||o._getXHRPromise(!1,i.context)).done(function(n,s,p){l=o._getUploadedBytes(p)||l+i.chunkSize,i._progress.loaded===h&&o._onProgress(e.Event("progress",{lengthComputable:!0,loaded:l-i.uploadedBytes,total:l-i.uploadedBytes}),i),t.uploadedBytes=i.uploadedBytes=l,i.result=n,i.textStatus=s,i.jqXHR=p,o._trigger("chunkdone",null,i),o._trigger("chunkalways",null,i),a>l?r():d.resolveWith(i.context,[n,s,p])}).fail(function(e,t,n){i.jqXHR=e,i.textStatus=t,i.errorThrown=n,o._trigger("chunkfail",null,i),o._trigger("chunkalways",null,i),d.rejectWith(i.context,[e,t,n])})},this._enhancePromise(h),h.abort=function(){return n.abort()},r(),h):!1},_beforeSend:function(e,t){0===this._active&&(this._trigger("start"),this._bitrateTimer=new this._BitrateTimer,this._progress.loaded=this._progress.total=0,this._progress.bitrate=0),t._progress||(t._progress={}),t._progress.loaded=t.loaded=t.uploadedBytes||0,t._progress.total=t.total=this._getTotal(t.files)||1,t._progress.bitrate=t.bitrate=0,this._active+=1,this._progress.loaded+=t.loaded,this._progress.total+=t.total},_onDone:function(t,i,n,r){var o=r._progress.total;r._progress.loadeda._sending)for(var n=a._slots.shift();n;){if("pending"===a._getDeferredState(n)){n.resolve();break}n=a._slots.shift()}})};return this._beforeSend(t,l),this.options.sequentialUploads||this.options.limitConcurrentUploads&&this.options.limitConcurrentUploads<=this._sending?(this.options.limitConcurrentUploads>1?(o=e.Deferred(),this._slots.push(o),s=o.pipe(p)):s=this._sequence=this._sequence.pipe(p,p),s.abort=function(){return r=[void 0,"abort","abort"],n?n.abort():(o&&o.rejectWith(l.context,r),p())},this._enhancePromise(s)):p()},_onAdd:function(t,i){var n,r,o,s,a=this,l=!0,p=e.extend({},this.options,i),u=p.limitMultiFileUploads,d=this._getParamName(p);if((p.singleFileUploads||u)&&this._isXHRUpload(p))if(!p.singleFileUploads&&u)for(o=[],n=[],s=0;s").append(i)[0].reset(),t.after(i).detach(),e.cleanData(t.unbind("remove")),this.options.fileInput=this.options.fileInput.map(function(e,n){return n===t[0]?i[0]:n}),t[0]===this.element[0]&&(this.element=i)},_handleFileTreeEntry:function(t,i){var n,r=this,o=e.Deferred(),s=function(e){e&&!e.entry&&(e.entry=t),o.resolve([e])};return i=i||"",t.isFile?t._file?(t._file.relativePath=i,o.resolve(t._file)):t.file(function(e){e.relativePath=i,o.resolve(e)},s):t.isDirectory?(n=t.createReader(),n.readEntries(function(e){r._handleFileTreeEntries(e,i+t.name+"/").done(function(e){o.resolve(e)}).fail(s)},s)):o.resolve([]),o.promise()},_handleFileTreeEntries:function(t,i){var n=this;return e.when.apply(e,e.map(t,function(e){return n._handleFileTreeEntry(e,i)})).pipe(function(){return Array.prototype.concat.apply([],arguments)})},_getDroppedFiles:function(t){t=t||{};var i=t.items;return i&&i.length&&(i[0].webkitGetAsEntry||i[0].getAsEntry)?this._handleFileTreeEntries(e.map(i,function(e){var t;return e.webkitGetAsEntry?(t=e.webkitGetAsEntry(),t&&(t._file=e.getAsFile()),t):e.getAsEntry()})):e.Deferred().resolve(e.makeArray(t.files)).promise()},_getSingleFileInputFiles:function(t){t=e(t);var i,n,r=t.prop("webkitEntries")||t.prop("entries");if(r&&r.length)return this._handleFileTreeEntries(r);if(i=e.makeArray(t.prop("files")),i.length)void 0===i[0].name&&i[0].fileName&&e.each(i,function(e,t){t.name=t.fileName,t.size=t.fileSize});else{if(n=t.prop("value"),!n)return e.Deferred().resolve([]).promise();i=[{name:n.replace(/^.*\\/,"")}]}return e.Deferred().resolve(i).promise()},_getFileInputFiles:function(t){return t instanceof e&&1!==t.length?e.when.apply(e,e.map(t,this._getSingleFileInputFiles)).pipe(function(){return Array.prototype.concat.apply([],arguments)}):this._getSingleFileInputFiles(t)},_onChange:function(t){var i=this,n={fileInput:e(t.target),form:e(t.target.form)};this._getFileInputFiles(n.fileInput).always(function(e){n.files=e,i.options.replaceFileInput&&i._replaceFileInput(n.fileInput),i._trigger("change",t,n)!==!1&&i._onAdd(t,n)})},_onPaste:function(t){var i=t.originalEvent.clipboardData,n=i&&i.items||[],r={files:[]};return e.each(n,function(e,t){var i=t.getAsFile&&t.getAsFile();i&&r.files.push(i)}),this._trigger("paste",t,r)===!1||this._onAdd(t,r)===!1?!1:void 0},_onDrop:function(e){var t=this,i=e.dataTransfer=e.originalEvent.dataTransfer,n={};i&&i.files&&i.files.length&&e.preventDefault(),this._getDroppedFiles(i).always(function(i){n.files=i,t._trigger("drop",e,n)!==!1&&t._onAdd(e,n)})},_onDragOver:function(t){var i=t.dataTransfer=t.originalEvent.dataTransfer;return this._trigger("dragover",t)===!1?!1:void(i&&-1!==e.inArray("Files",i.types)&&(i.dropEffect="copy",t.preventDefault()))},_initEventHandlers:function(){this._isXHRUpload(this.options)&&(this._on(this.options.dropZone,{dragover:this._onDragOver,drop:this._onDrop}),this._on(this.options.pasteZone,{paste:this._onPaste})),this._on(this.options.fileInput,{change:this._onChange})},_destroyEventHandlers:function(){this._off(this.options.dropZone,"dragover drop"),this._off(this.options.pasteZone,"paste"),this._off(this.options.fileInput,"change")},_setOption:function(t,i){var n=-1!==e.inArray(t,this._refreshOptionsList);n&&this._destroyEventHandlers(),this._super(t,i),n&&(this._initSpecialOptions(),this._initEventHandlers())},_initSpecialOptions:function(){var t=this.options;void 0===t.fileInput?t.fileInput=this.element.is('input[type="file"]')?this.element:this.element.find('input[type="file"]'):t.fileInput instanceof e||(t.fileInput=e(t.fileInput)),t.dropZone instanceof e||(t.dropZone=e(t.dropZone)),t.pasteZone instanceof e||(t.pasteZone=e(t.pasteZone))},_create:function(){var t=this.options;e.extend(t,e(this.element[0].cloneNode(!1)).data()),this._initSpecialOptions(),this._slots=[],this._sequence=this._getXHRPromise(!0),this._sending=this._active=0,this._initProgressObject(this),this._initEventHandlers()},progress:function(){return this._progress},add:function(t){var i=this;t&&!this.options.disabled&&(t.fileInput&&!t.files?this._getFileInputFiles(t.fileInput).always(function(e){t.files=e,i._onAdd(null,t)}):(t.files=e.makeArray(t.files),this._onAdd(null,t)))},send:function(t){if(t&&!this.options.disabled){if(t.fileInput&&!t.files){var i,n,r=this,o=e.Deferred(),s=o.promise();return s.abort=function(){return n=!0,i?i.abort():(o.reject(null,"abort","abort"),s)},this._getFileInputFiles(t.fileInput).always(function(e){n||(t.files=e,i=r._onSend(null,t).then(function(e,t,i){o.resolve(e,t,i)},function(e,t,i){o.reject(e,t,i)}))}),this._enhancePromise(s)}if(t.files=e.makeArray(t.files),t.files.length)return this._onSend(null,t)}return this._getXHRPromise(!1,t&&t.context)}})}),window.define&&define("fileupload",[],function(){}); jQuery.fn.pagination=function(e,t){return t=jQuery.extend({items_per_page:10,num_display_entries:10,current_page:0,num_edge_entries:2,link_to:"#",prev_text:"Prev",next_text:"Next",ellipse_text:"...",prev_show_always:!0,next_show_always:!0,callback:function(){return!1}},t||{}),this.each(function(){function n(){return Math.ceil(e/t.items_per_page)}function a(){var e=Math.ceil(t.num_display_entries/2),a=n(),r=a-t.num_display_entries,s=i>e?Math.max(Math.min(i-e,r),0):0,_=i>e?Math.min(i+e,a):Math.min(t.num_display_entries,a);return[s,_]}function r(e,n){n.preventDefault(),i=e,s();var a=t.callback(e,_);return a||(n.stopPropagation?n.stopPropagation():n.cancelBubble=!0),a}function s(){_.empty();var e=a(),s=n(),p=function(e){return function(t){return r(e,t)}},l=function(e,n){e=0>e?0:s>e?e:s-1,n=jQuery.extend({text:e+1,classes:""},n||{});var a="";if(e==i){var r=jQuery(""+n.text+"");n.text!=t.prev_text&&n.text!=t.next_text&&(a='class="active"')}else var r=jQuery(""+n.text+"").bind("click",p(e)).attr("href",t.link_to.replace(/__id__/,e));n.classes&&r.addClass(n.classes);var l=$("
  • ").append(r);_.append(l)};if(t.prev_text&&(i>0||t.prev_show_always)&&l(i-1,{text:t.prev_text,classes:"prev"}),e[0]>0&&t.num_edge_entries>0){for(var u=Math.min(t.num_edge_entries,e[0]),c=0;u>c;c++)l(c);t.num_edge_entries"+t.ellipse_text+"").appendTo(_)}for(var c=e[0];c0){s-t.num_edge_entries>e[1]&&t.ellipse_text&&jQuery("
  • "+t.ellipse_text+"
  • ").appendTo(_);for(var x=Math.max(s-t.num_edge_entries,e[1]),c=x;s>c;c++)l(c)}t.next_text&&(s-1>i||t.next_show_always)&&l(i+1,{text:t.next_text,classes:"next"})}var i=t.current_page;e=!e||0>e?1:e,t.items_per_page=!t.items_per_page||t.items_per_page<0?1:t.items_per_page;var _=jQuery(this);this.selectPage=function(e){r(e)},this.prevPage=function(){return i>0?(r(i-1),!0):!1},this.nextPage=function(){return i'+e.Name+"";$("#albumsForUpload").append(t).val(e.AlbumId),$("#albumsForList").append(t)},pageUpdateAlbum:function(e,t){$('option[value="'+e+'"]').html(t)},processAlbum:function(){function e(){$("#addOrUpdateAlbumForm").is(":hidden")?($("#addOrUpdateAlbumForm").show(),$("#albumSelect").hide()):($("#addOrUpdateAlbumForm").hide(),$("#albumSelect").show())}var t=this,a=!0,i="";$("#renameAlbumBtn").click(function(){return(i=$("#albumsForUpload").val())?(e(),$("#addOrUpdateAlbumBtn").html(getMsg("Rename Album")),$("#albumName").val($("#albumsForUpload option:selected").html()).focus(),void(a=!1)):void alert(getMsg("Cannot rename default album"))}),$("#addAlbumBtn").click(function(){e(),$("#addOrUpdateAlbumBtn").html(getMsg("Add Album")),$("#albumName").val("").focus(),a=!0}),$("#cancelAlbumBtn").click(function(){e()}),$("#addOrUpdateAlbumBtn").click(function(){var s=$("#albumName").val();return s?void(a?$.get("/album/addAlbum",{name:s},function(a){"object"==typeof a&&""!=a.AlbumId?($("#albumName").val(""),t.showMsg(getMsg("Add Success!")),t.pageAddAlbum(a),setTimeout(function(){e()},200)):alert(getMsg("error"))}):$.get("/album/updateAlbum",{albumId:i,name:s},function(a){"boolean"==typeof a&&a?($("#albumName").val(""),t.showMsg(getMsg("Rename Success!")),t.pageUpdateAlbum(i,s),setTimeout(function(){e()},200)):alert(getMsg("error!"))})):void $("#albumName").focus()}),$("#deleteAlbumBtn").click(function(){var e=$("#albumsForUpload").val();return e?void $.get("/album/deleteAlbum",{albumId:e},function(a){"object"==typeof a&&1==a.Ok?(t.showMsg(getMsg("Delete Success!")),$("#albumsForUpload option[value='"+e+"']").remove(),$("#albumsForList").val()==e&&(t.needRefresh=!0),$("#albumsForList option[value='"+e+"']").remove()):alert(getMsg("This album has images, please delete it's images at first."))}):void alert(getMsg("Cannot delete default album"))})},renderAlbums:function(){var e=this;$.get("/album/getAlbums",function(t){if(t){var a="";for(var i in t){var s=t[i],r='";a+=r}$("#albumsForUpload").append(a),$("#albumsForList").append(a);var l=$("#albumsForList").val();e.renderImages(l,1,!0)}})},imageMaskO:$("#imageMask"),noImagesO:$("#noImages"),loadingO:$("#loading"),loadingStart:function(){this.imageMaskO.is(":hidden")&&this.imageMaskO.css("opacity",.8).show(),this.noImagesO.hide(),this.loadingO.show()},loadingEnd:function(){this.imageMaskO.hide()},noImages:function(){this.imageMaskO.show().css("opacity",1),this.noImagesO.show(),this.loadingO.hide()},search:function(){var e=this,t=1;$("#key").on("keyup",function(){var a=++t,i=$(this).val(),s=$("#albumsForList").val();e.renderImages(s,1,!0,i,function(){return t==a})})},renderImages:function(e,t,a,i,s){var r=this;t||(t=1),r.loadingStart(),$.get("/file/getImages",{albumId:e,page:t,key:i},function(e){if(!e||!e.Count)return void r.noImages();r.loadingEnd();var t=e.List,i={};for(var s in r.selectedImages){var l=r.selectedImages[s];i[l]=!0}var n="";for(var s in t){var o=t[s],d="";if(""!=o.Path&&"/"==o.Path[0]&&(o.Path=o.Path.substr(1)),""!=o.Path&&"upload/"==o.Path.substr(0,7))var l=urlPrefix+"/"+o.Path;else var l=urlPrefix+"/api/file/getImage?fileId="+o.FileId;i[l]&&(d='class="selected"'),n+="
  • ",n+='',n+='
    '+o.Title+'
    ',n+="
  • "}$("#imageList").html(n),a&&r.pagination(e.Count)})},initSelectedZones:function(){var e=this;num=this.maxSelected,e.previewO.html("");for(var t=1;t<=num;++t)e.previewO.append("
  • ?
  • ")},reRenderSelectedImages:function(e,t){for(var a=this,i=this.selectedZoneO.find("li"),s=this.selectedImages.length-1,r=0;rs)l.html("?");else{src=this.selectedImages[r];var n=a.imageAttrs[src],o="";n&&(n.width&&(o+=' data-width="'+n.width+'"'),n.height&&(o+=' data-height="'+n.height+'"'),n.title&&(o+=' data-title="'+n.title+'"')),l.html("
    ')}e?l.removeClass("selected"):t==src&&l.click()}},removeSelectedImage:function(e){var t=this,a=e.find("img").attr("src");for(var i in this.selectedImages)this.selectedImages[i]==a&&this.selectedImages.splice(i,1);this.reRenderSelectedImages(!0),t.clearAttrs()},addSelectedImage:function(e){if(this.maxSelected>1&&this.maxSelected<=this.selectedImages.length)return!1;if("object"==typeof e)var t=e.find("img").attr("src");else t=-1!=e.indexOf("http://")||-1!=e.indexOf("https://")?e:urlPrefix+"/api/file/getImage?fileId="+e;return 1==this.maxSelected?($("#imageList li").removeClass("selected"),this.selectedImages=[t]):this.selectedImages.push(t),this.reRenderSelectedImages(!1,t),!0},initDataFromTinymce:function(){var e=this,t=top.LEAUI_DATAS,a="";if(t&&t.length>0){for(var i in t){var s=t[i];s.constrain=!0,a=s.src,e.selectedImages.push(s.src),e.imageAttrs[s.src]=s}e.reRenderSelectedImages(!1,a)}},init:function(){var e=this;e.processAlbum(),$("#albumsForList").change(function(){var t=$(this).val();e.renderImages(t,1,!0)}),$("#imageList").on("click","li",function(){$(this).hasClass("selected")?($(this).removeClass("selected"),e.removeSelectedImage($(this))):e.addSelectedImage($(this))&&$(this).addClass("selected")}),$("#imageList").on("click",".del",function(t){var a=this;if(t.stopPropagation(),confirm(getMsg("Are you sure to delete this image ?"))){var i=$(this).data("id");$.get("/file/deleteImage",{fileId:i},function(t){if(t){var i=$(a).closest("li");i.hasClass("selected")&&e.removeSelectedImage(i),$(a).closest("li").remove()}})}}),$("#imageList").on("click",".file-title",function(e){var t=this;if(e.stopPropagation(),!$(this).children().eq(0).is("input")){var a=$(t).parent().data("id"),i=$(this).text();$(this).html('');var s=$(this).find("input");s.focus(),s.keydown(function(e){13==e.keyCode&&$(this).trigger("blur")}),s.blur(function(){var e=$(this).val();e?$.post("/file/updateImageTitle",{fileId:a,title:e}):e=i,$(t).html(e)})}}),$("#preview").on("click",".del",function(t){t.stopPropagation();var a=$(this).closest("li"),i=a.find("img").attr("src");e.removeSelectedImage(a),$("#imageList img").each(function(){var e=$(this).attr("src");i==e&&$(this).parent().parent().removeClass("selected")})}),$("#goAddImageBtn").click(function(){$("#albumsForUpload").val($("#albumsForList").val()),$("#myTab li:eq(1) a").tab("show")}),$("#myTab a").on("shown.bs.tab",function(t){t.preventDefault(),$(this).tab("show");var a=$(this).attr("href");e.needRefresh&&"#images"==a&&(setTimeout(function(){var t=$("#albumsForList").val(),a=$("#key").val();e.renderImages(t,e.pageNum,!0,a)},200),e.needRefresh=!1),"#url"==a&&$("#imageUrl").focus()}),$("#refresh").click(function(){var t=$("#albumsForList").val(),a=$("#key").val();e.renderImages(t,e.pageNum,!1,a)}),$("#addImageUrlBtn").click(function(t){t.preventDefault();var a=$.trim($("#imageUrl").val());return a?void getImageSize(a,function(t){return t.width&&t.height?($("#msgForUrl").hide(),$("#imageUrl").val(""),void e.addSelectedImage(a)):void $("#msgForUrl").show()}):void $("#imageUrl").focus()}),$("#preview").on("click","li",function(){$(this).hasClass("selected")||$(this).find("img").length&&($("#preview li").removeClass("selected"),$(this).addClass("selected"),e.initAttr($(this)))}),$("#attrTitle, #attrWidth, #attrHeight").on("keyup",function(){e.modifyAttr($(this))}),$("#attrConstrain").on("click",function(){e.modifyAttr($(this))}),e.search(),e.initSelectedZones(),e.initDataFromTinymce(),e.renderAlbums(),e.initUploader()},curSrc:"",curLi:null,attrTitleO:$("#attrTitle"),attrWidthO:$("#attrWidth"),attrHeightO:$("#attrHeight"),attrConstrainO:$("#attrConstrain"),clearAttrs:function(){var e=this;e.attrTitleO.val("").attr("disabled",!0),e.attrHeightO.val("").attr("disabled",!0),e.attrWidthO.val("").attr("disabled",!0),e.attrConstrainO.prop("checked",!1).attr("disabled",!0)},scale:function(e){var t=this,a=t.attrConstrainO.is(":checked"),i=+t.attrWidthO.val(),s=+t.attrHeightO.val();if(!isNaN(i)&&!isNaN(s)){var r=t.getCurAttrs(),l=r.preWidth||r.width,n=r.preHeight||r.height;a&&l&&n&&(e?(s=parseInt(i/l*n),t.attrHeightO.val(s)):(i=parseInt(s/n*l),t.attrWidthO.val(i)));var o={width:i,height:s};return o}},getCurAttrs:function(){var e=this;return e.imageAttrs[e.curSrc]},setCurDataAttrs:function(e){var t=this,a=t.curLi.find("img");a.attr("data-width",e.width),a.attr("data-height",e.height),a.attr("data-title",e.title),t.imageAttrs[t.curSrc]=e},modifyAttr:function(e){var t=this,a=e.attr("id"),i=e.val(),s=t.getCurAttrs();if(s){switch(a){case"attrConstrain":i=0,e.is(":checked")&&(i=1),s.constrain=i;break;case"attrTitle":s.title=i;break;case"attrWidth":$.extend(s,t.scale(!0));break;case"attrHeight":$.extend(s,t.scale(!1))}t.setCurDataAttrs(s)}},initAttr:function(e){function t(e){e=e||{},a.attrTitleO.val(e.title).attr("disabled",!1),a.attrWidthO.val(e.width).attr("disabled",!1),a.attrHeightO.val(e.height).attr("disabled",!1),a.attrConstrainO.attr("disabled",!1),e.constrain?a.attrConstrainO.prop("checked",!0):a.attrConstrainO.prop("checked",!1),a.setCurDataAttrs(e)}var a=this;"object"!=typeof e&&(e=$("#preview").find('img[src="'+e+'"]').parent());var i=e.find("img").attr("src");a.curSrc=i,a.curLi=e;var s=a.imageAttrs[i];s=s||{},s&&s.width&&s.height?t(s):getImageSize(i,function(e){return e.title=s.title||"",e.constrain=1,e.preWidth=e.width,e.preHeight=e.height,i!=a.curSrc?(a.imageAttrs[i]=e,void a.setCurDataAttrs(s)):void t(e)})},needRefresh:!1,uploadRefreshImageList:function(){var e=this,t=$("#albumsForList").val();t==$("#albumsForUpload").val()&&(e.needRefresh=!0)},initUploader:function(){function e(e){return"number"!=typeof e?"":e>=1e9?(e/1e9).toFixed(2)+" GB":e>=1e6?(e/1e6).toFixed(2)+" MB":(e/1e3).toFixed(2)+" KB"}var t=this,a=$("#upload ul");$("#drop a").click(function(){$(this).parent().find("input").click()}),$("#upload").fileupload({dataType:"json",pasteZone:"",acceptFileTypes:/(\.|\/)(gif|jpg|jpeg|png|jpe)$/i,dropZone:$("#drop"),formData:function(e){return[{name:"albumId",value:$("#albumsForUpload").val()}]},add:function(t,i){var s=i.files[0].size,r=+parent.GlobalConfigs.uploadImageSize||100;if("number"==typeof s&&s>1048576*r){var l=$('
  • ');return l.find("div").append("Warning: "+i.files[0].name+" ["+e(i.files[0].size)+"] is bigger than "+r+"M "),void l.appendTo(a)}var l=$('
  • ');l.find("div").append(i.files[0].name+" ["+e(i.files[0].size)+"]"),i.context=l.appendTo(a);i.submit()},done:function(a,i){if(1==i.result.Ok)i.context.remove(),t.addSelectedImage(i.result.Id),t.uploadRefreshImageList();else{i.context.empty();var s=$('
  • ');s.find("div").append(""+getMsg("Error")+": "+i.files[0].name+" ["+e(i.files[0].size)+"] "+i.result.Msg),i.context.append(s),setTimeout(function(e){return function(){e.remove()}}(s),3e3)}$("#upload-msg").scrollTop(1e3)},fail:function(t,a){a.context.empty();var i=$('
  • ');i.find("div").append("Error: "+a.files[0].name+" ["+e(a.files[0].size)+"] "+a.errorThrown),a.context.append(i),$("#upload-msg").scrollTop(1e3)}}),$(document).on("drop dragover",function(e){e.preventDefault()}),$(document).bind("dragover",function(e){var t=$("#drop"),a=window.dropZoneTimeout;a?clearTimeout(a):t.addClass("in");var i=!1,s=e.target;do{if(s===t[0]){i=!0;break}s=s.parentNode}while(null!=s);i?t.addClass("hover"):t.removeClass("hover"),window.dropZoneTimeout=setTimeout(function(){window.dropZoneTimeout=null,t.removeClass("in hover")},100)})}};$(function(){o.init()}); \ No newline at end of file +function log(e){}function retIsOk(e){return e&&"object"==typeof e&&1==e.Ok?!0:!1}function getImageSize(e,t){function a(e,a){i.parentNode.removeChild(i),t({width:e,height:a})}var i=document.createElement("img");i.onload=function(){a(i.clientWidth,i.clientHeight)},i.onerror=function(){a()},i.src=e;var s=i.style;s.visibility="hidden",s.position="fixed",s.bottom=s.left=0,s.width=s.height="auto",document.body.appendChild(i)}function mdGetImgSrc(){return o.selectedImages&&o.selectedImages.length?o.selectedImages[0]:""}var urlPrefix="",getMsg=parent.getMsg;getMsg||(getMsg=function(e){return e});var o={maxSelected:G.maxSelected,selectedZoneO:$("#preview"),previewO:$("#preview"),selectedImages:[],imageAttrs:{},pageNum:1,pagination:function(e){var t=this;$(".pagination").pagination(e,{items_per_page:G.perPageItems,prev_text:getMsg("Prev"),next_text:getMsg("Next"),callback:function(e){t.pageNum=e+1,t.renderImages($("#albumsForList").val(),t.pageNum,!1)}})},showMsg:function(e){$("#msg").html(e).css("display","inline"),setTimeout(function(){$("#msg").fadeOut()},2e3)},pageAddAlbum:function(e){var t='";$("#albumsForUpload").append(t).val(e.AlbumId),$("#albumsForList").append(t)},pageUpdateAlbum:function(e,t){$('option[value="'+e+'"]').html(t)},processAlbum:function(){function e(){$("#addOrUpdateAlbumForm").is(":hidden")?($("#addOrUpdateAlbumForm").show(),$("#albumSelect").hide()):($("#addOrUpdateAlbumForm").hide(),$("#albumSelect").show())}var t=this,a=!0,i="";$("#renameAlbumBtn").click(function(){return(i=$("#albumsForUpload").val())?(e(),$("#addOrUpdateAlbumBtn").html(getMsg("Rename Album")),$("#albumName").val($("#albumsForUpload option:selected").html()).focus(),void(a=!1)):void alert(getMsg("Cannot rename default album"))}),$("#addAlbumBtn").click(function(){e(),$("#addOrUpdateAlbumBtn").html(getMsg("Add Album")),$("#albumName").val("").focus(),a=!0}),$("#cancelAlbumBtn").click(function(){e()}),$("#addOrUpdateAlbumBtn").click(function(){var s=$("#albumName").val();return s?void(a?$.get("/album/addAlbum",{name:s},function(a){"object"==typeof a&&""!=a.AlbumId?($("#albumName").val(""),t.showMsg(getMsg("Add Success!")),t.pageAddAlbum(a),setTimeout(function(){e()},200)):alert(getMsg("error"))}):$.get("/album/updateAlbum",{albumId:i,name:s},function(a){"boolean"==typeof a&&a?($("#albumName").val(""),t.showMsg(getMsg("Rename Success!")),t.pageUpdateAlbum(i,s),setTimeout(function(){e()},200)):alert(getMsg("error!"))})):void $("#albumName").focus()}),$("#deleteAlbumBtn").click(function(){var e=$("#albumsForUpload").val();return e?void $.get("/album/deleteAlbum",{albumId:e},function(a){"object"==typeof a&&1==a.Ok?(t.showMsg(getMsg("Delete Success!")),$("#albumsForUpload option[value='"+e+"']").remove(),$("#albumsForList").val()==e&&(t.needRefresh=!0),$("#albumsForList option[value='"+e+"']").remove()):alert(getMsg("This album has images, please delete it's images at first."))}):void alert(getMsg("Cannot delete default album"))})},renderAlbums:function(){var e=this;$.get("/album/getAlbums",function(t){if(t){var a="";for(var i in t){var s=t[i],r='";a+=r}$("#albumsForUpload").append(a),$("#albumsForList").append(a);var l=$("#albumsForList").val();e.renderImages(l,1,!0)}})},imageMaskO:$("#imageMask"),noImagesO:$("#noImages"),loadingO:$("#loading"),loadingStart:function(){this.imageMaskO.is(":hidden")&&this.imageMaskO.css("opacity",.8).show(),this.noImagesO.hide(),this.loadingO.show()},loadingEnd:function(){this.imageMaskO.hide()},noImages:function(){this.imageMaskO.show().css("opacity",1),this.noImagesO.show(),this.loadingO.hide()},search:function(){var e=this,t=1;$("#key").on("keyup",function(){var a=++t,i=$(this).val(),s=$("#albumsForList").val();e.renderImages(s,1,!0,i,function(){return t==a})})},renderImages:function(e,t,a,i,s){var r=this;t||(t=1),r.loadingStart(),$.get("/file/getImages",{albumId:e,page:t,key:i},function(e){if(!e||!e.Count)return void r.noImages();r.loadingEnd();var t=e.List,i={};for(var s in r.selectedImages){var l=r.selectedImages[s];i[l]=!0}var n="";for(var s in t){var o=t[s],d="";if(""!=o.Path&&"/"==o.Path[0]&&(o.Path=o.Path.substr(1)),""!=o.Path&&"upload/"==o.Path.substr(0,7))var l=urlPrefix+"/"+o.Path;else var l=urlPrefix+"/api/file/getImage?fileId="+o.FileId;i[l]&&(d='class="selected"'),n+="
  • ",n+='',n+='
    '+o.Title+'
    ',n+="
  • "}$("#imageList").html(n),a&&r.pagination(e.Count)})},initSelectedZones:function(){var e=this;num=this.maxSelected,e.previewO.html("");for(var t=1;t<=num;++t)e.previewO.append("
  • ?
  • ")},reRenderSelectedImages:function(e,t){for(var a=this,i=this.selectedZoneO.find("li"),s=this.selectedImages.length-1,r=0;rs)l.html("?");else{src=this.selectedImages[r];var n=a.imageAttrs[src],o="";n&&(n.width&&(o+=' data-width="'+n.width+'"'),n.height&&(o+=' data-height="'+n.height+'"'),n.title&&(o+=' data-title="'+n.title+'"')),l.html("
    ')}e?l.removeClass("selected"):t==src&&l.click()}},removeSelectedImage:function(e){var t=this,a=e.find("img").attr("src");for(var i in this.selectedImages)this.selectedImages[i]==a&&this.selectedImages.splice(i,1);this.reRenderSelectedImages(!0),t.clearAttrs()},addSelectedImage:function(e){if(this.maxSelected>1&&this.maxSelected<=this.selectedImages.length)return!1;if("object"==typeof e)var t=e.find("img").attr("src");else t=-1!=e.indexOf("http://")||-1!=e.indexOf("https://")?e:urlPrefix+"/api/file/getImage?fileId="+e;return 1==this.maxSelected?($("#imageList li").removeClass("selected"),this.selectedImages=[t]):this.selectedImages.push(t),this.reRenderSelectedImages(!1,t),!0},initDataFromTinymce:function(){var e=this,t=top.LEAUI_DATAS,a="";if(t&&t.length>0){for(var i in t){var s=t[i];s.constrain=!0,a=s.src,e.selectedImages.push(s.src),e.imageAttrs[s.src]=s}e.reRenderSelectedImages(!1,a)}},init:function(){var e=this;e.processAlbum(),$("#albumsForList").change(function(){var t=$(this).val();e.renderImages(t,1,!0)}),$("#imageList").on("click","li",function(){$(this).hasClass("selected")?($(this).removeClass("selected"),e.removeSelectedImage($(this))):e.addSelectedImage($(this))&&$(this).addClass("selected")}),$("#imageList").on("click",".del",function(t){var a=this;if(t.stopPropagation(),confirm(getMsg("Are you sure to delete this image ?"))){var i=$(this).data("id");$.get("/file/deleteImage",{fileId:i},function(t){if(t){var i=$(a).closest("li");i.hasClass("selected")&&e.removeSelectedImage(i),$(a).closest("li").remove()}})}}),$("#imageList").on("click",".file-title",function(e){var t=this;if(e.stopPropagation(),!$(this).children().eq(0).is("input")){var a=$(t).parent().data("id"),i=$(this).text();$(this).html('');var s=$(this).find("input");s.focus(),s.keydown(function(e){13==e.keyCode&&$(this).trigger("blur")}),s.blur(function(){var e=$(this).val();e?$.post("/file/updateImageTitle",{fileId:a,title:e}):e=i,$(t).html(e)})}}),$("#preview").on("click",".del",function(t){t.stopPropagation();var a=$(this).closest("li"),i=a.find("img").attr("src");e.removeSelectedImage(a),$("#imageList img").each(function(){var e=$(this).attr("src");i==e&&$(this).parent().parent().removeClass("selected")})}),$("#goAddImageBtn").click(function(){$("#albumsForUpload").val($("#albumsForList").val()),$("#myTab li:eq(1) a").tab("show")}),$("#myTab a").on("shown.bs.tab",function(t){t.preventDefault(),$(this).tab("show");var a=$(this).attr("href");e.needRefresh&&"#images"==a&&(setTimeout(function(){var t=$("#albumsForList").val(),a=$("#key").val();e.renderImages(t,e.pageNum,!0,a)},200),e.needRefresh=!1),"#url"==a&&$("#imageUrl").focus()}),$("#refresh").click(function(){var t=$("#albumsForList").val(),a=$("#key").val();e.renderImages(t,e.pageNum,!1,a)}),$("#addImageUrlBtn").click(function(t){t.preventDefault();var a=$.trim($("#imageUrl").val());return a?void getImageSize(a,function(t){return t.width&&t.height?($("#msgForUrl").hide(),$("#imageUrl").val(""),void e.addSelectedImage(a)):void $("#msgForUrl").show()}):void $("#imageUrl").focus()}),$("#preview").on("click","li",function(){$(this).hasClass("selected")||$(this).find("img").length&&($("#preview li").removeClass("selected"),$(this).addClass("selected"),e.initAttr($(this)))}),$("#attrTitle, #attrWidth, #attrHeight").on("keyup",function(){e.modifyAttr($(this))}),$("#attrConstrain").on("click",function(){e.modifyAttr($(this))}),e.search(),e.initSelectedZones(),e.initDataFromTinymce(),e.renderAlbums(),e.initUploader()},curSrc:"",curLi:null,attrTitleO:$("#attrTitle"),attrWidthO:$("#attrWidth"),attrHeightO:$("#attrHeight"),attrConstrainO:$("#attrConstrain"),clearAttrs:function(){var e=this;e.attrTitleO.val("").attr("disabled",!0),e.attrHeightO.val("").attr("disabled",!0),e.attrWidthO.val("").attr("disabled",!0),e.attrConstrainO.prop("checked",!1).attr("disabled",!0)},scale:function(e){var t=this,a=t.attrConstrainO.is(":checked"),i=+t.attrWidthO.val(),s=+t.attrHeightO.val();if(!isNaN(i)&&!isNaN(s)){var r=t.getCurAttrs(),l=r.preWidth||r.width,n=r.preHeight||r.height;a&&l&&n&&(e?(s=parseInt(i/l*n),t.attrHeightO.val(s)):(i=parseInt(s/n*l),t.attrWidthO.val(i)));var o={width:i,height:s};return o}},getCurAttrs:function(){var e=this;return e.imageAttrs[e.curSrc]},setCurDataAttrs:function(e){var t=this,a=t.curLi.find("img");a.attr("data-width",e.width),a.attr("data-height",e.height),a.attr("data-title",e.title),t.imageAttrs[t.curSrc]=e},modifyAttr:function(e){var t=this,a=e.attr("id"),i=e.val(),s=t.getCurAttrs();if(s){switch(a){case"attrConstrain":i=0,e.is(":checked")&&(i=1),s.constrain=i;break;case"attrTitle":s.title=i;break;case"attrWidth":$.extend(s,t.scale(!0));break;case"attrHeight":$.extend(s,t.scale(!1))}t.setCurDataAttrs(s)}},initAttr:function(e){function t(e){e=e||{},a.attrTitleO.val(e.title).attr("disabled",!1),a.attrWidthO.val(e.width).attr("disabled",!1),a.attrHeightO.val(e.height).attr("disabled",!1),a.attrConstrainO.attr("disabled",!1),e.constrain?a.attrConstrainO.prop("checked",!0):a.attrConstrainO.prop("checked",!1),a.setCurDataAttrs(e)}var a=this;"object"!=typeof e&&(e=$("#preview").find('img[src="'+e+'"]').parent());var i=e.find("img").attr("src");a.curSrc=i,a.curLi=e;var s=a.imageAttrs[i];s=s||{},s&&s.width&&s.height?t(s):getImageSize(i,function(e){return e.title=s.title||"",e.constrain=1,e.preWidth=e.width,e.preHeight=e.height,i!=a.curSrc?(a.imageAttrs[i]=e,void a.setCurDataAttrs(s)):void t(e)})},needRefresh:!1,uploadRefreshImageList:function(){var e=this,t=$("#albumsForList").val();t==$("#albumsForUpload").val()&&(e.needRefresh=!0)},initUploader:function(){function e(e){return"number"!=typeof e?"":e>=1e9?(e/1e9).toFixed(2)+" GB":e>=1e6?(e/1e6).toFixed(2)+" MB":(e/1e3).toFixed(2)+" KB"}var t=this,a=$("#upload ul");$("#drop a").click(function(){$(this).parent().find("input").click()}),$("#upload").fileupload({dataType:"json",pasteZone:"",acceptFileTypes:/(\.|\/)(gif|jpg|jpeg|png|jpe)$/i,dropZone:$("#drop"),formData:function(e){return[{name:"albumId",value:$("#albumsForUpload").val()}]},add:function(t,i){var s=i.files[0].size,r=+parent.GlobalConfigs.uploadImageSize||100;if("number"==typeof s&&s>1048576*r){var l=$('
  • ');return l.find("div").append("Warning: "+i.files[0].name+" ["+e(i.files[0].size)+"] is bigger than "+r+"M "),void l.appendTo(a)}var l=$('
  • ');l.find("div").append(i.files[0].name+" ["+e(i.files[0].size)+"]"),i.context=l.appendTo(a);i.submit()},done:function(a,i){if(1==i.result.Ok)i.context.remove(),t.addSelectedImage(i.result.Id),t.uploadRefreshImageList();else{i.context.empty();var s=$('
  • ');s.find("div").append(""+getMsg("Error")+": "+i.files[0].name+" ["+e(i.files[0].size)+"] "+i.result.Msg),i.context.append(s),setTimeout(function(e){return function(){e.remove()}}(s),3e3)}$("#upload-msg").scrollTop(1e3)},fail:function(t,a){a.context.empty();var i=$('
  • ');i.find("div").append("Error: "+a.files[0].name+" ["+e(a.files[0].size)+"] "+a.errorThrown),a.context.append(i),$("#upload-msg").scrollTop(1e3)}}),$(document).on("drop dragover",function(e){e.preventDefault()}),$(document).bind("dragover",function(e){var t=$("#drop"),a=window.dropZoneTimeout;a?clearTimeout(a):t.addClass("in");var i=!1,s=e.target;do{if(s===t[0]){i=!0;break}s=s.parentNode}while(null!=s);i?t.addClass("hover"):t.removeClass("hover"),window.dropZoneTimeout=setTimeout(function(){window.dropZoneTimeout=null,t.removeClass("in hover")},100)})}};$(function(){o.init()}); \ No newline at end of file diff --git a/public/album/js/main.js b/public/album/js/main.js index d93160c..ab3a291 100644 --- a/public/album/js/main.js +++ b/public/album/js/main.js @@ -8,7 +8,7 @@ function retIsOk(ret) { return false; } -var urlPrefix = UrlPrefix; +var urlPrefix = ''; var getMsg = parent.getMsg; if (!getMsg) { getMsg = function(msg) { diff --git a/public/js/app.min.js b/public/js/app.min.js index 166f0e7..f249d6c 100644 --- a/public/js/app.min.js +++ b/public/js/app.min.js @@ -1,6 +1,6 @@ function trimLeft(t,e){if(!e||" "==e)return $.trim(t);for(;0==t.indexOf(e);)t=t.substring(e.length);return t}function json(str){return eval("("+str+")")}function t(){var t=arguments;if(t.length<=1)return t[0];var e=t[0];if(!e)return e;var n="LEAAEL";e=e.replace(/\?/g,n);for(var o=1;o<=t.length;++o)e=e.replace(n,t[o]);return e}function arrayEqual(t,e){return t=t||[],e=e||[],t.join(",")==e.join(",")}function isArray(t){return"[object Array]"===Object.prototype.toString.call(t)}function isEmpty(t){return t?isArray(t)&&0==t.length?!0:!1:!0}function getFormJsonData(t){var e=formArrDataToJson($("#"+t).serializeArray());return e}function formArrDataToJson(t){var e={},n={};for(var o in t){var r=t[o].name,i=t[o].value;"[]"!=r.substring(r.length-2,r.length)?e[r]=i:(r=r.substring(0,r.length-2),void 0==n[r]?n[r]=[i]:n[r].push(i))}return $.extend(e,n)}function formSerializeDataToJson(t){for(var e=t.split("&"),n={},o={},r=0;r

    '===e?"


    ":e}function _getEditorContent(t){if(t)return[MD.getContent(),"
    "+$("#preview-contents").html()+"
    "];var e=tinymce.activeEditor;if(e){var n=$(e.getBody()).clone();if(n.find(".toggle-raw").remove(),window.LeaAce&&LeaAce.getAce)for(var o=n.find("pre"),r=0;r/g,">"),i.removeAttr("style","").removeAttr("contenteditable").removeClass("ace_editor"),i.html(l)}}if(n.find("pinit").remove(),n.find(".thunderpin").remove(),n.find(".pin").parent().remove(),n=$(n).html())for(;;){var c=n.lastIndexOf("");if(-1==c)return n;var u=n.length;if(u-9!=c)return n;var f=n.lastIndexOf("