From 19f1801379104bc1f74fbb9d288f71034ba829c9 Mon Sep 17 00:00:00 2001 From: Matias Niemelä Date: Tue, 2 Apr 2013 19:41:16 -0400 Subject: docs: add animations into docs and directive examples --- docs/src/example.js | 30 +++++++++++--- docs/src/ngdoc.js | 9 ++++- docs/src/templates/css/animations.css | 73 +++++++++++++++++++++++++++++++++++ docs/src/templates/css/docs.css | 9 +++++ docs/src/templates/index.html | 11 +++--- 5 files changed, 120 insertions(+), 12 deletions(-) create mode 100644 docs/src/templates/css/animations.css (limited to 'docs/src') diff --git a/docs/src/example.js b/docs/src/example.js index 7477b0a5..eadc218f 100644 --- a/docs/src/example.js +++ b/docs/src/example.js @@ -57,12 +57,27 @@ exports.Example.prototype.addSource = function(name, content) { } }; +exports.Example.prototype.enableAnimations = function() { + this.animations = true; +}; + +exports.Example.prototype.disableAnimations = function() { + this.animations = false; +}; + exports.Example.prototype.toHtml = function() { - return '

Source

\n' + - this.toHtmlEdit() + - this.toHtmlTabs() + - '

Demo

\n' + - this.toHtmlEmbed(); + var html = "

Source

\n"; + html += this.toHtmlEdit(); + html += this.toHtmlTabs(); + if(this.animations) { + html += '
'; + html += ' '; + html += ' '; + html += '
'; + } + html += "

Demo

\n"; + html += this.toHtmlEmbed(); + return html; }; @@ -116,7 +131,10 @@ exports.Example.prototype.toHtmlTabs = function() { exports.Example.prototype.toHtmlEmbed = function() { var out = []; - out.push('
'); diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index 3e1bbe9d..4f94a1cd 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -130,8 +130,13 @@ Doc.prototype = { parts.forEach(function(text, i) { parts[i] = (text || ''). - replace(/([\s\S]*?)<\/example>/gmi, function(_, module, deps, content) { + replace(/([\s\S]*?)<\/example>/gmi, + function(_, module, deps, animations, content) { + var example = new Example(self.scenarios); + if(animations) { + example.enableAnimations(); + } example.setModule(module); example.addDeps(deps); @@ -437,9 +442,11 @@ Doc.prototype = { var restrict = self.restrict || 'AC'; if (restrict.match(/E/)) { + dom.html('

'); dom.text('This directive can be used as custom element, but we aware of '); dom.tag('a', {href:'guide/ie'}, 'IE restrictions'); dom.text('.'); + dom.html('

'); } if (self.usage) { diff --git a/docs/src/templates/css/animations.css b/docs/src/templates/css/animations.css new file mode 100644 index 00000000..3defa5ad --- /dev/null +++ b/docs/src/templates/css/animations.css @@ -0,0 +1,73 @@ +.reveal-setup { + -webkit-transition:1s linear all; + -moz-transition:1s linear all; + -ms-transition:1s linear all; + -o-transition:1s linear all; + transition:1s linear all; + + opacity:0; +} +.reveal-setup.reveal-start { + opacity:1; +} + +.slide-reveal-setup { + -webkit-transition:0.5s linear all; + -moz-transition:0.5s linear all; + -ms-transition:0.5s linear all; + -o-transition:0.5s linear all; + transition:0.5s linear all; + opacity:0.5; +} +.slide-reveal-setup.slide-reveal-start { + opacity:1; +} + +.slide-enter-setup { + -webkit-transition:0.5s linear all; + -moz-transition:0.5s linear all; + -ms-transition:0.5s linear all; + -o-transition:0.5s linear all; + transition:0.5s linear all; + + position:relative; + left:10px; + opacity:0; +} +.slide-enter-setup.slide-enter-start { + left:0; + opacity:1; +} + +.slide-leave-setup { + -webkit-transition:0.5s linear all; + -moz-transition:0.5s linear all; + -ms-transition:0.5s linear all; + -o-transition:0.5s linear all; + transition:0.5s linear all; + + opacity:1; +} +.slide-leave-setup.slide-leave-start { + opacity:0; +} + +.example-animate-container { + position:relative; + background:white; + border:1px solid black; + height:40px; + overflow:hidden; +} + +.example-animate-container > div { + padding:1em; +} + +.animator-container.animations-off * { + -webkit-transition: none; + -moz-transition: none; + -ms-transition: none; + -o-transition: color 0 ease-in; /* opera is special :) */ + transition: none; +} diff --git a/docs/src/templates/css/docs.css b/docs/src/templates/css/docs.css index 70d98a3c..bed88f80 100644 --- a/docs/src/templates/css/docs.css +++ b/docs/src/templates/css/docs.css @@ -3,6 +3,15 @@ img.AngularJS-small { height: 25px; } +/* this is here to avoid the display=block shuffling of ngShow */ +.breadcrumb li > * { + float:left; + margin:0 2px 0 0; +} + +.breadcrumb { + padding-bottom:2px; +} .clear-navbar { margin-top: 60px; diff --git a/docs/src/templates/index.html b/docs/src/templates/index.html index bd460838..6e3be195 100644 --- a/docs/src/templates/index.html +++ b/docs/src/templates/index.html @@ -34,6 +34,7 @@ addTag('link', {rel: 'stylesheet', href: 'css/bootstrap.min.css', type: 'text/css'}); addTag('link', {rel: 'stylesheet', href: 'css/font-awesome.css', type: 'text/css'}); addTag('link', {rel: 'stylesheet', href: 'css/docs.css', type: 'text/css'}); + addTag('link', {rel: 'stylesheet', href: 'css/animations.css', type: 'text/css'}); if (jQuery) addTag('script', {src: debug ? 'js/jquery.js' : 'js/jquery.min.js'}); addTag('script', {src: path('angular.js')}, sync); addTag('script', {src: path('angular-resource.js') }, sync); @@ -231,21 +232,21 @@ -
  • +
  • {{page.shortName}}
  • -
  • +
  • {{page.shortName}}
  • -
  • +
  • {{service.name}}
  • @@ -253,7 +254,7 @@ -
  • +
  • {{page.shortName}}
  • @@ -281,7 +282,7 @@
    Loading...
    -
    +

    Discussion

    -- cgit v1.2.3