Revision 565d9620

b/cloudcms/static/cloudcms/js/client-downloads.js
1
var ClientDownloads = function( wrapper, clients, cl_default) {
2
    this.el = $(wrapper);
3
    this.clients = clients; 
4
    this.cl_default = cl_default;
5
}
6

  
7
ClientDownloads.prototype.update = function() {
8
    
9
     
10
    var current_os = BrowserDetect.OS;
11
    //var current_os = "linux";
12
    var current_client = _.filter(this.clients, function(el){return el.os == current_os});
13
   
14
    if (_.isEmpty(current_client)){
15
    	current_os = this.cl_default;
16
    	var current_client = _.filter(this.clients, function(el){return el.os == current_os})[0];
17
    	
18
   
19
    } else {
20
    	current_client = current_client[0];
21
    }
22
    this.el.find("#os").html(current_client.os);
23
    this.el.find(".btn_01").attr('href',current_client.link);
24
    
25
    var new_list = _.filter(this.clients, function(el){return el.os != current_os});
26
    
27
    first = new_list.shift();
28
    popped = new_list.pop();
29
    
30
    this.el.find(".other-clients").append("<a href='"+first.link+"'>"+first.os+"</a>"); 
31
    var self = this;
32
    _.each(new_list, function(client) {
33
    	self.el.find(".other-clients").append(", <a href='"+client.link+"'>"+client.os+"</a>")
34
    })
35
    this.el.find(".other-clients").append(" and <a href='"+popped.link+"'>"+popped.os+"</a>.");
36
}
37

  
38
 
39

  
40

  
41

  
42
/* kpap
43

  
44

  
1 45
var ClientDownloads = function(wrapper, clients) {
2 46
    this.el = $(wrapper);
3 47
    this.clients = clients;
48
    console.log("test");
49
    console.log(this.clients);
50
    console.log("end test")
4 51
}
5 52

  
6 53
ClientDownloads.prototype.update = function() {
7 54
    console.log("updating clients");
8
}
55
    
56
    var current_os = "linux";
57
    var current_client = _.filter(this.clients, function(el){return el.os == current_os})[0];
58
    this.el.find(".current-os-link").html(current_client.os);
59
    
60
    var self = this;
61
    _.each(this.clients, function(client) {
62
    	self.el.find(".other-clients").append("<span>"+client.os+"</span>")
63
    })
64
    console.log(current_client);
65
}*/
9 66

  
b/cloudcms/static/cloudcms/js/os.js
1
//http://www.quirksmode.org/js/detect.html
1 2
var BrowserDetect = {
2 3
	init: function () {
3 4
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
......
94 95
		{
95 96
			string: navigator.platform,
96 97
			subString: "Win",
97
			identity: "Windows"
98
			identity: "windows"
98 99
		},
99 100
		{
100 101
			string: navigator.platform,
101 102
			subString: "Mac",
102
			identity: "Mac"
103
			identity: "MacOS"
103 104
		},
104 105
		{
105 106
			   string: navigator.userAgent,
106 107
			   subString: "iPhone",
107
			   identity: "iPhone/iPod"
108
			   identity: "iPhone"
108 109
	    },
109 110
		{
110 111
			string: navigator.platform,
111 112
			subString: "Linux",
112
			identity: "Linux"
113
			identity: "linux"
113 114
		}
114 115
	]
115 116

  
b/cloudcms/templates/content/client_downloads.html
1 1
<div class="clients-wrapper">
2
    <ul>
3
    </ul>
2
	<a class="btn_01" href="">
3
        <em>DOWNLOAD THE PITHOS CLIENT</em>
4
        <span id="os">&nbsp;</span>
5
    </a> 
6
    <p class="centered">Also available for <span class="other-clients"></span></p>
4 7
</div>
5 8

  
6 9
<script>
7 10
    $(document).ready(function(){
8
        if (window.ClientDownloads) {
9
            var clients_data = {{ content.client.to_json|safe }};
10
            var clients = new ClientDownloads(".clients-wrapper", clients_data);
11
        if (window.ClientDownloads) { 
12
        	
13
            var clients_data = {{ content.client.to_json|safe }};          
14
            var clients_default = 'windows';
15
            var clients = new ClientDownloads(".clients-wrapper", clients_data, clients_default);
11 16
            clients.update();
17
            
18
             
12 19
        }
13 20
    })
14 21
</script>

Also available in: Unified diff