Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | <!DOCTYPE html> |
| 2 | <html lang="en"> |
||
| 3 | <head> |
||
| 4 | <title>Animations + Transitions | Jcrop Demo</title> |
||
| 5 | <meta http-equiv="Content-type" content="text/html;charset=UTF-8" /> |
||
| 6 | |||
| 7 | <script src="../js/jquery.min.js"></script> |
||
| 8 | <script src="../js/jquery.Jcrop.js"></script> |
||
| 9 | <script src="../js/jquery.color.js"></script> |
||
| 10 | <script type="text/javascript"> |
||
| 11 | jQuery(function($){ |
||
| 12 | |||
| 13 | var jcrop_api; |
||
| 14 | |||
| 15 | $('#target').Jcrop({ |
||
| 16 | bgFade: true, |
||
| 17 | bgOpacity: .2, |
||
| 18 | setSelect: [ 60, 70, 540, 330 ] |
||
| 19 | },function(){ |
||
| 20 | jcrop_api = this; |
||
| 21 | }); |
||
| 22 | |||
| 23 | $('#fadetog').change(function(){ |
||
| 24 | jcrop_api.setOptions({ |
||
| 25 | bgFade: this.checked |
||
| 26 | }); |
||
| 27 | }).attr('checked','checked'); |
||
| 28 | |||
| 29 | $('#shadetog').change(function(){ |
||
| 30 | if (this.checked) $('#shadetxt').slideDown(); |
||
| 31 | else $('#shadetxt').slideUp(); |
||
| 32 | jcrop_api.setOptions({ |
||
| 33 | shade: this.checked |
||
| 34 | }); |
||
| 35 | }).attr('checked',false); |
||
| 36 | |||
| 37 | // Define page sections |
||
| 38 | var sections = { |
||
| 39 | bgc_buttons: 'Change bgColor', |
||
| 40 | bgo_buttons: 'Change bgOpacity', |
||
| 41 | anim_buttons: 'Animate Selection' |
||
| 42 | }; |
||
| 43 | // Define animation buttons |
||
| 44 | var ac = { |
||
| 45 | anim1: [217,122,382,284], |
||
| 46 | anim2: [20,20,580,380], |
||
| 47 | anim3: [24,24,176,376], |
||
| 48 | anim4: [347,165,550,355], |
||
| 49 | anim5: [136,55,472,183] |
||
| 50 | }; |
||
| 51 | // Define bgOpacity buttons |
||
| 52 | var bgo = { |
||
| 53 | Low: .2, |
||
| 54 | Mid: .5, |
||
| 55 | High: .8, |
||
| 56 | Full: 1 |
||
| 57 | }; |
||
| 58 | // Define bgColor buttons |
||
| 59 | var bgc = { |
||
| 60 | R: '#900', |
||
| 61 | B: '#4BB6F0', |
||
| 62 | Y: '#F0B207', |
||
| 63 | G: '#46B81C', |
||
| 64 | W: 'white', |
||
| 65 | K: 'black' |
||
| 66 | }; |
||
| 67 | // Create fieldset targets for buttons |
||
| 68 | for(i in sections) |
||
| 69 | insertSection(i,sections[i]); |
||
| 70 | |||
| 71 | function create_btn(c) { |
||
| 72 | var $o = $('<button />').addClass('btn btn-small'); |
||
| 73 | if (c) $o.append(c); |
||
| 74 | return $o; |
||
| 75 | } |
||
| 76 | |||
| 77 | var a_count = 1; |
||
| 78 | // Create animation buttons |
||
| 79 | for(i in ac) { |
||
| 80 | $('#anim_buttons .btn-group') |
||
| 81 | .append( |
||
| 82 | create_btn(a_count++).click(animHandler(ac[i])), |
||
| 83 | ' ' |
||
| 84 | ); |
||
| 85 | } |
||
| 86 | |||
| 87 | $('#anim_buttons .btn-group').append( |
||
| 88 | create_btn('Bye!').click(function(e){ |
||
| 89 | $(e.target).addClass('active'); |
||
| 90 | jcrop_api.animateTo( |
||
| 91 | [300,200,300,200], |
||
| 92 | function(){ |
||
| 93 | this.release(); |
||
| 94 | $(e.target).closest('.btn-group').find('.active').removeClass('active'); |
||
| 95 | } |
||
| 96 | ); |
||
| 97 | return false; |
||
| 98 | }) |
||
| 99 | ); |
||
| 100 | |||
| 101 | // Create bgOpacity buttons |
||
| 102 | for(i in bgo) { |
||
| 103 | $('#bgo_buttons .btn-group').append( |
||
| 104 | create_btn(i).click(setoptHandler('bgOpacity',bgo[i])), |
||
| 105 | ' ' |
||
| 106 | ); |
||
| 107 | } |
||
| 108 | // Create bgColor buttons |
||
| 109 | for(i in bgc) { |
||
| 110 | $('#bgc_buttons .btn-group').append( |
||
| 111 | create_btn(i).css({ |
||
| 112 | background: bgc[i], |
||
| 113 | color: ((i == 'K') || (i == 'R'))?'white':'black' |
||
| 114 | }).click(setoptHandler('bgColor',bgc[i])), ' ' |
||
| 115 | ); |
||
| 116 | } |
||
| 117 | // Function to insert named sections into interface |
||
| 118 | function insertSection(k,v) { |
||
| 119 | $('#interface').prepend( |
||
| 120 | $('<fieldset></fieldset>').attr('id',k).append( |
||
| 121 | $('<legend></legend>').append(v), |
||
| 122 | '<div class="btn-toolbar"><div class="btn-group"></div></div>' |
||
| 123 | ) |
||
| 124 | ); |
||
| 125 | }; |
||
| 126 | // Handler for option-setting buttons |
||
| 127 | function setoptHandler(k,v) { |
||
| 128 | return function(e) { |
||
| 129 | $(e.target).closest('.btn-group').find('.active').removeClass('active'); |
||
| 130 | $(e.target).addClass('active'); |
||
| 131 | var opt = { }; |
||
| 132 | opt[k] = v; |
||
| 133 | jcrop_api.setOptions(opt); |
||
| 134 | return false; |
||
| 135 | }; |
||
| 136 | }; |
||
| 137 | // Handler for animation buttons |
||
| 138 | function animHandler(v) { |
||
| 139 | return function(e) { |
||
| 140 | $(e.target).addClass('active'); |
||
| 141 | jcrop_api.animateTo(v,function(){ |
||
| 142 | $(e.target).closest('.btn-group').find('.active').removeClass('active'); |
||
| 143 | }); |
||
| 144 | return false; |
||
| 145 | }; |
||
| 146 | }; |
||
| 147 | |||
| 148 | $('#bgo_buttons .btn:first,#bgc_buttons .btn:last').addClass('active'); |
||
| 149 | $('#interface').show(); |
||
| 150 | |||
| 151 | }); |
||
| 152 | |||
| 153 | |||
| 154 | </script> |
||
| 155 | <link rel="stylesheet" href="demo_files/main.css" type="text/css" /> |
||
| 156 | <link rel="stylesheet" href="demo_files/demos.css" type="text/css" /> |
||
| 157 | <link rel="stylesheet" href="../css/jquery.Jcrop.css" type="text/css" /> |
||
| 158 | <link rel="stylesheet" href="../css/jquery.Jcrop.extras.css" type="text/css" /> |
||
| 159 | |||
| 160 | </head> |
||
| 161 | <body> |
||
| 162 | |||
| 163 | <div class="container"> |
||
| 164 | <div class="row"> |
||
| 165 | <div class="span12"> |
||
| 166 | <div class="jc-demo-box"> |
||
| 167 | |||
| 168 | <div class="page-header"> |
||
| 169 | <ul class="breadcrumb first"> |
||
| 170 | <li><a href="../index.html">Jcrop</a> <span class="divider">/</span></li> |
||
| 171 | <li><a href="../index.html">Demos</a> <span class="divider">/</span></li> |
||
| 172 | <li class="active">Animations + Transitions</li> |
||
| 173 | </ul> |
||
| 174 | <h1>Animations + Transitions</h1> |
||
| 175 | </div> |
||
| 176 | |||
| 177 | |||
| 178 | <div class="row-fluid"> |
||
| 179 | <div class="span9"> |
||
| 180 | <img src="demo_files/sago.jpg" id="target" alt="Jcrop Image" /> |
||
| 181 | |||
| 182 | <div class="description"> |
||
| 183 | <p id="shadetxt" style="display:none; color:#900;"> |
||
| 184 | <b>Experimental shader active.</b> |
||
| 185 | Jcrop now includes a shading mode that facilitates building |
||
| 186 | better transparent Jcrop instances. The experimental shader is less |
||
| 187 | robust than Jcrop's default shading method and should only be |
||
| 188 | used if you require this functionality. |
||
| 189 | </p> |
||
| 190 | |||
| 191 | <p> |
||
| 192 | <b>Animation/Transitions.</b> |
||
| 193 | Demonstration of animateTo API method and transitions for bgColor |
||
| 194 | and bgOpacity options. Color fading requires inclusion of John Resig's |
||
| 195 | jQuery <a href="http://plugins.jquery.com/project/color">Color |
||
| 196 | Animations</a> plugin. If it is not included, colors will not fade. |
||
| 197 | </p> |
||
| 198 | </div> |
||
| 199 | |||
| 200 | </div> |
||
| 201 | <div class="span3" id="interface"> |
||
| 202 | <label class="checkbox"> |
||
| 203 | <input type="checkbox" id="fadetog" /> Enable fading (bgFade: true) |
||
| 204 | </label> |
||
| 205 | <label class="checkbox"> |
||
| 206 | <input type="checkbox" id="shadetog" /> Use experimental shader (shade: true) |
||
| 207 | </label> |
||
| 208 | </div> |
||
| 209 | </div> |
||
| 210 | |||
| 211 | <div class="tapmodo-footer"> |
||
| 212 | <a href="http://tapmodo.com" class="tapmodo-logo segment">tapmodo.com</a> |
||
| 213 | <div class="segment"><b>© 2008-2013 Tapmodo Interactive LLC</b><br /> |
||
| 214 | Jcrop is free software released under <a href="../MIT-LICENSE.txt">MIT License</a> |
||
| 215 | </div> |
||
| 216 | </div> |
||
| 217 | |||
| 218 | <div class="clearfix"></div> |
||
| 219 | |||
| 220 | </div> |
||
| 221 | </div> |
||
| 222 | </div> |
||
| 223 | </div> |
||
| 224 | |||
| 225 | </body> |
||
| 226 | </html> |
||
| 227 |