{I" class:ETI"BundledAsset;FI"logical_path;TI"+spotlight/blocks/multi_up_item_grid.js;FI" pathname;TI"g/Users/cabeer/Projects/sul/spotlight/app/assets/javascripts/spotlight/blocks/multi_up_item_grid.js;FI"content_type;TI"application/javascript;TI" mtime;Tl+Ť¾TI" length;Ti<'I" digest;TI"%2fc989b172ac46b795768f51914ae563;FI" source;TI"<'/* Sir Trevor MutliUpItemGrid Block. This block takes an ID, fetches the record from solr, displays the image, title, and any provided text and displays them. */ SirTrevor.Blocks.MultiUpItemGrid = (function(){ return Spotlight.Block.extend({ key: "item-grid", id_key: "item-grid-id", display_checkbox: "item-grid-display", panel: 'typeahead-panel', thumbnail_key: 'item-grid-thumbnail', primary_field_key: "item-grid-primary-caption-field", show_primary_caption: "show-primary-caption", secondary_field_key: "item-grid-secondary-caption-field", show_secondary_caption: "show-secondary-caption", auto_play_images_key: "auto-play-images", auto_play_images_interval_key: "auto-play-images-interval", max_height_key: "max-height", title_key: "spotlight_title_field", type: "multi-up-item-grid", title: function() { return "Multi-Up Item Grid"; }, blockGroup: 'Exhibit item widgets', icon_name: "multi-up-item-grid", inputFieldsCount: 5, carouselCycleTimesInSeconds: { values: [ 3, 5, 8, 12, 20 ], selected: 5 }, carouselMaxHeights: { values: { 'Small': 200, 'Medium': 350, 'Large': 500 }, selected: 'Medium' }, onBlockRender: function() { Spotlight.Block.prototype.onBlockRender.apply(); this.loadCaptionField(); this.addCaptionSelectFocus(); this.makeItemGridNestable(); }, afterLoadData: function(data){ // set a data attribute on the select fields so the ajax request knows which option to select this.$('select#' + this.formId(this.primary_field_key)).data('select-after-ajax', data[this.primary_field_key]); this.$('select#' + this.formId(this.secondary_field_key)).data('select-after-ajax', data[this.secondary_field_key]); var context = this; context.$('[data-target-panel]').each(function(i){ if ($(this).prop("value") != "") { var target_panel = $(this), object_id = data[context.id_key + "_" + i], object_title = data[context.id_key + "_" + i + "_title"], object_thumbnail = data[context.thumbnail_key + "_" + i]; $.ajax($('form[data-autocomplete-url]').data('autocomplete-url') + '?q=id:' + object_id).success(function(ajaxData){ var thumbnails = ajaxData['docs'][0]['thumbnails'], privateLabel = ajaxData['docs'][0]['private']; swapInputForPanel(target_panel, context.$(target_panel.data('target-panel')), { id: object_id, title: object_title, thumbnail: object_thumbnail, thumbnails: thumbnails, private: privateLabel }); }); } }); }, description: "This widget displays one to five thumbnail images of repository items in a single row grid. Optionally, you can a caption below each image..", template: [ '
', '
', '<%= description %>', '
', '
', '', '
', '
    ', '<%= buildInputFields(inputFieldsCount) %>', '
', '
', '
', '
', '
', '', '', '', '
', '
', '', '', '', '
', '<%= addCarouselFields() %>', '
', '
' ].join("\n"), makeItemGridNestable: function() { SpotlightNestable.init(); $('.nestable-item-grid').on('change', function(){ var i = 0; $('li.dd-item', $(this)).each(function(){ $("[data-nestable-observe]", $(this)).each(function(){ replaceName($(this), i) }); replaceName($("[data-target-panel='#" + $(this).attr('id') + "']"), i); i++; }); }); addRemoveAutocompletedPanelBehavior(); }, buildInputFields: function(times) { var output = ''; for(var i=0; i < times; i++){ output += '
'; output += ''; output += '" data-checkbox_field="#<%= formId(display_checkbox + "_' + i + '") %>" data-id_field="#<%= formId(id_key + "_' + i + '") %>" name="<%= id_key + "_' + i + '_title" %>" class="st-input-string item-grid-input form-control" data-twitter-typeahead="true" type="text" id="<%= formId(id_key + "_' + i + '_title") %>" data-nestable-observe="true" />'; output += '
'; } return _.template(output)(this); }, addCarouselFields: function() { var tpl = ''; if (this.type === 'item-carousel') { tpl = [ '
', '', '', '', '
', '
', '
', '<%= addCarouselMaxHeightOptions(carouselMaxHeights) %>', '
', ].join("\n"); } return _.template(tpl)(this); }, addCarouselCycleOptions: function(options) { var html = ''; $.each(options.values, function(index, interval) { var selected = (interval === options.selected) ? 'selected' : '', intervalInMilliSeconds = parseInt(interval, 10) * 1000; html += ''; }); return html; }, addCarouselMaxHeightOptions: function(options) { var html = '', _this = this; $.each(options.values, function(size, px) { var checked = (size === options.selected) ? 'checked' : '', id = _this.formId(_this.max_height_key) html += ''; html += ''; }); return html; } }); })(); ;TI"required_assets_digest;TI"%ea45592ae9b547c697f43a09175c204b;FI" _version;TI"%069e88c06b889877799890854d7f4c40;F