Skip to content

Commit

Permalink
Modfiy hello-seajs example
Browse files Browse the repository at this point in the history
  • Loading branch information
lifesinger committed Oct 16, 2012
1 parent ba4311e commit 7fd9db2
Show file tree
Hide file tree
Showing 15 changed files with 351 additions and 10,971 deletions.
8 changes: 4 additions & 4 deletions docs/assets/highlight.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions docs/assets/home.css
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,3 @@ pre {
border-radius: 0 3px 3px 0;
}

pre.text {
border-width: 0 0 0 6px;
background-color: #F4F4F4;
margin-left: 1em;
}
18 changes: 9 additions & 9 deletions docs/assets/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,15 @@ define('home', [], function(require) {
require.async(['jquery'], function($) {
initLazySrc($)
})

require.async('highlight', function(highlight) {
highlight.init()
})

// Only run once
delete extraCode['intro']
},

'quick-start': function() {
var iframe = document.getElementById('quick-start-iframe')
iframe.contentDocument.location.reload()
iframe.contentDocument.location.href = 'examples/hello-seajs/index.html'

require.async('highlight', function(highlight) {
highlight.init()
})
}
}

Expand Down Expand Up @@ -68,7 +65,10 @@ define('home', [], function(require) {
page.className = isActive ? 'page page-active' : 'page'
}

extraCode[pageId] && extraCode[pageId]()
if (extraCode[pageId]) {
extraCode[pageId]()
delete extraCode[pageId]
}
}

function bindEvents() {
Expand Down
Binary file added docs/examples/hello-seajs.zip
Binary file not shown.
6 changes: 6 additions & 0 deletions docs/examples/hello-seajs/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
"dependencies": {
"jquery": "1.7.2"
},
"root": "",
"output": {
"hello.js": ".",
"hello.css": "."
},
"spmConfig": {
"build": {
"to": "sea_modules/{{name}}/{{version}}"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
html, body, div, span, h1, h2, h3, h4, p, img, strong, ol, ul, li {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
vertical-align: baseline;
background: transparent;
}

body {
background: #F4F4F4;
}

#container {
position: relative;
margin: 40px 120px;
display: none;
}

#container img {
position: absolute;
cursor: pointer;
opacity: .6;

-webkit-transition-property: -webkit-transform;
-moz-transition-property: -moz-transform;
-o-transition-property: -o-transform;
transition-property: transform;
-webkit-transition-duration: 0.8s;
-moz-transition-duration: 0.8s;
-o-transition-duration: 0.8s;
transition-duration: 0.8s;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
define("hello-seajs/1.0.0/spinning-debug", ["#jquery/1.7.2/jquery-debug"], function(require, exports, module) {

var $ = require('#jquery/1.7.2/jquery-debug')

var TRANSFORM = $.browser.webkit ? '-webkit-transform' :
$.browser.mozilla ? '-moz-transform' :
$.browser.opera ? '-o-transform' : 'transform'

function random(x) { return Math.random() * x }


function Spinning(container) {
this.container = $(container)
this.icons = this.container.children()
this.spinnings = []
}

Spinning.prototype.render = function() {
this._init()
this.container.show()
this._spin()
}

Spinning.prototype._init = function() {
var spinnings = this.spinnings

$(this.icons).each(function(n) {
var startDeg = random(360)
var node = $(this)
var timer

node.css({
top: random(40),
left: n * 50 + random(10),
zIndex: 1000
}).hover(
function() {
node.fadeTo(250, 1)
.css('zIndex', 1001)
.css(TRANSFORM, 'rotate(0deg)')

},
function() {
node.fadeTo(250, .6).css('zIndex', 1000)
timer && clearTimeout(timer)
timer = setTimeout(spin, Math.ceil(random(10000)))
}
)

function spin() {
node.css(TRANSFORM, 'rotate(' + startDeg + 'deg)')
}

spinnings[n] = spin
})

return this
}

Spinning.prototype._spin = function() {

$(this.spinnings).each(function(i, fn) {
setTimeout(fn, Math.ceil(random(3000)))
})

return this
}


module.exports = Spinning
})


define("hello-seajs/1.0.0/hello-debug", ["./spinning-debug", "#jquery/1.7.2/jquery-debug"], function(require) {

var Spinning = require('./spinning-debug')

var s = new Spinning('#container')
s.render()

})

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7fd9db2

Please sign in to comment.