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.4.27 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.5.4 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.26 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.5.3 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.25 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.5.2 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.24 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.5.1 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.23 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.22 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.5.0 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.21 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.5.0.beta.1 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.20 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.19 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.18 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.17 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.16 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.15 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js
workarea-admin-3.4.14 app/assets/javascripts/workarea/admin/modules/asset_picker_fields.js