Advertisement
Guest User

faerjhkg

a guest
Sep 30th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sys.apps = {
  2.     opened: {},
  3.     openedFocuses: [],
  4.     defaultWidth: 500,
  5.     defaultHeight: 275,
  6.     defaultIcon: 'fa-square-o',
  7.     defaultColor: '#808080',
  8.     listApps: function(){
  9.         $('#panel .listedapp').remove();
  10.         var keyss = [];
  11.         for(var k in sys.apps.installed) keyss.push(k);
  12.         keyss.sort();
  13.         for(i=0;i<keyss.length;i++){
  14.             if(sys.apps.installed[keyss[i]].hidden == false){
  15.                 icon = sys.apps.installed[keyss[i]].icon;
  16.                 color = sys.apps.installed[keyss[i]].color;
  17.                 if(icon == "default" || icon == false){icon = sys.apps.defaultIcon}
  18.                 if(color == "default" || color == false){color = sys.apps.defaultColor}
  19.                 $('#panel').append('\
  20.                    <div class="listedapp">\
  21.                        <div class="listedapp_icon" onclick="sys.apps.register('+"'"+sys.apps.installed[keyss[i]].appName+"'"+')" style="background-color:'+color+';"><i class="fa '+icon+'"></i></div>\
  22.                        <div class="listedapp_title">'+sys.apps.installed[keyss[i]].appFullName+'</div>\
  23.                    </div>\
  24.                ')
  25.             }
  26.         }
  27.     },
  28.     register: function(app){
  29.         if(typeof(sys.apps.installed[app]) == "undefined" || typeof(sys.apps.installed[app]) != "object"){
  30.             console.error('ERROR sys.apps.register: Aplikacja o nazwie '+app+' nie istnieje!')
  31.             return false;
  32.         }
  33.         id = Math.floor((Math.random() * 99999999) + 1);
  34.         sys.apps.openedFocuses.push('app'+id);
  35.         sys.apps.opened[id] = {
  36.             "id": id,
  37.             "icon": sys.apps.installed[app].icon,
  38.             "color": sys.apps.installed[app].color,
  39.             "appName": sys.apps.installed[app].appName,
  40.             "appTitle": sys.apps.installed[app].appTitle,
  41.             "width": sys.apps.installed[app].width,
  42.             "height": sys.apps.installed[app].height,            
  43.             "maxWidth": sys.apps.installed[app].maxWidth,
  44.             "maxHeight": sys.apps.installed[app].maxHeight,            
  45.             "minWidth": sys.apps.installed[app].minWidth,
  46.             "minHeight": sys.apps.installed[app].minHeight,
  47.             "resizable": sys.apps.installed[app].resizable,
  48.         };
  49.         sys.apps.pushWindow(id, sys.apps.installed[app].icon, sys.apps.installed[app].color, sys.apps.installed[app].appName, sys.apps.installed[app].appFullName, sys.apps.installed[app].appTitle, sys.apps.installed[app].width, sys.apps.installed[app].height, sys.apps.installed[app].maxWidth, sys.apps.installed[app].maxHeight, sys.apps.installed[app].minWidth, sys.apps.installed[app].minHeight, sys.apps.installed[app].resizable, sys.apps.installed[app].content);
  50.     },
  51.     pushWindow: function(id, icon, color, appName, appFullName, appTitle, width, height, maxWidth, maxHeight, minWidth, minHeight, resizable, content){
  52.         if(width == "default"){width = sys.apps.defaultWidth}
  53.         if(height == "default"){height = sys.apps.defaultHeight}
  54.         if(icon == "default" || icon == false){icon = sys.apps.defaultIcon}
  55.        
  56.         $('#windows_handler').prepend('\
  57.            <div id="app'+id+'" onmousedown="sys.apps.changeFocus('+id+')" style="width:'+width+'px;height:'+height+'px;" class="ui-widget-content window window_fade">\
  58.                <div class="window_handle">\
  59.                    <div class="window_title"><i class="fa '+icon+'"></i>'+appTitle+'</div>\
  60.                    <div class="window_close" onclick="sys.apps.closeWindow('+id+')"><i class="fa fa-times"></i>\
  61.                    </div>\
  62.                </div>\
  63.                <div class="window_content"></div>\
  64.            </div>\
  65.        ');
  66.        
  67.         $('#app'+id).draggable({ containment: "#windows_handler", scroll: false, handle: "div.window_handle:nth-child(1)"});
  68.         $('#app'+id).removeClass('window_fade');
  69.        
  70.         if(resizable == true){
  71.             $('#app'+id).addClass('ui-resizable');
  72.             $('#app'+id).resizable({containment: "#windows_handler"});
  73.             $('#app'+id+' .window_handle').append('<div class="window_full" onclick="sys.apps.fullSizeWindow('+id+')"><i class="fa fa-expand"></i></div>');
  74.             $('#app'+id+' .window_handle').append('<div class="window_mini" onclick="sys.apps.defaultSizeWindow('+id+')"><i class="fa fa-compress"></i></div>')
  75.         }
  76.        
  77.         if(content != false){
  78.             /*
  79.             $.get( content, function(data) {
  80.               $("#app"+id+" .window_content").html(data);
  81.             })
  82.             .fail(function() {
  83.                 $("#app"+id+" .window_content").text("ERROR");
  84.             });
  85.             //----
  86.             $.ajax({
  87.                 url: content,
  88.                 success: function (data) {$("#app"+id+" .window_content").html(data);},
  89.                 dataType: 'html'
  90.             });*/
  91.             $("#app"+id+" .window_content").html(content);
  92.         }
  93.        
  94.         if(minHeight != "default" && minHeight != false){
  95.             $('#app'+id).css("minHeight", minHeight+'px');
  96.         }
  97.         if(minWidth != "default" && minWidth != false){
  98.             $('#app'+id).css("minWidth", minWidth+'px');
  99.         }        
  100.         if(maxHeight != "default" && maxHeight != false){
  101.             $('#app'+id).css("maxHeight", maxHeight+'px');
  102.         }        
  103.         if(maxWidth != "default" && maxWidth != false){
  104.             $('#app'+id).css("maxWidth", maxWidth+'px');
  105.         }
  106.         if(color != "default" && maxWidth != false){
  107.             $('#app'+id).css("borderColor", color);
  108.             $('#app'+id+' .window_handle').css("backgroundColor", color);
  109.         }
  110.        
  111.         sys.apps.changeFocus(id);
  112.         sys.apps.centerWindow(id);
  113.     },
  114.     closeWindow: function(id){
  115.         if(typeof(sys.apps.opened[id]) == "undefined" || typeof(sys.apps.opened[id]) != "object"){
  116.             console.error('ERROR sys.apps.closeWindow: Aplikacja o nazwie '+id+' nie istnieje!')
  117.             return false;
  118.         }
  119.         delete sys.apps.opened[id];
  120.         sys.apps.openedFocuses.splice($.inArray('app'+id, sys.apps.openedFocuses),1);
  121.         $('#app'+id).addClass('window_fade');
  122.         setTimeout(function(){$('#app'+id).remove()},400)
  123.     },
  124.     fullSizeWindow: function(id){
  125.         if(typeof(sys.apps.opened[id]) == "undefined" || typeof(sys.apps.opened[id]) != "object"){
  126.             console.error('ERROR sys.apps.fullSizeWindow: Aplikacja o nazwie '+id+' nie istnieje!')
  127.             return false;
  128.         }
  129.         $('#app'+id).css("width",$('#windows_handler').width()-7).css("height",$('#windows_handler').height()-27).css("top","2px").css("left","2px");
  130.     },
  131.     defaultSizeWindow: function(id){
  132.         if(typeof(sys.apps.opened[id]) == "undefined" || typeof(sys.apps.opened[id]) != "object"){
  133.             console.error('ERROR sys.apps.fullSizeWindow: Aplikacja o nazwie '+id+' nie istnieje!')
  134.             return false;
  135.         }
  136.         if(sys.apps.opened[id].width != "default"){
  137.             $('#app'+id).css("width",sys.apps.opened[id].width).css("height",sys.apps.opened[id].height);
  138.         }
  139.         else{
  140.             $('#app'+id).css("width",sys.apps.defaultWidth).css("height",sys.apps.defaultHeight);
  141.         }  
  142.     },
  143.     centerWindow: function(id){
  144.         if(typeof(sys.apps.opened[id]) == "undefined" || typeof(sys.apps.opened[id]) != "object"){
  145.             console.error('ERROR sys.apps.fullSizeWindow: Aplikacja o nazwie '+id+' nie istnieje!')
  146.             return false;
  147.         }
  148.         $('#app'+id).css("top",($('#windows_handler').height()/2)-($('#app'+id).height()/2)+Math.floor((Math.random() * 40) + 1)+"px").css("left",($('#windows_handler').width()/2)-($('#app'+id).width()/2)+Math.floor((Math.random() * 40) + 1)+"px");
  149.     },
  150.     changeFocus: function(id){
  151.         /*sys.apps.openedFocuses['app'+id];
  152.         sys.apps.openedFocuses.length;
  153.         az.move(0, 4)
  154.         sys.apps.openedFocuses[0]
  155.         $.inArray("app78510096", sys.apps.openedFocuses)*/
  156.        
  157.         sys.apps.openedFocuses.move($.inArray("app"+id, sys.apps.openedFocuses), (sys.apps.openedFocuses.length - 1));
  158.         for(i=0;i<sys.apps.openedFocuses.length;i++){
  159.             $("#"+sys.apps.openedFocuses[i]).css('zIndex', 10+i);
  160.         }
  161.     }
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement