summaryrefslogtreecommitdiff
path: root/public/javascripts/admin_interface.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/javascripts/admin_interface.js')
-rw-r--r--public/javascripts/admin_interface.js99
1 files changed, 12 insertions, 87 deletions
diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js
index e9f96c2..f6d915f 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 }
@@ -110,14 +106,6 @@ $(document).ready(function () {
110}); 106});
111 107
112 108
113meta_data = {
114 initialize : function() {
115 document.getElementById("metadata_details").addEventListener("toggle", function() {
116 if (this.open) image_interface.initialize();
117 });
118 }
119};
120
121cccms = { 109cccms = {
122 setup_autosave : function() { 110 setup_autosave : function() {
123 111
@@ -277,10 +265,13 @@ cccms = {
277 265
278 var items = $('#related_asset_list li').map(function() { 266 var items = $('#related_asset_list li').map(function() {
279 return { 267 return {
268 id: $(this).data('asset-id'),
280 thumb: $(this).find('img').attr('src'), 269 thumb: $(this).find('img').attr('src'),
281 large: $(this).data('large-url'), 270 large: $(this).data('large-url'),
282 original: $(this).data('original-url'), 271 original: $(this).data('original-url'),
283 name: $(this).data('name') 272 name: $(this).data('name'),
273 hasCredit: $(this).data('has-credit') === true,
274 headline: $(this).data('headline') === true
284 }; 275 };
285 }).get(); 276 }).get();
286 cccms.inline_images.items = items; 277 cccms.inline_images.items = items;
@@ -293,7 +284,7 @@ cccms = {
293 items.forEach(function(item, i) { 284 items.forEach(function(item, i) {
294 var wrapper = $('<div class="inline_image_picker_item"></div>'); 285 var wrapper = $('<div class="inline_image_picker_item"></div>');
295 wrapper.append($('<img>').attr('src', item.thumb).attr('data-index', i)); 286 wrapper.append($('<img>').attr('src', item.thumb).attr('data-index', i));
296 if (i === 0) { 287 if (item.headline) {
297 wrapper.append($('<span>', { "class": "inline_image_picker_headline_badge" }).text("Headline")); 288 wrapper.append($('<span>', { "class": "inline_image_picker_headline_badge" }).text("Headline"));
298 } 289 }
299 grid.append(wrapper); 290 grid.append(wrapper);
@@ -317,8 +308,13 @@ cccms = {
317 ? 'inline-image inline-image--full' 308 ? 'inline-image inline-image--full'
318 : 'inline-image inline-image--half inline-image--' + placement; 309 : 'inline-image inline-image--half inline-image--' + placement;
319 310
320 var html = '<a href="' + item.original + '" class="glightbox" data-gallery="page-' + cccms.inline_images.node_id + '">' + 311 var esc = cccms.inline_images.escape_attr;
321 '<img src="' + item.large + '" class="' + classes + '" alt="' + cccms.inline_images.escape_attr(item.name) + '"></a>'; 312 var titleForGlightbox = (item.name || '').replace(/;/g, ',');
313 var glightboxOpts = 'title: ' + esc(titleForGlightbox) +
314 (item.hasCredit ? '; description: #credit_for_asset_' + esc(item.id) : '') + ';';
315 var html = '<a href="' + esc(item.original) + '" class="glightbox" data-gallery="page-' + esc(cccms.inline_images.node_id) + '"' +
316 ' data-glightbox="' + glightboxOpts + '">' +
317 '<img src="' + esc(item.large) + '" class="' + classes + '" alt="' + esc(item.name) + '"></a>';
322 318
323 cccms.inline_images.editor.insertContent(html); 319 cccms.inline_images.editor.insertContent(html);
324 $('#inline_image_picker').hide(); 320 $('#inline_image_picker').hide();
@@ -356,77 +352,6 @@ menu_item_sorter = {
356 } 352 }
357} 353}
358 354
359image_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
430rrule_builder = { 355rrule_builder = {
431 initialize : function() { 356 initialize : function() {
432 rrule_builder.try_populate_from_rrule($("#event_rrule").val()); 357 rrule_builder.try_populate_from_rrule($("#event_rrule").val());