was.wm.js

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 4  →  ?path2? @ 3
File deleted
/trunk/dist/was.wm.js
File deleted
\ No newline at end of file
/trunk/dist/was.wm.min.js
/trunk/Gruntfile.js
@@ -17,8 +17,8 @@
stripBanners: true
},
dist: {
src: ['lib/**/*.js'],
dest: 'dist/<%= pkg.name %>' // <%= pkg.name %>.js -> was.wm.js
src: ['lib/*.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
uglify: {
@@ -27,7 +27,7 @@
},
dist: {
src: '<%= concat.dist.dest %>',
dest: 'dist/was.wm.min.js' // <%= pkg.name %>.min.js -> was.wm.min.js
dest: 'dist/<%= pkg.name %>.min.js'
}
},
jshint: {
@@ -44,16 +44,8 @@
boss: true,
eqnull: true,
globals: {
'$': false,
'module': false,
'document' : false,
'window' : false,
'interact' : false,
'Cookies' : false,
jQuery: true
},
// spread/rest operator
esnext: true
'$': false
}
},
gruntfile: {
src: 'Gruntfile.js'
@@ -79,7 +71,7 @@
 
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify-es');
grunt.loadNpmTasks('grunt-contrib-uglify');
//grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
/trunk/lib/wm.js
@@ -5,14 +5,11 @@
var ix = 0, iy = 0;
var states = {};
var cookie = Cookies.get('window-manager-icons');
if(cookie) {
if(cookie)
states = JSON.parse(cookie);
}
$.each(nucleons, function(index, file) {
// Skip files starting with full stop (POSIX).
if (/^\./.test(file)) {
return;
}
if (/^\./.test(file)) return;
$.get(path + '/' + file, function(data) {
data = $(data).get(0);
var nucleon = data.getAttribute('data-target');
@@ -53,9 +50,8 @@
// Open a window manager window.
function openWindowManagerWindow(nucleon) {
// If the nucleon already exists, then do not append the content again.
if($('#' + nucleon).length) {
if($('#' + nucleon).length)
return;
}
// Store the icon.
var nucleon_icon = $('#' + nucleon + '-window-manager-button-icon').attr('src');
@@ -75,17 +71,15 @@
var nucleonScripts = [];
$(data).find('script').each(function() {
var src = $(this).attr('src');
if(src === undefined) {
if(src === undefined)
return;
}
nucleonScripts[src] = $(this);
});
// Remove scripts from the nucleon if they are already added to the DOM.
$(document).find('script').each(function() {
var src = $(this).attr('src');
if(nucleonScripts[src] === undefined) {
if(nucleonScripts[src] === undefined)
return;
}
nucleonScripts[src].remove();
});
@@ -120,9 +114,8 @@
function getTopWindowIndex() {
return Math.max.apply(null,
$.map($('.window-manager-window'), function(e, n) {
if ($(e).css('position') !== 'static') {
if ($(e).css('position') != 'static')
return parseInt($(e).css('z-index')) || 1;
}
})
);
}
@@ -129,54 +122,6 @@
 
// Draggable and moveable windows.
$(document).ready(() => {
function dragMoveListener (event) {
var target = event.target, states, cookie,
// keep the dragged position in the data-x/data-y attributes
x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx,
y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
 
// translate the element
target.style.webkitTransform =
target.style.transform =
'translate(' + x + 'px, ' + y + 'px)';
 
// update the position attributes
target.setAttribute('data-x', x);
target.setAttribute('data-y', y);
if(target.classList.contains('window-manager-window')) {
// Save the window position.
states = {};
cookie = Cookies.get('window-manager-windows');
if(cookie) {
states = JSON.parse(cookie);
}
states[$(event.target).data('target')] = {
x: x,
y: y
};
Cookies.set('window-manager-windows', states, { path: '' });
}
if(target.classList.contains('window-manager-icon')) {
// Save the icon position.
states = {};
cookie = Cookies.get('window-manager-icons');
if(cookie) {
states = JSON.parse(cookie);
}
states[$(event.target).data('target')] = {
x: x,
y: y
};
Cookies.set('window-manager-icons', states, { path: '' });
}
}
// Window manager windows.
interact('.window-manager-window')
.draggable({
@@ -248,7 +193,53 @@
.closest('.window-manager-window')
.css('z-index', getTopWindowIndex() + 1);
});
function dragMoveListener (event) {
var target = event.target,
// keep the dragged position in the data-x/data-y attributes
x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx,
y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
 
// translate the element
target.style.webkitTransform =
target.style.transform =
'translate(' + x + 'px, ' + y + 'px)';
 
// update the position attributes
target.setAttribute('data-x', x);
target.setAttribute('data-y', y);
if(target.classList.contains('window-manager-window')) {
// Save the window position.
var states = {};
var cookie = Cookies.get('window-manager-windows');
if(cookie)
states = JSON.parse(cookie);
states[$(event.target).data('target')] = {
x: x,
y: y
};
Cookies.set('window-manager-windows', states, { path: '' });
}
if(target.classList.contains('window-manager-icon')) {
// Save the icon position.
var states = {};
var cookie = Cookies.get('window-manager-icons');
if(cookie)
states = JSON.parse(cookie);
states[$(event.target).data('target')] = {
x: x,
y: y
};
Cookies.set('window-manager-icons', states, { path: '' });
}
}
 
// this is used later in the resizing and gesture demos
window.dragMoveListener = dragMoveListener;
});
/trunk/package.json
@@ -8,11 +8,11 @@
"grunt-contrib-watch": "~0.6.1",
"grunt-contrib-nodeunit": "~0.4.1",
"grunt-contrib-concat": "~0.4.0",
"grunt-contrib-uglify-es": "git+https://github.com/gruntjs/grunt-contrib-uglify.git#harmony"
"grunt-contrib-uglify": "~0.5.0"
},
"name": "was.wm.js",
"description": "Original repo at http://svn.grimore.org/was.wm.js",
"version": "1.0.2",
"version": "1.0.0",
"main": "Gruntfile.js",
"directories": {
"test": "test"