Sha256: 9fd3d979bd9fc77c81acc96d2e38460147e735e154934e5cf9235fd1445ea732

Contents?: true

Size: 1.5 KB

Versions: 24

Compression:

Stored size: 1.5 KB

Contents

FORGE.features.fileSelectWidget = {
  init: function () {
    var self = FORGE.features.fileSelectWidget;
    $(document)
      .on('click', 'a.select-asset',  self.selectAsset)
      .on('click', 'a.upload-file', self.uploadFile)
      .on('click', 'a.attach-to-object', self.attachToObject);
  },
  
  selectAsset: function (event) {
    event.preventDefault();
    var self = FORGE.features.fileSelectWidget,
        $this = $(this);
    
    FORGE.assetDrawer.asset_id_container = $this.closest('div').find('.file-widget-asset-id').attr('id')
    FORGE.assetDrawer.asset_url_container = $this.closest('div').find('.file-widget-asset-url').attr('id')
    FORGE.assetDrawer.load(null, '/forge/assets/drawer?single=true');
  },
  
  uploadFile: function (event) {
    event.preventDefault();
    var self = FORGE.features.fileSelectWidget,
        $this = $(this);
    
    FORGE.assetDrawer.asset_id_container = $this.closest('div').find('.file-widget-asset-id').attr('id');
    FORGE.assetDrawer.asset_url_container = $this.closest('div').find('.file-widget-asset-url').attr('id');
    FORGE.features.assets.dialog.showNew('#new-asset-dialog', '/forge/assets/new?single=true&for_model=true');
  },
  
  attachToObject: function (event) {
    event.preventDefault();
    var self = FORGE.features.fileSelectWidget,
        $this = $(this);
    
    var id =  $(this).closest('li').attr('id').replace('asset_', ''),
        url = $(this).closest('li').find('img').attr('src');
    FORGE.assetDrawer.attachToObject(id, url);
  },
};

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
forge-cli-0.1.10 lib/forge/app/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.1.9 lib/forge/app/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.1.8 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.1.7 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.1.6 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.1.5 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.1.4 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.1.3 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.1.2 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.1.1 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.1.0 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.0.18 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.0.17 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.0.16 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.0.15 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.0.14 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.0.13 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.0.12 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.0.11 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb
forge-cli-0.0.10 lib/forge/lib/assets/javascripts/forge/features/file_select_widget.js.erb