1 line
No EOL
3.3 KiB
JavaScript
1 line
No EOL
3.3 KiB
JavaScript
!function(t){t.fn.date=function(){return this.each(function(){if(t(this).data("pikaday"))return t(this);var e=t(this).attr("type","text"),a=e.next(),n=e.data("format"),r=e.val(),i=r?moment(r).format(n):null;if(e.attr("placeholder",n),e.val(i),e.is("[readonly]"))return!1;e.on("change",function(){var t=e.val();t?a.val(moment(t,n).format("YYYY-MM-DD")):a.val("")});var o=new Pikaday({field:this,firstDay:1,format:n,i18n:e.data("i18n"),onSelect:function(t){a.val(moment(t).format("YYYY-MM-DD"))}});t(this).data("pikaday",o)})}}(jQuery),function(t){t.fn.imagefield=function(){return this.each(function(){var e=t(this);if(e.data("imagefield"))return!0;e.data("imagefield",!0);var a=e.find("select"),n=e.find(".input-preview figure"),r=n.parent("a");a.on("keydown change",function(){var t=a.find("option:selected"),e=t.data("url"),i=t.data("thumb");""===t.val()&&(e="#"),i?n.attr("style","background-image: url("+i+")"):n.attr("style","background-image: none"),r.attr("href",e)}).trigger("change"),e.find(".input-preview").on("click",function(){return"#"==t(this).attr("href")?!1:void 0}),e.find(".input").droppable({hoverClass:"over",accept:t(".sidebar .draggable-file"),drop:function(e,a){t(this).find("select").val(a.draggable.data("helper")).trigger("change")}})})}}(jQuery),function(t){var e=function(e){var a=t(e),n=a.data("style"),r=a.data("api"),i=a.data("sortable"),o="table"==n?a.find(".structure-table tbody"):a.find(".structure-entries");return i===!1?!1:void o.sortable({helper:function(e,a){return a.children().each(function(){t(this).width(t(this).width())}),a.addClass("structure-sortable-helper")},update:function(){var e=[];t.each(t(this).sortable("toArray"),function(t,a){e.push(a.replace("structure-entry-",""))}),t.post(r,{ids:e},function(){app.content.reload()})}})};t.fn.structure=function(){return this.each(function(){if(t(this).data("structure"))return t(this);var a=new e(this);return t(this).data("structure",a),t(this)})}}(jQuery),function(t){t.fn.counter=function(){return this.each(function(){var e=t(this);if(e.data("counter"))return e;var a=e.parent(".field").find(".input"),n=t.trim(a.val()).length,r=a.data("max"),i=a.data("min");a.keyup(function(){n=t.trim(a.val()).length,e.text(n+(r?"/"+r:"")),r&&n>r||i&&i>n?e.addClass("outside-range"):e.removeClass("outside-range")}).trigger("keyup"),e.data("counter",!0)})}}(jQuery),function(t){t.fn.editor=function(){return this.each(function(){if(t(this).data("editor"))return t(this);var e=t(this),a=e.parent().find(".field-buttons");e.autosize(),a.find(".btn").on("click.editorButton",function(a){e.focus();var n=t(this);if(n.data("action"))app.modal.open(n.data("action"),window.location.href);else{var r=e.getSelection(),i=n.data("tpl"),o=n.data("text");r.length>0&&(o=r);var u=i.replace("{text}",o);e.insertAtCursor(u),e.trigger("autosize.resize")}return!1}),a.find("[data-editor-shortcut]").each(function(a,n){var r=t(this).data("editor-shortcut"),i=function(e){return t(n).trigger("click"),!1};e.bind("keydown",r,i),r.match(/meta\+/)&&e.bind("keydown",r.replace("meta+","ctrl+"),i)}),e.data("editor",!0)})}}(jQuery),function(t){t.fn.urlfield=function(){return this.each(function(){var e=t(this);if(!e.data("urlfield")){e.data("urlfield",!0);var a=e.next(".field-icon");a.css({cursor:"pointer","pointer-events":"auto"}),a.on("click",function(){var a=t.trim(e.val());""!==a&&e.is(":valid")?window.open(a):e.focus()})}})}}(jQuery); |