Skip to content

Commit

Permalink
1. 添加subslide
Browse files Browse the repository at this point in the history
2. 修复同步问题
  • Loading branch information
ksky521 committed Mar 13, 2015
1 parent fd59270 commit a2e7853
Show file tree
Hide file tree
Showing 13 changed files with 526 additions and 393 deletions.
2 changes: 1 addition & 1 deletion assets/css/nodeppt.css

Large diffs are not rendered by default.

103 changes: 46 additions & 57 deletions assets/js/nodeppt.control.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,10 @@
*/
(function($win, $doc, $B, Slide, loadJS, undefined) {
var $slides = Slide.$slides;
var doSlide = Slide.doSlide;

function doItem(id, itemID) {
itemID = itemID | 0;
var $curSlide = $slides[id];
var buildClass = '.build > *,.fadeIn > *,.moveIn > *,.bounceIn > *,.zoomIn > *,.fade > *';
var toBuild = $curSlide.querySelectorAll(buildClass);
var list;
var index = itemID;

while (itemID >= 0) {
list = toBuild.item(itemID).classList;
list.remove('to-build');
list.add(itemID === index ? 'building' : 'build-fade');
itemID--;
}
}
// function doItem(direction) {
// return Slide[direction === 'prev' ? 'buildPrevItem' : 'buildNextItem'](true);
// }

function getType(obj) {
return ({}).toString.call(obj).slice(8, -1)
Expand All @@ -35,44 +22,46 @@
var t = this;
//监听用户端发出的广播
$B.on('slide change ID', function(json) {
var slideID = json.slideID;
//发送请求
t.sendUpdate(slideID);
var slideID = json.slideID;
//发送请求
t.sendUpdate(slideID, json.direction);

}).on('slide do build', function(json) {
var slideID = json.slideID;
var buildItem = json.build;
//发送请求
t.sendUpdateItem(slideID, buildItem);
}).on('slide event keyup', function(e) {
t.sendKeyEvent(e.keyCode);
}).on('show paint', function(e){
t.sendKeyEvent(80);
}).on('remove paint', function(){
t.sendKeyEvent(67);
}).on('paint points', function(points) {
var data = {
points: points,
screen: {
width: $doc.body.offsetWidth,
height: $doc.body.offsetHeight
}
};
t.send_('broadcast', ['paint points', data]);
})
//监听控制来的广播
.on('from control order', function(json) {
var fnName = json.fnName;
var args = json.args;
Slide.proxyFn(fnName, args);
}).on('from control update', function(json) {
doSlide(json.id, false);
}).on('from control updateItem', function(json) {
doSlide(json.id, false);
doItem(json.id, json.item);
}).on('from control key event', function(json) {
t.createKeyEvent_(json.keyCode);
})
}).on('slide do build', function(json) {
var slideID = json.slideID;
var buildItem = json.build;
var direction = json.direction;
//发送请求
t.sendUpdateItem(slideID, buildItem, direction);
}).on('slide event keyup', function(e) {
t.sendKeyEvent(e.keyCode);
}).on('show paint', function(e) {
t.sendKeyEvent(80);
}).on('remove paint', function() {
t.sendKeyEvent(67);
}).on('paint points', function(points) {
var data = {
points: points,
screen: {
width: $doc.body.offsetWidth,
height: $doc.body.offsetHeight
}
};
t.send_('broadcast', ['paint points', data]);
})
//监听控制来的广播
.on('from control order', function(json) {
var fnName = json.fnName;
var args = json.args;
Slide.proxyFn(fnName, args);
}).on('from control update', function(json) {
Slide[json.direction](true);
// doSlide(json.direction, json.id, false);
}).on('from control updateItem', function(json) {
Slide[json.direction](true);
//doItem(json.direction) && doSlide(json.id, false);
}).on('from control key event', function(json) {
t.createKeyEvent_(json.keyCode);
})
},
createKeyEvent_: function(keyCode) {
var evt = document.createEvent('Event');
Expand All @@ -92,11 +81,11 @@
typeof method === 'function' && method.apply(Slide, args);
}
},
sendUpdate: function(slideID) {
this.send_('update', [slideID]);
sendUpdate: function(slideID, direction) {
this.send_('update', [slideID, direction]);
},
sendUpdateItem: function(id, buildItem) {
this.send_('updateItem', [id, buildItem]);
sendUpdateItem: function(id, buildItem, direction) {
this.send_('updateItem', [id, buildItem, direction]);
},
sendKeyEvent: function(keycode) {
this.send_('keyEvent', [keycode]);
Expand Down
12 changes: 7 additions & 5 deletions assets/js/nodeppt.control.postMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,23 @@ Slide.Control.add('postMessage', function(S, broadcast) {
}, '*');
}
},
update: function(id) {
update: function(id, direction) {
if (postWin) {
window.opener.postMessage({
action: 'update',
id: id
id: id,
direction: direction
}, '*');
}

},
updateItem: function(id, item) {
updateItem: function(id, item, direction) {
if (postWin) {
window.opener.postMessage({
action: 'updateItem',
id: id,
item: item
item: item,
direction: direction
}, '*');
}

Expand Down Expand Up @@ -74,7 +76,7 @@ Slide.Control.add('postMessage', function(S, broadcast) {
Slide.proxyFn(fnName, args);
break;
default:
broadcast.fire('from control '+data.action, data.data);
broadcast.fire('from control ' + data.action, data.data);
}

},
Expand Down
12 changes: 7 additions & 5 deletions assets/js/nodeppt.control.socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Slide.Control.add('socket', function(S, broadcast) {

},
connect: function() {
webSocket = io.connect(location.host+'/ppt');
webSocket = io.connect(location.host + '/ppt');
// console.log(io);
webSocket.on('UUID', function(uid) {
webSocket.uid = uid;
Expand Down Expand Up @@ -128,17 +128,19 @@ Slide.Control.add('socket', function(S, broadcast) {
data: data
});
},
update: function(id) {
update: function(id, direction) {
webSocket.emit('repost data', {
action: 'from ' + Socket.role + ' update',
id: id
id: id,
direction: direction
});
},
updateItem: function(id, item) {
updateItem: function(id, item, direction) {
webSocket.emit('repost data', {
action: 'from ' + Socket.role + ' updateItem',
id: id,
item: item
item: item,
direction: direction
});
},
keyEvent: function(keyCode) {
Expand Down
Loading

0 comments on commit a2e7853

Please sign in to comment.