Skip to content

Commit

Permalink
修改theme和transition为js控制
Browse files Browse the repository at this point in the history
  • Loading branch information
ksky521 committed Mar 15, 2015
1 parent 14507ef commit 1bc6f9f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 21 deletions.
49 changes: 38 additions & 11 deletions assets/js/nodeppt.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,27 @@
var $drawBoard; //画板
var $slideTip;
var slideCount; //幻灯片总页数-1
var QUERY = queryToJson(location.search);

//设置底部进度条
function queryToJson(url) {
url = !!url ? decodeURIComponent(url) : '';

var locse = url.split('?'),
search = locse[1] ? locse[1] : locse[0],
pairs = search.split('&'),
result = {};

pairs.forEach(function(pair) {
pair = pair.split('=');
if (pair[0].length > 0) {
result[pair[0]] = pair[1] || '';
}
});

return result;
}

//设置底部进度条
function setProgress() {
//添加dataset
Slide.current = curIndex + 1;
Expand Down Expand Up @@ -92,7 +110,6 @@
clearTimeout(slideInTimer);
}
slideInTimer = setTimeout(slideInCallBack_, 1500);

}

function slideInCallBack_() {
Expand Down Expand Up @@ -802,7 +819,6 @@
};

//初始化变量

function initVar() {

$slideTip = $$(defaultOptions.tipID);
Expand All @@ -812,8 +828,6 @@
$progress = $$(defaultOptions.progressID);
Slide.$slides = $slides = toArray($(defaultOptions.slideClass, $container));



slideCount = $slides.length; //幻灯片总页数-1
Slide.count = slideCount;

Expand All @@ -827,14 +841,20 @@

function fullImg() {

loadJS(defaultOptions.dir + 'img.screenfull.js', function() {
//图片处理
var $imgs = toArray($(defaultOptions.slideClass + ' img', $container));
screenfull($imgs);
});
loadJS(defaultOptions.dir + 'img.screenfull.js', function() {
//图片处理
var $imgs = toArray($(defaultOptions.slideClass + ' img', $container));
screenfull($imgs);
});
}

function loadTheme() {
if (defaultOptions.theme) {
loadCSS('/css/theme.' + defaultOptions.theme + '.css')
}
//初始化
}

//初始化
function init(options) {
options = options || {};

Expand All @@ -843,6 +863,12 @@
defaultOptions[key] = options[key];
}
}
['theme', 'transition'].forEach(function(v) {
if (QUERY && QUERY[v]) {
defaultOptions[v] = QUERY[v];
}
});

Slide.dir = defaultOptions.dir;
if (defaultOptions.control) {
var control = defaultOptions.control;
Expand All @@ -853,6 +879,7 @@


initVar(); //初始化变量
loadTheme();
makeBuildLists();
fullImg(); //图片全屏
bindEvent();
Expand Down
18 changes: 9 additions & 9 deletions lib/md_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ var parser = function(string, callback, argvObj, queryObj, commonData) {
query: mix(queryObj || {}, argvObj || {})
});

//优先使用url的参数来控制
['theme', 'transition'].forEach(function(v) {
if (json.query && json.query[v]) {
json[v] = json.query[v];
}
});
if (json.theme) {
json.files = [json.files || '', '/css/theme.' + json.theme + '.css'].join(',');
}
//优先使用url的参数来控制,使用js来做,不再使用server
// ['theme', 'transition'].forEach(function(v) {
// if (json.query && json.query[v]) {
// json[v] = json.query[v];
// }
// });
// if (json.theme) {
// json.files = [json.files || '', '/css/theme.' + json.theme + '.css'].join(',');
// }

if (json.files) {
var files = json.files.split(/\s?,\s?/);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nodeppt",
"jsname": "nodeppt",
"description": "A simple, in-browser, markdown-driven presentation framework",
"version": "1.2.0",
"version": "1.2.1",
"site": "https://github.com/ksky521/nodePPT",
"author": {
"name": "Theo Wang",
Expand Down

0 comments on commit 1bc6f9f

Please sign in to comment.