diff options
Diffstat (limited to 'public/javascripts/admin_interface.js')
| -rw-r--r-- | public/javascripts/admin_interface.js | 111 |
1 files changed, 24 insertions, 87 deletions
diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js index e9f96c2..5514f3b 100644 --- a/public/javascripts/admin_interface.js +++ b/public/javascripts/admin_interface.js | |||
| @@ -45,10 +45,6 @@ $(document).ready(function () { | |||
| 45 | menu_item_sorter.initialize(); | 45 | menu_item_sorter.initialize(); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | if ($("#metadata").length != 0) { | ||
| 49 | meta_data.initialize(); | ||
| 50 | } | ||
| 51 | |||
| 52 | if ($("#parent_search_term").length != 0) { | 48 | if ($("#parent_search_term").length != 0) { |
| 53 | parent_search.initialize_search(); | 49 | parent_search.initialize_search(); |
| 54 | } | 50 | } |
| @@ -69,6 +65,10 @@ $(document).ready(function () { | |||
| 69 | related_assets.initialize(); | 65 | related_assets.initialize(); |
| 70 | } | 66 | } |
| 71 | 67 | ||
| 68 | if ($("#asset_node_search_term").length != 0) { | ||
| 69 | asset_node_search.initialize_search(); | ||
| 70 | } | ||
| 71 | |||
| 72 | if ($("#rrule_builder").length != 0) { | 72 | if ($("#rrule_builder").length != 0) { |
| 73 | rrule_builder.initialize(); | 73 | rrule_builder.initialize(); |
| 74 | } | 74 | } |
| @@ -77,6 +77,14 @@ $(document).ready(function () { | |||
| 77 | cccms.preview.initialize(); | 77 | cccms.preview.initialize(); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | var metadata_details = document.getElementById('metadata_details'); | ||
| 81 | if (metadata_details) { | ||
| 82 | var desktop_mq = window.matchMedia('(min-width: 1016px)'); | ||
| 83 | var sync_metadata = function() { metadata_details.open = desktop_mq.matches; }; | ||
| 84 | sync_metadata(); | ||
| 85 | desktop_mq.addEventListener('change', sync_metadata); | ||
| 86 | } | ||
| 87 | |||
| 80 | jQuery.ajaxSetup({ | 88 | jQuery.ajaxSetup({ |
| 81 | 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript");} | 89 | 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript");} |
| 82 | }); | 90 | }); |
| @@ -110,14 +118,6 @@ $(document).ready(function () { | |||
| 110 | }); | 118 | }); |
| 111 | 119 | ||
| 112 | 120 | ||
| 113 | meta_data = { | ||
| 114 | initialize : function() { | ||
| 115 | document.getElementById("metadata_details").addEventListener("toggle", function() { | ||
| 116 | if (this.open) image_interface.initialize(); | ||
| 117 | }); | ||
| 118 | } | ||
| 119 | }; | ||
| 120 | |||
| 121 | cccms = { | 121 | cccms = { |
| 122 | setup_autosave : function() { | 122 | setup_autosave : function() { |
| 123 | 123 | ||
| @@ -277,10 +277,13 @@ cccms = { | |||
| 277 | 277 | ||
| 278 | var items = $('#related_asset_list li').map(function() { | 278 | var items = $('#related_asset_list li').map(function() { |
| 279 | return { | 279 | return { |
| 280 | id: $(this).data('asset-id'), | ||
| 280 | thumb: $(this).find('img').attr('src'), | 281 | thumb: $(this).find('img').attr('src'), |
| 281 | large: $(this).data('large-url'), | 282 | large: $(this).data('large-url'), |
| 282 | original: $(this).data('original-url'), | 283 | original: $(this).data('original-url'), |
| 283 | name: $(this).data('name') | 284 | name: $(this).data('name'), |
| 285 | hasCredit: $(this).data('has-credit') === true, | ||
| 286 | headline: $(this).data('headline') === true | ||
| 284 | }; | 287 | }; |
| 285 | }).get(); | 288 | }).get(); |
| 286 | cccms.inline_images.items = items; | 289 | cccms.inline_images.items = items; |
| @@ -293,7 +296,7 @@ cccms = { | |||
| 293 | items.forEach(function(item, i) { | 296 | items.forEach(function(item, i) { |
| 294 | var wrapper = $('<div class="inline_image_picker_item"></div>'); | 297 | var wrapper = $('<div class="inline_image_picker_item"></div>'); |
| 295 | wrapper.append($('<img>').attr('src', item.thumb).attr('data-index', i)); | 298 | wrapper.append($('<img>').attr('src', item.thumb).attr('data-index', i)); |
| 296 | if (i === 0) { | 299 | if (item.headline) { |
| 297 | wrapper.append($('<span>', { "class": "inline_image_picker_headline_badge" }).text("Headline")); | 300 | wrapper.append($('<span>', { "class": "inline_image_picker_headline_badge" }).text("Headline")); |
| 298 | } | 301 | } |
| 299 | grid.append(wrapper); | 302 | grid.append(wrapper); |
| @@ -317,8 +320,13 @@ cccms = { | |||
| 317 | ? 'inline-image inline-image--full' | 320 | ? 'inline-image inline-image--full' |
| 318 | : 'inline-image inline-image--half inline-image--' + placement; | 321 | : 'inline-image inline-image--half inline-image--' + placement; |
| 319 | 322 | ||
| 320 | var html = '<a href="' + item.original + '" class="glightbox" data-gallery="page-' + cccms.inline_images.node_id + '">' + | 323 | var esc = cccms.inline_images.escape_attr; |
| 321 | '<img src="' + item.large + '" class="' + classes + '" alt="' + cccms.inline_images.escape_attr(item.name) + '"></a>'; | 324 | var titleForGlightbox = (item.name || '').replace(/;/g, ','); |
| 325 | var glightboxOpts = 'title: ' + esc(titleForGlightbox) + | ||
| 326 | (item.hasCredit ? '; description: #credit_for_asset_' + esc(item.id) : '') + ';'; | ||
| 327 | var html = '<a href="' + esc(item.original) + '" class="glightbox" data-gallery="page-' + esc(cccms.inline_images.node_id) + '"' + | ||
| 328 | ' data-glightbox="' + glightboxOpts + '">' + | ||
| 329 | '<img src="' + esc(item.large) + '" class="' + classes + '" alt="' + esc(item.name) + '"></a>'; | ||
| 322 | 330 | ||
| 323 | cccms.inline_images.editor.insertContent(html); | 331 | cccms.inline_images.editor.insertContent(html); |
| 324 | $('#inline_image_picker').hide(); | 332 | $('#inline_image_picker').hide(); |
| @@ -356,77 +364,6 @@ menu_item_sorter = { | |||
| 356 | } | 364 | } |
| 357 | } | 365 | } |
| 358 | 366 | ||
| 359 | image_interface = { | ||
| 360 | |||
| 361 | initialize : function() { | ||
| 362 | |||
| 363 | $("#image_browser").hide(); | ||
| 364 | image_interface.initialize_sortable_image_box(); | ||
| 365 | image_interface.connect_browser_and_box(); | ||
| 366 | image_interface.set_droppable_behavior(); | ||
| 367 | image_interface.bind_image_browser_toggle(); | ||
| 368 | }, | ||
| 369 | |||
| 370 | |||
| 371 | set_droppable_behavior : function() { | ||
| 372 | $("ul#image_box").droppable({ | ||
| 373 | out : function(event, ui) { | ||
| 374 | $(ui.draggable).fadeTo("fast", 0.4); | ||
| 375 | |||
| 376 | $(ui.draggable).bind("mouseup", function() { | ||
| 377 | $(this).remove(); | ||
| 378 | }); | ||
| 379 | }, | ||
| 380 | over : function(event, ui) { | ||
| 381 | $(ui.draggable).fadeTo("fast", 1.0); | ||
| 382 | $(ui.draggable).unbind("mouseup"); | ||
| 383 | } | ||
| 384 | }); | ||
| 385 | }, | ||
| 386 | |||
| 387 | connect_browser_and_box : function() { | ||
| 388 | $("#image_browser ul li").draggable({ | ||
| 389 | connectToSortable : 'ul#image_box', | ||
| 390 | helper : 'clone', | ||
| 391 | revert : 'invalid' | ||
| 392 | }); | ||
| 393 | }, | ||
| 394 | |||
| 395 | initialize_sortable_image_box : function() { | ||
| 396 | |||
| 397 | $("ul#image_box").sortable({ | ||
| 398 | revert : true, | ||
| 399 | update : function(event, ui) { | ||
| 400 | images = $("ul#image_box").sortable("serialize", {attribute : "rel"}); | ||
| 401 | |||
| 402 | $.ajax({ | ||
| 403 | type : "POST", | ||
| 404 | url : "/pages/" + $("ul#image_box").attr("rel") + "/sort_images", | ||
| 405 | dataType : "json", | ||
| 406 | data : images + "&_method=put", | ||
| 407 | success : function() { | ||
| 408 | } | ||
| 409 | }); | ||
| 410 | } | ||
| 411 | }); | ||
| 412 | }, | ||
| 413 | |||
| 414 | bind_image_browser_toggle : function() { | ||
| 415 | $("#image_browser_toggle").bind("click", function(){ | ||
| 416 | if ($("#image_browser_toggle").attr("class") == "unselected") { | ||
| 417 | $("#image_browser_toggle").attr("class", "selected"); | ||
| 418 | $("#image_browser").show(); | ||
| 419 | } | ||
| 420 | else { | ||
| 421 | $("#image_browser_toggle").attr("class", "unselected"); | ||
| 422 | $("#image_browser").hide(); | ||
| 423 | } | ||
| 424 | |||
| 425 | return false; | ||
| 426 | }); | ||
| 427 | } | ||
| 428 | } | ||
| 429 | |||
| 430 | rrule_builder = { | 367 | rrule_builder = { |
| 431 | initialize : function() { | 368 | initialize : function() { |
| 432 | rrule_builder.try_populate_from_rrule($("#event_rrule").val()); | 369 | rrule_builder.try_populate_from_rrule($("#event_rrule").val()); |
