Project

General

Profile

« Previous | Next » 

Revision 60324

[Library|Trunk]
Cite this component:
- show download (not only in dev)
- UI updates
- show citation after the user selects a format.

View differences:

modules/uoa-services-library/trunk/ng-openaire-library/src/app/landingPages/landing-utils/citeThis/citeThis.component.ts
30 30
                      [value]="style">{{style}}</mat-option>
31 31
        </mat-select>
32 32
      </mat-form-field>
33
      <div *ngIf="selectedStyle">
34
        <div id="citation" class="box-content uk-margin-small-top uk-overflow-auto uk-padding-small" [innerHTML]=citationText></div>
35
        <button class="clipboard_btn uk-button uk-button-primary uk-button-small copy uk-margin-small-top uk-icon uk-float-right"
36
            data-clipboard-target="#citation" title="Copy to clipboard">
37
          <span class="custom-icon custom-copy-white"></span>
38
          <span class="uk-margin-small-left">COPY</span>
39
        </button>
33
      <div *ngIf="selectedStyle" class="box-content uk-grid uk-margin-auto ">
34
        <div id="citation" class="  uk-overflow-auto uk-padding-small" [innerHTML]=citationText></div>
35
        <div class="uk-width-1-1">
36
          <button class="clipboard_btn uk-button uk-button-primary uk-button-small copy  uk-icon uk-float-right"
37
              data-clipboard-target="#citation" title="Copy to clipboard">
38
            <span class="custom-icon custom-copy-white"></span>
39
<!--            <span class="uk-margin-small-left">COPY</span>-->
40
          </button>
41
        </div>
40 42
      </div>
41
      <div *ngIf="properties.environment == 'development'" class="uk-margin-small-top">
43
      <div  class="uk-margin-top">
42 44
        <mat-form-field class="matSelectionFormField uk-width-1-1">
43 45
          <mat-label>Or select file format to download</mat-label>
44 46
          <mat-select class="matSelection" id="fileformats" name="fileformatsSelect" [(ngModel)]="selectedFormat"
......
49 51
                        [value]="format">{{format + " (" +citation.fileSuffix[i] + ")"}}</mat-option>
50 52
          </mat-select>
51 53
        </mat-form-field>
52
       
53
       <!-- <div *ngIf="selectedFormat">
54
          <div id="citation" class="box-content uk-margin-small-top uk-overflow-auto uk-padding-small" [innerHTML]="fileText"></div>
55
        </div>-->
56
        <button class="  uk-button uk-button-primary uk-button-small copy uk-margin-small-top uk-icon uk-float-right"
54
        <button  *ngIf="selectedFormat" class="  uk-button uk-button-primary uk-button-small uk-margin-small-top uk-icon uk-float-right"
57 55
                title="Copy to clipboard" [disabled]="!selectedFormat" (click)="downloadFile()">
58 56
          <span class="custom-icon " uk-icon="download"></span>
59 57
          <span class="uk-margin-small-left">Download</span>
......
99 97
        renderer.appendChild(head, script);
100 98
        this.timeout = setTimeout(() => {
101 99
          const script2 = renderer.createElement('script');
100
          renderer.setAttribute(script2, "id", "citationjs2");
102 101
          renderer.setAttribute(script2, "type", "text/javascript");
103 102
          renderer.setProperty(script2,  "text","const Cite = require('citation-js')");
104 103
          renderer.appendChild(head, script2);
105
        }, 300);
104
        }, 500);
106 105
      }
107
    this.timeout = setTimeout(() => {
108
      this.citeConfig = Cite.plugins.config.get('csl');
109
      this.cite = new Cite();
110
      this.parseData();
111
      this.selectedStyle = this.citation.templates[0];
112
      this.selectedFormat = this.citation.fileFormats[0];
113
      this.styleChanged();
114
      this.formatChanged();
115
      this.createClipboard();
116
    }, 800);
117 106

  
118 107
  }catch (e) {
119 108
    console.error(e)
......
124 113
    delete this.clipboard;
125 114
    clearTimeout(this.timeout);
126 115
  }
127
  
116
  private initiate(){
117
    this.citeConfig = Cite.plugins.config.get('csl');
118
    this.cite = new Cite();
119
    this.parseData();
120
    this.createClipboard();
121
  }
128 122
  private createClipboard() {
129 123
    if (typeof window !== 'undefined') {
130 124
      delete this.clipboard;
......
261 255
   * @param format
262 256
   */
263 257
  getFormat(format:string) {
258
    if(!this.cite){
259
      this.initiate();
260
    }
264 261
    return this.cite.format(format, {
265 262
      format: 'text'
266 263
    });
......
273 270
   */
274 271

  
275 272
  getBibliography(template:string) {
273
    if(!this.cite || !this.citeConfig ){
274
      this.initiate();
275
    }
276 276
    if (!this.citeConfig.templates.get(template)) {
277 277
      this.citeConfig.templates.add(template, this.citation[template]);
278 278
    }

Also available in: Unified diff