File: view-css.js

package info (click to toggle)
webdeveloper 1.2.5%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,364 kB
  • ctags: 1,608
  • sloc: makefile: 10
file content (91 lines) | stat: -rw-r--r-- 2,881 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
var WebDeveloper = WebDeveloper || {};

WebDeveloper.Generated = WebDeveloper.Generated || {};

// Initializes the page with data
WebDeveloper.Generated.initialize = function(data, locale)
{
  var contentDocument    = null;
  var css                = locale.css;
  var documents          = data.documents;
  var embeddedContainers = null;
  var embeddedCSSFrom    = locale.embeddedCSSFrom;
  var styleSheets        = null;
  var styleSheetsCount   = null;
  var styleSheetsCounter = 1;
  var url                = null;
  var urlContentRequests = [];

  WebDeveloper.Generated.emptyContent();
  WebDeveloper.Generated.localizeHeader(locale);
  WebDeveloper.Generated.setPageTitle(css, data, locale);
  $(".dropdown-toggle", $("#files-dropdown")).prepend(css);

  // Loop through the documents
  for(var i = 0, l = documents.length; i < l; i++)
  {
    contentDocument  = documents[i];
    styleSheets      = contentDocument.styleSheets;
    styleSheetsCount = styleSheets.length;
    url              = contentDocument.url;

    WebDeveloper.Generated.addDocument(url, i);

    // If there are embedded styles
    if(contentDocument.embedded)
    {
      embeddedContainers = WebDeveloper.Generated.output(embeddedCSSFrom + " " + url, null, "style-sheet-" + (styleSheetsCounter++), "css");

      // Loop through the embedded containers
      for(var j = 0, m = embeddedContainers.length; j < m; j++)
      {
        embeddedContainers[j].text(contentDocument.embedded);
      }
    }

    // Loop through the style sheets
    for(var k = 0; k < styleSheetsCount; k++)
    {
      url = styleSheets[k];

      urlContentRequests.push({ "outputContainers": WebDeveloper.Generated.output(null, url, "style-sheet-" + (styleSheetsCounter++), "css"), "url": url });
    }

    // If there are no style sheets
    if(!contentDocument.embedded && styleSheetsCount === 0)
    {
      WebDeveloper.Generated.addSeparator();
    }
  }

  WebDeveloper.Generated.initializeCommonElements();

  // If there are external style sheets to get the CSS from
  if(urlContentRequests.length)
  {
    WebDeveloper.Common.getURLContents(urlContentRequests, "/* " + locale.couldNotLoadCSS + " */", function()
    {
      var outputContainers  = null;
      var urlContentRequest = null;

      // Loop through the URL content requests
      for(var n = 0, p = urlContentRequests.length; n < p; n++)
      {
        urlContentRequest = urlContentRequests[n];
        outputContainers  = urlContentRequest.outputContainers;

        // Loop through the output containers
        for(var q = 0, r = outputContainers.length; q < r; q++)
        {
          outputContainers[q].text(urlContentRequest.content);
        }
      }

      WebDeveloper.Generated.initializeSyntaxHighlight(data.theme, locale);
    });
  }
  else
  {
    WebDeveloper.Generated.initializeSyntaxHighlight(data.theme, locale);
  }
};