Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sys.apps = {
- opened: {},
- openedFocuses: [],
- defaultWidth: 500,
- defaultHeight: 275,
- defaultIcon: 'fa-square-o',
- defaultColor: '#808080',
- listApps: function(){
- $('#panel .listedapp').remove();
- var keyss = [];
- for(var k in sys.apps.installed) keyss.push(k);
- keyss.sort();
- for(i=0;i<keyss.length;i++){
- if(sys.apps.installed[keyss[i]].hidden == false){
- icon = sys.apps.installed[keyss[i]].icon;
- color = sys.apps.installed[keyss[i]].color;
- if(icon == "default" || icon == false){icon = sys.apps.defaultIcon}
- if(color == "default" || color == false){color = sys.apps.defaultColor}
- $('#panel').append('\
- <div class="listedapp">\
- <div class="listedapp_icon" onclick="sys.apps.register('+"'"+sys.apps.installed[keyss[i]].appName+"'"+')" style="background-color:'+color+';"><i class="fa '+icon+'"></i></div>\
- <div class="listedapp_title">'+sys.apps.installed[keyss[i]].appFullName+'</div>\
- </div>\
- ')
- }
- }
- },
- register: function(app){
- if(typeof(sys.apps.installed[app]) == "undefined" || typeof(sys.apps.installed[app]) != "object"){
- console.error('ERROR sys.apps.register: Aplikacja o nazwie '+app+' nie istnieje!')
- return false;
- }
- id = Math.floor((Math.random() * 99999999) + 1);
- sys.apps.openedFocuses.push('app'+id);
- sys.apps.opened[id] = {
- "id": id,
- "icon": sys.apps.installed[app].icon,
- "color": sys.apps.installed[app].color,
- "appName": sys.apps.installed[app].appName,
- "appTitle": sys.apps.installed[app].appTitle,
- "width": sys.apps.installed[app].width,
- "height": sys.apps.installed[app].height,
- "maxWidth": sys.apps.installed[app].maxWidth,
- "maxHeight": sys.apps.installed[app].maxHeight,
- "minWidth": sys.apps.installed[app].minWidth,
- "minHeight": sys.apps.installed[app].minHeight,
- "resizable": sys.apps.installed[app].resizable,
- };
- 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);
- },
- pushWindow: function(id, icon, color, appName, appFullName, appTitle, width, height, maxWidth, maxHeight, minWidth, minHeight, resizable, content){
- if(width == "default"){width = sys.apps.defaultWidth}
- if(height == "default"){height = sys.apps.defaultHeight}
- if(icon == "default" || icon == false){icon = sys.apps.defaultIcon}
- $('#windows_handler').prepend('\
- <div id="app'+id+'" onmousedown="sys.apps.changeFocus('+id+')" style="width:'+width+'px;height:'+height+'px;" class="ui-widget-content window window_fade">\
- <div class="window_handle">\
- <div class="window_title"><i class="fa '+icon+'"></i>'+appTitle+'</div>\
- <div class="window_close" onclick="sys.apps.closeWindow('+id+')"><i class="fa fa-times"></i>\
- </div>\
- </div>\
- <div class="window_content"></div>\
- </div>\
- ');
- $('#app'+id).draggable({ containment: "#windows_handler", scroll: false, handle: "div.window_handle:nth-child(1)"});
- $('#app'+id).removeClass('window_fade');
- if(resizable == true){
- $('#app'+id).addClass('ui-resizable');
- $('#app'+id).resizable({containment: "#windows_handler"});
- $('#app'+id+' .window_handle').append('<div class="window_full" onclick="sys.apps.fullSizeWindow('+id+')"><i class="fa fa-expand"></i></div>');
- $('#app'+id+' .window_handle').append('<div class="window_mini" onclick="sys.apps.defaultSizeWindow('+id+')"><i class="fa fa-compress"></i></div>')
- }
- if(content != false){
- /*
- $.get( content, function(data) {
- $("#app"+id+" .window_content").html(data);
- })
- .fail(function() {
- $("#app"+id+" .window_content").text("ERROR");
- });
- //----
- $.ajax({
- url: content,
- success: function (data) {$("#app"+id+" .window_content").html(data);},
- dataType: 'html'
- });*/
- $("#app"+id+" .window_content").html(content);
- }
- if(minHeight != "default" && minHeight != false){
- $('#app'+id).css("minHeight", minHeight+'px');
- }
- if(minWidth != "default" && minWidth != false){
- $('#app'+id).css("minWidth", minWidth+'px');
- }
- if(maxHeight != "default" && maxHeight != false){
- $('#app'+id).css("maxHeight", maxHeight+'px');
- }
- if(maxWidth != "default" && maxWidth != false){
- $('#app'+id).css("maxWidth", maxWidth+'px');
- }
- if(color != "default" && maxWidth != false){
- $('#app'+id).css("borderColor", color);
- $('#app'+id+' .window_handle').css("backgroundColor", color);
- }
- sys.apps.changeFocus(id);
- sys.apps.centerWindow(id);
- },
- closeWindow: function(id){
- if(typeof(sys.apps.opened[id]) == "undefined" || typeof(sys.apps.opened[id]) != "object"){
- console.error('ERROR sys.apps.closeWindow: Aplikacja o nazwie '+id+' nie istnieje!')
- return false;
- }
- delete sys.apps.opened[id];
- sys.apps.openedFocuses.splice($.inArray('app'+id, sys.apps.openedFocuses),1);
- $('#app'+id).addClass('window_fade');
- setTimeout(function(){$('#app'+id).remove()},400)
- },
- fullSizeWindow: function(id){
- if(typeof(sys.apps.opened[id]) == "undefined" || typeof(sys.apps.opened[id]) != "object"){
- console.error('ERROR sys.apps.fullSizeWindow: Aplikacja o nazwie '+id+' nie istnieje!')
- return false;
- }
- $('#app'+id).css("width",$('#windows_handler').width()-7).css("height",$('#windows_handler').height()-27).css("top","2px").css("left","2px");
- },
- defaultSizeWindow: function(id){
- if(typeof(sys.apps.opened[id]) == "undefined" || typeof(sys.apps.opened[id]) != "object"){
- console.error('ERROR sys.apps.fullSizeWindow: Aplikacja o nazwie '+id+' nie istnieje!')
- return false;
- }
- if(sys.apps.opened[id].width != "default"){
- $('#app'+id).css("width",sys.apps.opened[id].width).css("height",sys.apps.opened[id].height);
- }
- else{
- $('#app'+id).css("width",sys.apps.defaultWidth).css("height",sys.apps.defaultHeight);
- }
- },
- centerWindow: function(id){
- if(typeof(sys.apps.opened[id]) == "undefined" || typeof(sys.apps.opened[id]) != "object"){
- console.error('ERROR sys.apps.fullSizeWindow: Aplikacja o nazwie '+id+' nie istnieje!')
- return false;
- }
- $('#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");
- },
- changeFocus: function(id){
- /*sys.apps.openedFocuses['app'+id];
- sys.apps.openedFocuses.length;
- az.move(0, 4)
- sys.apps.openedFocuses[0]
- $.inArray("app78510096", sys.apps.openedFocuses)*/
- sys.apps.openedFocuses.move($.inArray("app"+id, sys.apps.openedFocuses), (sys.apps.openedFocuses.length - 1));
- for(i=0;i<sys.apps.openedFocuses.length;i++){
- $("#"+sys.apps.openedFocuses[i]).css('zIndex', 10+i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement