Sha256: 45d034d461a2cecba18bfa3c5d1f8832578691e1e6b3a1dd1b8bacaabecdff37

Contents?: true

Size: 1.63 KB

Versions: 62

Compression:

Stored size: 1.63 KB

Contents

/**
 * @namespace WORKAREA.assetPickerFields
 */
WORKAREA.registerModule('assetPickerFields', (function () {
    'use strict';

    var addAsset = function (assetPickerField, event, asset) {
            $('input', assetPickerField).val(asset.id).trigger('change');
            $('[data-asset-name]', assetPickerField).text(asset.name);
            $('[data-asset-url]', assetPickerField).val(asset.url).trigger('change');
            $(window).off('assetPickers:insert');
        },

        clearAsset = function (event) {
            var assetPickerField = event.delegateTarget;

            $('input', assetPickerField).val('').trigger('change');
            $('[data-asset-name]', assetPickerField).text(
                I18n.t('workarea.admin.content_blocks.asset.name_missing')
            );
        },

        openAssetPickerTakeover = function (event) {
            event.preventDefault();

            $.get(event.currentTarget.href).done(function (response) {
                WORKAREA.takeover.open(response, {
                    reloadUrl: event.currentTarget.href
                });
            });

            $(window).on(
                'assetPickers:insert', _.partial(addAsset, event.delegateTarget)
            );
        },

        /**
         * @method
         * @name init
         * @memberof WORKAREA.assetPickerFields
         */
        init = function ($scope) {
            $('[data-asset-picker-field]', $scope)
            .on('click', '[data-asset-picker-field-open]', openAssetPickerTakeover)
            .on('click', '[data-asset-picker-field-clear]', clearAsset);
        };

    return {
        init: init
    };
}()));

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-admin-3.5.27 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.5.26 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.45 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.5.25 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.5.23 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.44 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.5.22 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.43 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.5.21 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.42 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.5.20 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.41 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.5.19 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.40 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.5.18 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.39 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.5.17 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.38 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.5.16 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.37 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js