diff options
Diffstat (limited to 'themes/okadmin/public/js/app.js')
| -rw-r--r-- | themes/okadmin/public/js/app.js | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/themes/okadmin/public/js/app.js b/themes/okadmin/public/js/app.js index 2667ce6..d58cb2a 100644 --- a/themes/okadmin/public/js/app.js +++ b/themes/okadmin/public/js/app.js @@ -99,7 +99,44 @@ var OKAdmin = function(){ $el.parent().find(".video-thumb").val( media.thumbnail ) }) })) - + + // Add a new link to the list + $('.link-list').on('click', '.add-link-btn', function(e) { + e.preventDefault() + e.stopPropagation() + var $delegate = $(e.delegateTarget) + var $list = $delegate.find('.links') + var length = $list.find('input').length + var name = $delegate.parent('.property').data('name') + var $new = $delegate.find('.link-input-new') + var input = document.createElement('input') + var delBtn = document.createElement('button') + var inputName = name + '[' + length + ']' + $(input).attr({ + name: inputName, + type: 'text', + value: $new.val() + }) + $list.append(input) + $(delBtn).addClass('remove-link-btn') + $(delBtn).data('for', inputName) + delBtn.innerHTML = '-' + $list.append(delBtn) + $new.val('') + }) + + // Remove a link from the list + $('.link-list').on('click', '.remove-link-btn', function(e) { + e.preventDefault() + e.stopPropagation() + var $delegate = $(e.delegateTarget) + var $target = $(e.target) + var inputName = $target.data('for') + var $input = $delegate.find('[name="' + inputName + '"]') + $input.remove() + $target.remove() + }) + // fix post indexing in list-driven inputs $(".main.resource form").submit(function(e){ var $id = $("[name=id]"), $title = $("[name=title]"), $menu = $("[name=menu]"), $section = $(".resource.main") @@ -125,6 +162,25 @@ var OKAdmin = function(){ $id.val( slug ) } + // Parse date input + $('.property .date').each(function(i, el) { + var name = $(el).parent('.property').data('name') + var $input = $(el).find('input') + var date = new Date($input.val()) + // Set to middle of day so it is the same date + // for all locales + date.setUTCHours(12) + var dateString = date.toUTCString() + var normalizedInput = document.createElement('input') + $(normalizedInput).attr({ + name: name, + type: 'text', + value: dateString + }) + $input.remove() + $(el).append(normalizedInput) + }) + $("ol").each(function(){ $("li", this).each(function(index){ $(this).find("input,textarea").each(function(){ |
