Skip to content

Commit

Permalink
fix umd bug
Browse files Browse the repository at this point in the history
  • Loading branch information
RuochenLyu committed Jun 18, 2015
1 parent 14867e5 commit 457b6cb
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports = (grunt) ->
watch:
scripts:
files: ['src/*.coffee', 'demo/**/*.coffee']
tasks: ['coffee']
tasks: ['coffee', 'umd']
style:
files: ['styles/*.scss', 'demo/**/*.scss']
tasks: ['sass']
Expand Down
39 changes: 14 additions & 25 deletions lib/stack.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define('simple-stack', ["jquery",
"simple-module",
"simple-pjax",
"simple-url"], function ($, SimpleModule, simplePjax, simpleUrl) {
return (root.returnExportsGlobal = factory($, SimpleModule, simplePjax, simpleUrl));
// AMD. Register as an anonymous module unless amdModuleId is set
define('simple-stack', ["jquery","simple-module","simple-pjax","simple-url"], function (a0,b1,c2,d3) {
return (root['stack'] = factory(a0,b1,c2,d3));
});
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like enviroments that support module.exports,
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory(require("jquery"),
require("simple-module"),
require("simple-pjax"),
require("simple-url"));
module.exports = factory(require("jquery"),require("simple-module"),require("simple-pjax"),require("simple-url"));
} else {
root.simple = root.simple || {};
root.simple['stack'] = factory(jQuery,
SimpleModule,
simple.pjax,
simple.url);
root.simple['stack'] = factory(jQuery,SimpleModule,simple.pjax,simple.url);
}
}(this, function ($, SimpleModule, simplePjax, simpleUrl) {

var Stack, stack,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

Stack = (function(_super) {
__extends(Stack, _super);
Stack = (function(superClass) {
extend(Stack, superClass);

function Stack() {
return Stack.__super__.constructor.apply(this, arguments);
Expand Down Expand Up @@ -225,7 +216,7 @@ Stack = (function(_super) {
};

Stack.prototype.load = function(url, opts) {
var $link, $page, $parent, $prevPage, i, page, pageUrl, pjax, prevPage, prevPageName, _i, _len, _ref;
var $link, $page, $parent, $prevPage, i, j, len, page, pageUrl, pjax, prevPage, prevPageName, ref;
if (opts == null) {
opts = {};
}
Expand Down Expand Up @@ -261,9 +252,9 @@ Stack = (function(_super) {
if (this.currentPage.unload() === false) {
return false;
}
_ref = this.stack;
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
page = _ref[i];
ref = this.stack;
for (i = j = 0, len = ref.length; j < len; i = ++j) {
page = ref[i];
if (page === this.currentPage) {
continue;
}
Expand Down Expand Up @@ -331,5 +322,3 @@ stack.clearCache = Stack.clearCache;
return stack;

}));


4 changes: 2 additions & 2 deletions src/stack.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Stack extends SimpleModule
state = e.originalEvent.state
return unless state

if @currentPage
if @currentPage
if @triggerHandler('pageunload', [@currentPage.el.children().first(), @currentPage.getCache()]) == false
return

Expand Down Expand Up @@ -208,7 +208,7 @@ class Stack extends SimpleModule

return false if @currentPage.unload() == false

$link = $('<a/>',
$link = $('<a/>',
'class': 'link-page-behind'
'data-stack': ''
href: simpleUrl().toString('relative')
Expand Down
13 changes: 4 additions & 9 deletions styles/stack.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
clear: both;
}
.simple-stack .page {
width: 960px;
width: 100%;
min-height: 600px;
border: 1px solid #dbdfd6;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
Expand Down Expand Up @@ -46,11 +46,6 @@
.simple-stack .page > a.link-page-behind:hover {
background: #ffffff;
}
.simple-stack .page.transition-start {
/*opacity: 0;*/
/*transform: scale(1.05);*/
/*-webkit-transform: scale(1.05);*/
}
.simple-stack .page.page-root.page-behind {
top: 2px;
}
Expand Down Expand Up @@ -144,8 +139,8 @@
background: none;
}
.simple-stack.simple-stack-transition .page {
transition-property: top, margin-top, opacity, transform, box-shadow, border-color;
transition-duration: 200ms;
-webkit-transition-property: top, margin-top, opacity, -webkit-transform, box-shadow, border-color;
-webkit-transition-property: top, margin-top, opacity, -webkit-transform, box-shadow;
-webkit-transition-duration: 200ms;
transition-property: top, margin-top, opacity, transform, box-shadow;
transition-duration: 200ms;
}
14 changes: 4 additions & 10 deletions styles/stack.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $stack-header-height: 46px;
}

.page {
width: 960px;
width: 100%;
min-height: 600px;
border: 1px solid #dbdfd6;
box-shadow: 0 0 5px rgba(0,0,0,0.15);
Expand Down Expand Up @@ -56,12 +56,6 @@ $stack-header-height: 46px;
}
}

&.transition-start {
/*opacity: 0;*/
/*transform: scale(1.05);*/
/*-webkit-transform: scale(1.05);*/
}

&.page-root.page-behind {
top: 2px;
}
Expand Down Expand Up @@ -91,10 +85,10 @@ $stack-header-height: 46px;
}

&.simple-stack-transition .page {
transition-property: top, margin-top, opacity, transform, box-shadow, border-color;
transition-duration: 200ms;
-webkit-transition-property: top, margin-top, opacity, -webkit-transform, box-shadow, border-color;
-webkit-transition-property: top, margin-top, opacity, -webkit-transform, box-shadow;
-webkit-transition-duration: 200ms;
transition-property: top, margin-top, opacity, transform, box-shadow;
transition-duration: 200ms;
}
}

16 changes: 7 additions & 9 deletions umd.hbs
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define({{#if amdModuleId}}'{{amdModuleId}}', {{/if}}[{{{amdDependencies}}}], function ({{dependencies}}) {
return (root.returnExportsGlobal = factory({{dependencies}}));
// AMD. Register as an anonymous module unless amdModuleId is set
define({{#if amdModuleId}}'{{amdModuleId}}', {{/if}}[{{{amdDependencies.wrapped}}}], function ({{{amdDependencies.params}}}) {
return ({{#if objectToExport}}root['{{{objectToExport}}}'] = {{/if}}factory({{{amdDependencies.params}}}));
});
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like enviroments that support module.exports,
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory({{{cjsDependencies}}});
module.exports = factory({{{cjsDependencies.wrapped}}});
} else {
root.simple = root.simple || {};
{{#if globalAlias}}root.simple['{{{globalAlias}}}'] = {{else}}{{#if objectToExport}}root['{{{objectToExport}}}'] = {{/if}}{{/if}}factory({{{globalDependencies}}});
{{#if globalAlias}}root.simple['{{{globalAlias}}}'] = {{else}}{{#if objectToExport}}root['{{{objectToExport}}}'] = {{/if}}{{/if}}factory({{{globalDependencies.normal}}});
}
}(this, function ({{dependencies}}) {

{{{code}}}
{{#if objectToExport}}
{{indent}}return {{{objectToExport}}};
return {{{objectToExport}}};
{{/if}}

}));


0 comments on commit 457b6cb

Please sign in to comment.