site-skel 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -0
- data/.gitmodules +3 -0
- data/README.markdown +37 -0
- data/Rakefile +13 -0
- data/VERSION +1 -0
- data/bin/site-skel +78 -0
- data/common/images/lightbox-blank.gif +0 -0
- data/common/images/lightbox-btn-close.gif +0 -0
- data/common/images/lightbox-btn-next.gif +0 -0
- data/common/images/lightbox-btn-prev.gif +0 -0
- data/common/images/lightbox-ico-loading.gif +0 -0
- data/common/javascripts/application.js +23 -0
- data/common/javascripts/jquery-extensions.js +184 -0
- data/common/javascripts/jquery.lightbox.min.js +41 -0
- data/common/javascripts/jquery.min.js +19 -0
- data/common/javascripts/pngfix.js +34 -0
- data/common/javascripts/sifr.js +18 -0
- data/common/javascripts/swfobject.js +230 -0
- data/common/stylesheets/ie.css +0 -0
- data/common/stylesheets/ie6.css +0 -0
- data/common/stylesheets/jquery.lightbox.css +101 -0
- data/common/stylesheets/main.css +55 -0
- data/common/stylesheets/sifr.css +79 -0
- data/common/stylesheets/zero.css +48 -0
- data/layouts/default/index.html +32 -0
- data/layouts/php/_offsite/lib/common/contact_form.php +45 -0
- data/layouts/php/_offsite/lib/common/helpers.php +9 -0
- data/layouts/php/_offsite/lib/common/template.php +42 -0
- data/layouts/php/_offsite/res/sifr-flash/Options.as +8 -0
- data/layouts/php/_offsite/res/sifr-flash/SifrStyleSheet.as +78 -0
- data/layouts/php/_offsite/res/sifr-flash/sIFR.as +555 -0
- data/layouts/php/_offsite/res/sifr-flash/sifr.fla +0 -0
- data/layouts/php/_offsite/tpl/_footer.php +5 -0
- data/layouts/php/_offsite/tpl/_header.php +39 -0
- data/layouts/php/all.php +31 -0
- data/layouts/php/index.php +4 -0
- data/layouts/php/tpl/.gitignore +0 -0
- data/lib/.gitignore +0 -0
- data/site-skel.gemspec +82 -0
- data/variants/default/footer.html +1 -0
- data/variants/default/header.html +1 -0
- data/variants/default/main.css +1 -0
- metadata +99 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
/* http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/ */
|
2
|
+
|
3
|
+
html, body, div, span, applet, object, iframe,
|
4
|
+
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
5
|
+
a, abbr, acronym, address, big, cite, code,
|
6
|
+
del, dfn, em, font, img, ins, kbd, q, s, samp,
|
7
|
+
small, strike, strong, sub, sup, tt, var,
|
8
|
+
dl, dt, dd, ol, ul, li,
|
9
|
+
fieldset, form, label, legend,
|
10
|
+
table, caption, tbody, tfoot, thead, tr, th, td {
|
11
|
+
margin: 0;
|
12
|
+
padding: 0;
|
13
|
+
border: 0;
|
14
|
+
outline: 0;
|
15
|
+
font-weight: inherit;
|
16
|
+
font-style: inherit;
|
17
|
+
font-size: 100%;
|
18
|
+
font-family: inherit;
|
19
|
+
vertical-align: baseline;
|
20
|
+
}
|
21
|
+
/* remember to define focus styles! */
|
22
|
+
:focus {
|
23
|
+
outline: 0;
|
24
|
+
}
|
25
|
+
body {
|
26
|
+
line-height: 1;
|
27
|
+
color: black;
|
28
|
+
background: white;
|
29
|
+
}
|
30
|
+
ol, ul {
|
31
|
+
list-style: none;
|
32
|
+
}
|
33
|
+
/* tables still need 'cellspacing="0"' in the markup */
|
34
|
+
table {
|
35
|
+
border-collapse: separate;
|
36
|
+
border-spacing: 0;
|
37
|
+
}
|
38
|
+
caption, th, td {
|
39
|
+
text-align: left;
|
40
|
+
font-weight: normal;
|
41
|
+
}
|
42
|
+
blockquote:before, blockquote:after,
|
43
|
+
q:before, q:after {
|
44
|
+
content: "";
|
45
|
+
}
|
46
|
+
blockquote, q {
|
47
|
+
quotes: "" "";
|
48
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
|
4
|
+
<html>
|
5
|
+
<head>
|
6
|
+
<title></title>
|
7
|
+
<meta name="description" content="" />
|
8
|
+
<meta name="keywords" content="" />
|
9
|
+
<script type='text/javascript' src='javascripts/swfobject.js'></script>
|
10
|
+
<script type='text/javascript' src='javascripts/jquery.min.js'></script>
|
11
|
+
<script type='text/javascript' src='javascripts/jquery.lightbox.min.js'></script>
|
12
|
+
<script type='text/javascript' src='javascripts/jquery-extensions.js'></script>
|
13
|
+
<script type='text/javascript' src='javascripts/application.js'></script>
|
14
|
+
<!--[if lt IE 7]>
|
15
|
+
<script defer type='text/javascript' src='javascripts/pngfix.js'></script>
|
16
|
+
<![endif]-->
|
17
|
+
<link rel="stylesheet" href="stylesheets/main.css" type="text/css" />
|
18
|
+
<!--[if IE]>
|
19
|
+
<link rel="stylesheet" href="stylesheets/ie.css" type="text/css" />
|
20
|
+
<![endif]-->
|
21
|
+
<!--[if lte IE 6]>
|
22
|
+
<link rel="stylesheet" href="stylesheets/ie6.css" type="text/css" />
|
23
|
+
<![endif]-->
|
24
|
+
</head>
|
25
|
+
<body>
|
26
|
+
|
27
|
+
<%= @header %>
|
28
|
+
|
29
|
+
<%= @footer %>
|
30
|
+
|
31
|
+
</body>
|
32
|
+
</html>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<?php
|
2
|
+
//
|
3
|
+
//
|
4
|
+
// Example:
|
5
|
+
// $c = new ContactForm();
|
6
|
+
//
|
7
|
+
// $emailer = new ContactFormEmailHandler();
|
8
|
+
// $emailer->to('jason@magiclamp.co.uk')->from('{email}');
|
9
|
+
// $c->add_handler($emailer);
|
10
|
+
//
|
11
|
+
// $csv = new ContactFormCSVHandler();
|
12
|
+
// $csv->path('/foo/bar/baz.csv')->fields('forename', 'surname', 'email');
|
13
|
+
// $c->add_handler($csv);
|
14
|
+
//
|
15
|
+
|
16
|
+
class ContactForm
|
17
|
+
{
|
18
|
+
|
19
|
+
}
|
20
|
+
|
21
|
+
interface ContactFormHandler
|
22
|
+
{
|
23
|
+
public function handle(ContactForm $form);
|
24
|
+
}
|
25
|
+
|
26
|
+
class ContactFormEmailHandler
|
27
|
+
{
|
28
|
+
private $to;
|
29
|
+
private $from;
|
30
|
+
|
31
|
+
public function handle(ContactForm $form) {
|
32
|
+
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
class ContactFormCSVHandler
|
37
|
+
{
|
38
|
+
private $path;
|
39
|
+
private $fields = array();
|
40
|
+
|
41
|
+
public function handle(ContactForm $form) {
|
42
|
+
|
43
|
+
}
|
44
|
+
}
|
45
|
+
?>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<?php
|
2
|
+
function template_file($f) {
|
3
|
+
if ($f === null) {
|
4
|
+
$f = basename($_SERVER['PHP_SELF'], '.php');
|
5
|
+
}
|
6
|
+
if ($f[0] == ':') {
|
7
|
+
$f = substr($f, 1);
|
8
|
+
$dir = TPL_ROOT;
|
9
|
+
} else {
|
10
|
+
$dir = TPL_DIR;
|
11
|
+
}
|
12
|
+
return "$dir/$f.php";
|
13
|
+
}
|
14
|
+
|
15
|
+
function display_template($__tpl__, $locals = array()) {
|
16
|
+
global $_TPL;
|
17
|
+
extract($_TPL);
|
18
|
+
require template_file($__tpl__);
|
19
|
+
}
|
20
|
+
|
21
|
+
function render_template($__tpl__, $locals = array()) {
|
22
|
+
ob_start();
|
23
|
+
display_template($__tpl__, $locals);
|
24
|
+
return ob_get_clean();
|
25
|
+
}
|
26
|
+
|
27
|
+
function get_template_var($k, $d = null) {
|
28
|
+
if (isset($GLOBALS['_TPL'][$k])) {
|
29
|
+
return $GLOBALS['_TPL'][$k];
|
30
|
+
} else {
|
31
|
+
return $d;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
function set_template_var($k, $v) {
|
36
|
+
$GLOBALS['_TPL'] = $v;
|
37
|
+
}
|
38
|
+
|
39
|
+
function set_template_ref($k, &$v) {
|
40
|
+
$GLOBALS['_TPL'] = &$v;
|
41
|
+
}
|
42
|
+
?>
|
@@ -0,0 +1,78 @@
|
|
1
|
+
/*=:project
|
2
|
+
scalable Inman Flash Replacement (sIFR) version 3.
|
3
|
+
|
4
|
+
=:file
|
5
|
+
Copyright: 2006 Mark Wubben.
|
6
|
+
Author: Mark Wubben, <http://novemberborn.net/>
|
7
|
+
|
8
|
+
=:history
|
9
|
+
* IFR: Shaun Inman
|
10
|
+
* sIFR 1: Mike Davidson, Shaun Inman and Tomas Jogin
|
11
|
+
* sIFR 2: Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben
|
12
|
+
|
13
|
+
=:license
|
14
|
+
This software is licensed and provided under the CC-GNU LGPL.
|
15
|
+
See <http://creativecommons.org/licenses/LGPL/2.1/>
|
16
|
+
*/
|
17
|
+
|
18
|
+
import TextField.StyleSheet;
|
19
|
+
|
20
|
+
class SifrStyleSheet extends TextField.StyleSheet {
|
21
|
+
public var fontSize;
|
22
|
+
public var latestLeading = 0;
|
23
|
+
|
24
|
+
public function parseCSS(cssText:String) {
|
25
|
+
var native = new TextField.StyleSheet();
|
26
|
+
var parsed = native.parseCSS(cssText);
|
27
|
+
|
28
|
+
if(!parsed) return false;
|
29
|
+
|
30
|
+
var selectors = native.getStyleNames();
|
31
|
+
for(var i = selectors.length - 1; i >= 0; i--) {
|
32
|
+
var selector = selectors[i];
|
33
|
+
var nativeStyle = native.getStyle(selector);
|
34
|
+
var style = this.getStyle(selector) || nativeStyle;
|
35
|
+
if(style != nativeStyle) {
|
36
|
+
for(var property in nativeStyle) style[property] = nativeStyle[property];
|
37
|
+
}
|
38
|
+
this.setStyle(selector, style);
|
39
|
+
}
|
40
|
+
|
41
|
+
return true;
|
42
|
+
}
|
43
|
+
|
44
|
+
// Apply leading to the textFormat. Much thanks to <http://www.blog.lessrain.com/?p=98>.
|
45
|
+
private function applyLeading(format, leading) {
|
46
|
+
this.latestLeading = leading;
|
47
|
+
|
48
|
+
// Fix leading internally
|
49
|
+
leading = parseInt(leading, 10) + sIFR.LEADING_REMAINDER;
|
50
|
+
|
51
|
+
if(leading >= 0) {
|
52
|
+
format.leading = leading;
|
53
|
+
return format;
|
54
|
+
}
|
55
|
+
|
56
|
+
// Workaround for negative leading, which is ignored otherwise.
|
57
|
+
var newFormat = new TextFormat(null, null, null, null, null, null, null, null, null, null, null, null, leading);
|
58
|
+
for(var property in format) if(property != 'leading') newFormat[property] = format[property];
|
59
|
+
|
60
|
+
return newFormat;
|
61
|
+
}
|
62
|
+
|
63
|
+
public function transform(style) {
|
64
|
+
var format = super.transform(style);
|
65
|
+
if(style.leading) format = applyLeading(format, style.leading);
|
66
|
+
if(style.letterSpacing) format.letterSpacing = style.letterSpacing;
|
67
|
+
if(style.fontSize) {
|
68
|
+
// Support font sizes relative to the size of .sIFR-root.
|
69
|
+
if (this.fontSize && style.fontSize.indexOf('%') > 0) {
|
70
|
+
format.size = this.fontSize * parseInt(style.fontSize, 10) / 100;
|
71
|
+
} else {
|
72
|
+
format.size = parseInt(style.fontSize, 10);
|
73
|
+
}
|
74
|
+
}
|
75
|
+
format.kerning = _root.kerning == 'true' || !(_root.kerning == 'false') || sIFR.defaultKerning;
|
76
|
+
return format;
|
77
|
+
}
|
78
|
+
}
|
@@ -0,0 +1,555 @@
|
|
1
|
+
/*****************************************************************************
|
2
|
+
scalable Inman Flash Replacement (sIFR) version 3.
|
3
|
+
|
4
|
+
Copyright 2006 – 2008 Mark Wubben, <http://novemberborn.net/>
|
5
|
+
|
6
|
+
Older versions:
|
7
|
+
* IFR by Shaun Inman
|
8
|
+
* sIFR 1.0 by Mike Davidson, Shaun Inman and Tomas Jogin
|
9
|
+
* sIFR 2.0 by Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben
|
10
|
+
|
11
|
+
See also <http://novemberborn.net/sifr3> and <http://wiki.novemberborn.net/sifr3>.
|
12
|
+
|
13
|
+
This software is licensed and provided under the CC-GNU LGPL.
|
14
|
+
See <http://creativecommons.org/licenses/LGPL/2.1/>
|
15
|
+
*****************************************************************************/
|
16
|
+
|
17
|
+
import SifrStyleSheet;
|
18
|
+
import flash.external.*;
|
19
|
+
|
20
|
+
class sIFR {
|
21
|
+
public static var DEFAULT_TEXT = 'Rendered with sIFR 3, revision 436<br><strong>Rendered with sIFR 3, revision 436</strong><br><em>Rendered with sIFR 3, revision 436</em><br><strong><em>Rendered with sIFR 3, revision 436</em></strong>';
|
22
|
+
public static var VERSION_WARNING = 'Movie (436) is incompatible with sifr.js (%s). Use movie of %s.<br><strong>Movie (436) is incompatible with sifr.js (%s). Use movie of %s.</strong><br><em>Movie (436) is incompatible with sifr.js (%s). Use movie of %s.</em><br><strong><em>Movie (436) is incompatible with sifr.js (%s). Use movie of %s.</em></strong>';
|
23
|
+
public static var CSS_ROOT_CLASS = 'sIFR-root';
|
24
|
+
public static var DEFAULT_WIDTH = 300;
|
25
|
+
public static var DEFAULT_HEIGHT = 100;
|
26
|
+
public static var DEFAULT_ANTI_ALIAS_TYPE = 'advanced';
|
27
|
+
public static var MARGIN_LEFT = -3;
|
28
|
+
public static var PADDING_BOTTOM = 5; // Extra padding to make sure the movie is high enough in most cases.
|
29
|
+
public static var LEADING_REMAINDER = 2; // Flash uses the specified leading minus 2 as the applied leading, so we increment by 2
|
30
|
+
|
31
|
+
public static var MIN_FONT_SIZE = 6;
|
32
|
+
public static var MAX_FONT_SIZE = 126;
|
33
|
+
// Minimal height of the Flash movie. This height is required in order to detect incorrect Stage height in the
|
34
|
+
// scaling calculations. JavaScript sets the size of the Flash movie to 0px by 0px, but at least Opera makes this
|
35
|
+
// 1px by 1px. With 1000% page zoom this would get to 10px, but the highest I saw was 8px. Seems safe enough to have
|
36
|
+
// the min height at 10px then.
|
37
|
+
public static var MIN_HEIGHT = 10;
|
38
|
+
public static var ALIASING_MAX_FONT_SIZE = 48;
|
39
|
+
public static var VERSION = '436';
|
40
|
+
|
41
|
+
//= Holds CSS properties and other rendering properties for the Flash movie.
|
42
|
+
// *Don't overwrite!*
|
43
|
+
public static var styles:SifrStyleSheet = new SifrStyleSheet();
|
44
|
+
//= Allow sIFR to be run from the filesystem
|
45
|
+
public static var fromLocal:Boolean = true;
|
46
|
+
//= Array containing domains for which sIFR may render text. Used to prevent
|
47
|
+
// hotlinking. Use `*` to allow all domains.
|
48
|
+
public static var domains:Array = [];
|
49
|
+
//= Whether kerning is enabled by default. This can be overriden from the client side.
|
50
|
+
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002811.html>.
|
51
|
+
public static var defaultKerning:Boolean = true;
|
52
|
+
//= Default value which can be overriden from the client side.
|
53
|
+
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002788.html>.
|
54
|
+
public static var defaultSharpness:Number = 0;
|
55
|
+
//= Default value which can be overriden from the client side.
|
56
|
+
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002787.html>.
|
57
|
+
public static var defaultThickness:Number = 0;
|
58
|
+
//= Default value which can be overriden from the client side.
|
59
|
+
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002732.html>.
|
60
|
+
public static var defaultOpacity:Number = -1; // Use client settings
|
61
|
+
//= Default value which can be overriden from the client side.
|
62
|
+
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002788.html>.
|
63
|
+
public static var defaultBlendMode:Number = -1; // Use cliest settings
|
64
|
+
//= Overrides the grid fit type as defined on the client side.
|
65
|
+
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002444.html>.
|
66
|
+
public static var enforcedGridFitType:String = null;
|
67
|
+
//= If `true` sIFR won't override the anti aliasing set in the Flash IDE when exporting.
|
68
|
+
// Thickness and sharpness won't be affected either.
|
69
|
+
public static var preserveAntiAlias:Boolean = false;
|
70
|
+
//= If `true` sIFR will disable anti-aliasing if the font size is larger than `ALIASING_MAX_FONT_SIZE`.
|
71
|
+
// This setting is *independent* from `preserveAntiAlias`.
|
72
|
+
public static var conditionalAntiAlias:Boolean = true;
|
73
|
+
//= Sets the anti alias type. By default it's `DEFAULT_ANTI_ALIAS_TYPE`.
|
74
|
+
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002733.html>.
|
75
|
+
public static var antiAliasType:String = null;
|
76
|
+
//= Flash filters can be added to this array and will be applied to the text field.
|
77
|
+
public static var filters:Array = [];
|
78
|
+
//= A mapping from the names of the filters to their actual objecs, used when transforming
|
79
|
+
// filters defined on the client. You can add additional filters here so they'll be supported
|
80
|
+
// when defined on the client.
|
81
|
+
public static var filterMap:Object = {
|
82
|
+
DisplacementMapFilter : flash.filters.DisplacementMapFilter,
|
83
|
+
ColorMatrixFilter : flash.filters.ColorMatrixFilter,
|
84
|
+
ConvolutionFilter : flash.filters.ConvolutionFilter,
|
85
|
+
GradientBevelFilter : flash.filters.GradientBevelFilter,
|
86
|
+
GradientGlowFilter : flash.filters.GradientGlowFilter,
|
87
|
+
BevelFilter : flash.filters.BevelFilter,
|
88
|
+
GlowFilter : flash.filters.GlowFilter,
|
89
|
+
BlurFilter : flash.filters.BlurFilter,
|
90
|
+
DropShadowFilter : flash.filters.DropShadowFilter
|
91
|
+
};
|
92
|
+
|
93
|
+
private static var instance;
|
94
|
+
private static var menu;
|
95
|
+
private static var menuItems = [];
|
96
|
+
|
97
|
+
private var textField;
|
98
|
+
private var content;
|
99
|
+
private var forceSingleLine;
|
100
|
+
private var fontSize;
|
101
|
+
private var tuneWidth;
|
102
|
+
private var tuneHeight;
|
103
|
+
private var primaryLink;
|
104
|
+
private var primaryLinkTarget;
|
105
|
+
|
106
|
+
public var realHeight;
|
107
|
+
public var renderHeight;
|
108
|
+
public var firstResize = true;
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
//= Sets the default styles for `sIFR.styles`. This method is called
|
113
|
+
// directly in `sifr.fla`, before options are applied.
|
114
|
+
public static function setDefaultStyles() {
|
115
|
+
sIFR.styles.parseCSS([
|
116
|
+
'.', CSS_ROOT_CLASS, ' { color: #000000; }',
|
117
|
+
'strong { display: inline; font-weight: bold; } ',
|
118
|
+
'em { display: inline; font-style: italic; }',
|
119
|
+
'a { color: #0000FF; text-decoration: underline; }',
|
120
|
+
'a:hover { color: #0000FF; text-decoration: none; }'
|
121
|
+
].join(''));
|
122
|
+
}
|
123
|
+
|
124
|
+
//= Validates the domain sIFR is being used on.
|
125
|
+
// Returns `true` if the domain is valid, `false` otherwise.
|
126
|
+
public static function checkDomain():Boolean {
|
127
|
+
if(sIFR.domains.length == 0) return true;
|
128
|
+
|
129
|
+
var domain = (new LocalConnection()).domain();
|
130
|
+
for(var i = 0; i < sIFR.domains.length; i++) {
|
131
|
+
var match = sIFR.domains[i];
|
132
|
+
if(match == '*' || match == domain) return true;
|
133
|
+
|
134
|
+
var wildcard = match.lastIndexOf('*');
|
135
|
+
if(wildcard > -1) {
|
136
|
+
match = match.substr(wildcard + 1);
|
137
|
+
var matchPosition = domain.lastIndexOf(match);
|
138
|
+
if(matchPosition > -1 && (matchPosition + match.length) == domain.length) return true;
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
return false;
|
143
|
+
}
|
144
|
+
|
145
|
+
public static function checkLocation():Boolean {
|
146
|
+
return _root._url.indexOf('?') == -1;
|
147
|
+
}
|
148
|
+
|
149
|
+
//= Runs sIFR. Called automatically.
|
150
|
+
public static function run(delayed) {
|
151
|
+
// Flash version older than 9,0,115 under IE incorrectly approach the Flash movie, breaking ExternalInterface.
|
152
|
+
// sIFR has a workaround, but this workaround cannot be applied until the Flash movie has been added to the document,
|
153
|
+
// which usually causes the ActionScript to run and set up ExternalInterface. Delaying for a couple milliseconds
|
154
|
+
// gives the JavaScript time to set up the workaround.
|
155
|
+
if(_root.delayrun == 'true' && !delayed) {
|
156
|
+
var interval;
|
157
|
+
interval = setInterval(
|
158
|
+
function() {
|
159
|
+
clearInterval(interval);
|
160
|
+
sIFR.run(true);
|
161
|
+
}, 200);
|
162
|
+
|
163
|
+
return;
|
164
|
+
}
|
165
|
+
|
166
|
+
// Have to set up the menu items first!
|
167
|
+
menuItems.push(
|
168
|
+
new ContextMenuItem("Follow link", function() { getURL(sIFR.instance.primaryLink, sIFR.instance.primaryLinkTarget) }),
|
169
|
+
new ContextMenuItem("Open link in new window", function() { getURL(sIFR.instance.primaryLink, "_blank") })
|
170
|
+
);
|
171
|
+
|
172
|
+
var holder = _root.holder;
|
173
|
+
var content = DEFAULT_TEXT;
|
174
|
+
var checkVersion = true;
|
175
|
+
if(checkLocation() && checkDomain()) content = unescapeUnicode(_root.content);
|
176
|
+
if(content == 'undefined' || content == '') {
|
177
|
+
var resetting = ExternalInterface.call('sIFR.__resetBrokenMovies');
|
178
|
+
if(resetting) return;
|
179
|
+
content = DEFAULT_TEXT;
|
180
|
+
checkVersion = false;
|
181
|
+
}
|
182
|
+
|
183
|
+
if(checkVersion && _root.version != VERSION) content = VERSION_WARNING.split('%s').join(_root.version);
|
184
|
+
|
185
|
+
// Sets stage parameters
|
186
|
+
Stage.scaleMode = 'noscale';
|
187
|
+
Stage.align = 'TL';
|
188
|
+
|
189
|
+
menu = new ContextMenu();
|
190
|
+
menu.hideBuiltInItems();
|
191
|
+
_root.menu = menu;
|
192
|
+
|
193
|
+
// Other parameters
|
194
|
+
var opacity = parseInt(_root.opacity, 10);
|
195
|
+
if(!isNaN(opacity)) holder._alpha = sIFR.defaultOpacity == -1 ? opacity : sIFR.defaultOpacity;
|
196
|
+
else holder._alpha = 100;
|
197
|
+
_root.blendMode = sIFR.defaultBlendMode == -1 ? _root.blendmode : sIFR.defaultBlendMode;
|
198
|
+
|
199
|
+
sIFR.instance = new sIFR(holder.txtF, content);
|
200
|
+
Key.addListener({onKeyDown: function() { sIFR.instance.blur() }});
|
201
|
+
Mouse.addListener({onMouseWheel: function() { sIFR.instance.blur() }});
|
202
|
+
Stage.addListener({onResize: function() { sIFR.instance.onResize(); }});
|
203
|
+
if(_root.selectable == 'false') Mouse.addListener({onMouseDown: function() { sIFR.instance.blur() }});
|
204
|
+
if(_root.cursor == 'arrow') _root.holder.useHandCursor = false;
|
205
|
+
|
206
|
+
ExternalInterface.addCallback('replaceText', sIFR.instance, sIFR.instance.replaceText);
|
207
|
+
ExternalInterface.addCallback('calculateRatios', sIFR.instance, sIFR.instance.calculateRatios);
|
208
|
+
ExternalInterface.addCallback('resize', sIFR.instance, sIFR.instance.resize);
|
209
|
+
ExternalInterface.addCallback('scaleMovie', sIFR.instance, sIFR.instance.repaint);
|
210
|
+
ExternalInterface.addCallback('changeCSS', sIFR.instance, sIFR.instance.changeCSS);
|
211
|
+
}
|
212
|
+
|
213
|
+
private static function eval(str) {
|
214
|
+
var as;
|
215
|
+
|
216
|
+
if(str.charAt(0) == '{') { // Ah, we need to create an object
|
217
|
+
as = {};
|
218
|
+
str = str.substring(1, str.length - 1);
|
219
|
+
var $ = str.split(',');
|
220
|
+
for(var i = 0; i < $.length; i++) {
|
221
|
+
var $1 = $[i].split(':');
|
222
|
+
as[$1[0]] = sIFR.eval($1[1]);
|
223
|
+
}
|
224
|
+
} else if(str.charAt(0) == '"') { // String
|
225
|
+
as = str.substring(1, str.length - 1);
|
226
|
+
} else if(str == 'true' || str == 'false') { // Boolean
|
227
|
+
as = str == 'true';
|
228
|
+
} else { // Float
|
229
|
+
as = parseFloat(str);
|
230
|
+
}
|
231
|
+
|
232
|
+
return as;
|
233
|
+
}
|
234
|
+
|
235
|
+
private static function unescapeUnicode(str) {
|
236
|
+
var result = [];
|
237
|
+
var escapees = str.split('%');
|
238
|
+
|
239
|
+
for(var i = 0; i < escapees.length; i++) {
|
240
|
+
var escapee = escapees[i];
|
241
|
+
if(i > 0 || str.charAt(0) == '%') {
|
242
|
+
var hex = escapee.charAt(0) == 'u' ? escapee.substr(1, 4) : escapee.substr(0, 2);
|
243
|
+
result.push(String.fromCharCode(parseInt(hex, 16)), escapee.substr(escapee.charAt(0) == 'u' ? 5 : 2));
|
244
|
+
} else result.push(escapee);
|
245
|
+
}
|
246
|
+
|
247
|
+
return result.join('');
|
248
|
+
}
|
249
|
+
|
250
|
+
private function applyFilters() {
|
251
|
+
var $filters = this.textField.filters;
|
252
|
+
$filters = $filters.concat(sIFR.filters);
|
253
|
+
|
254
|
+
var $ = unescapeUnicode(_root.flashfilters).split(';'); // name,prop:value,...;
|
255
|
+
for(var i = 0; i < $.length; i++) {
|
256
|
+
var $1 = $[i].split(',');
|
257
|
+
|
258
|
+
var newFilter = new sIFR.filterMap[$1[0]]();
|
259
|
+
for(var j = 1; j < $1.length; j++) {
|
260
|
+
var $2 = $1[j].split(':');
|
261
|
+
newFilter[$2[0]] = sIFR.eval(unescapeUnicode($2[1]));
|
262
|
+
}
|
263
|
+
|
264
|
+
$filters.push(newFilter);
|
265
|
+
}
|
266
|
+
|
267
|
+
this.textField.filters = $filters;
|
268
|
+
}
|
269
|
+
|
270
|
+
private function applyBackground() {
|
271
|
+
if(!_root.background) return;
|
272
|
+
|
273
|
+
var background = _root.createEmptyMovieClip('backgroundClip', 10);
|
274
|
+
var loader = new MovieClipLoader();
|
275
|
+
loader.addListener({onLoadInit: function() { background.setMask(_root.holder) }});
|
276
|
+
loader.loadClip("/projectfiles/img.jpg", background);
|
277
|
+
}
|
278
|
+
|
279
|
+
private function setTextFieldSize(width, height) {
|
280
|
+
textField._width = tuneWidth + (isNaN(width) ? DEFAULT_WIDTH : width);
|
281
|
+
textField._height = tuneHeight + (isNaN(height) ? DEFAULT_HEIGHT : height);
|
282
|
+
}
|
283
|
+
|
284
|
+
private function sIFR(textField, content) {
|
285
|
+
sIFR.instance = this; // Need to set it right now, because it's used in closures later
|
286
|
+
|
287
|
+
this.textField = textField;
|
288
|
+
this.content = content;
|
289
|
+
|
290
|
+
this.primaryLink = unescapeUnicode(_root.link);
|
291
|
+
this.primaryLinkTarget = unescapeUnicode(_root.target);
|
292
|
+
|
293
|
+
var offsetLeft = parseInt(_root.offsetleft, 10);
|
294
|
+
textField._x = MARGIN_LEFT + (isNaN(offsetLeft) ? 0 : offsetLeft);
|
295
|
+
var offsetTop = parseInt(_root.offsettop, 10);
|
296
|
+
if(!isNaN(offsetTop)) textField._y += offsetTop;
|
297
|
+
|
298
|
+
tuneWidth = parseInt(_root.tunewidth, 10);
|
299
|
+
if(isNaN(tuneWidth)) tuneWidth = 0;
|
300
|
+
tuneHeight = parseInt(_root.tuneheight, 10);
|
301
|
+
if(isNaN(tuneHeight)) tuneHeight = 0;
|
302
|
+
|
303
|
+
this.renderHeight = parseInt(_root.renderheight, 10);
|
304
|
+
this.setTextFieldSize(parseInt(_root.width, 10), parseInt(this.renderHeight, 10));
|
305
|
+
this.forceSingleLine = _root.forcesingleline == 'true';
|
306
|
+
textField.wordWrap = _root.preventwrap != 'true';
|
307
|
+
textField.selectable = _root.selectable == 'true';
|
308
|
+
textField.gridFitType = sIFR.enforcedGridFitType || _root.gridfittype;
|
309
|
+
|
310
|
+
this.applyFilters();
|
311
|
+
this.applyBackground();
|
312
|
+
|
313
|
+
this.fontSize = parseInt(_root.size, 10);
|
314
|
+
if(isNaN(this.fontSize)) this.fontSize = 26;
|
315
|
+
|
316
|
+
this.setStyles(unescapeUnicode(_root.css), false);
|
317
|
+
|
318
|
+
if(!sIFR.preserveAntiAlias && (sIFR.conditionalAntiAlias && this.fontSize < ALIASING_MAX_FONT_SIZE
|
319
|
+
|| !sIFR.conditionalAntiAlias)) {
|
320
|
+
textField.antiAliasType = (_root.antialiastype != '' ? _root.antialiastype : sIFR.antiAliasType) || DEFAULT_ANTI_ALIAS_TYPE;
|
321
|
+
}
|
322
|
+
|
323
|
+
if(!sIFR.preserveAntiAlias || !isNaN(parseInt(_root.sharpness, 10))) {
|
324
|
+
textField.sharpness = parseInt(_root.sharpness, 10);
|
325
|
+
}
|
326
|
+
if(isNaN(textField.sharpness)) textField.sharpness = sIFR.defaultSharpness;
|
327
|
+
|
328
|
+
if(!sIFR.preserveAntiAlias || !isNaN(parseInt(_root.thickness, 10))) {
|
329
|
+
textField.thickness = parseInt(_root.thickness, 10);
|
330
|
+
}
|
331
|
+
if(isNaN(textField.thickness)) textField.thickness = sIFR.defaultThickness;
|
332
|
+
|
333
|
+
textField._parent._xscale = textField._parent._yscale = 100;
|
334
|
+
|
335
|
+
this.setupEvents();
|
336
|
+
this.write(content);
|
337
|
+
this.repaint();
|
338
|
+
}
|
339
|
+
|
340
|
+
private static function call(method) {
|
341
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
342
|
+
args.unshift('sIFR.replacements["' + _root.id + '"].' + method);
|
343
|
+
return ExternalInterface.call.apply(ExternalInterface, args);
|
344
|
+
}
|
345
|
+
|
346
|
+
private function repaint() {
|
347
|
+
if(this.forceSingleLine) {
|
348
|
+
this.textField._width = 50000;
|
349
|
+
// 50 000 is a bit too much, filters won't work at that size etc. Therefore we size it down to the text width, and
|
350
|
+
// a bit of margin.
|
351
|
+
this.textField._width = this.textField.textWidth + 500;
|
352
|
+
}
|
353
|
+
|
354
|
+
var leadingFix = this.isSingleLine() ? sIFR.styles.latestLeading : 0;
|
355
|
+
|
356
|
+
// Flash wants to scroll the movie by one line, by adding the fontSize to the
|
357
|
+
// textField height this is no longer happens. We also add the absolute tuneHeight,
|
358
|
+
// to prevent a negative value from triggering the bug. We won't send the fake
|
359
|
+
// value to the JavaScript side, though.
|
360
|
+
textField._height = Math.max(MIN_HEIGHT, textField.textHeight + PADDING_BOTTOM + tuneHeight - leadingFix) + this.fontSize + Math.abs(tuneHeight);
|
361
|
+
this.realHeight = Math.floor(textField._height - this.fontSize - Math.abs(tuneHeight));
|
362
|
+
var width = _root.fitexactly == 'true' ? textField.textWidth + tuneWidth : null;
|
363
|
+
|
364
|
+
this.doScale(function() {
|
365
|
+
// Store in a local variable to deal with synchronous interaction with JavaScript.
|
366
|
+
var firstResize = sIFR.instance.firstResize;
|
367
|
+
sIFR.instance.firstResize = false;
|
368
|
+
sIFR.call('resizeFlashElement', sIFR.instance.realHeight, width, firstResize);
|
369
|
+
sIFR.instance.renderHeight = sIFR.instance.realHeight;
|
370
|
+
});
|
371
|
+
}
|
372
|
+
|
373
|
+
private function write(content) {
|
374
|
+
this.textField.htmlText = ['<p class="', CSS_ROOT_CLASS, '">',
|
375
|
+
content, '</p>'
|
376
|
+
].join('');
|
377
|
+
}
|
378
|
+
|
379
|
+
private function isSingleLine() {
|
380
|
+
return Math.round((this.textField.textHeight - sIFR.styles.latestLeading) / this.fontSize) == 1;
|
381
|
+
}
|
382
|
+
|
383
|
+
public function doScale(callback) {
|
384
|
+
if(this.validScale()) return this.scale(callback);
|
385
|
+
|
386
|
+
var self = this;
|
387
|
+
this.textField._parent.onEnterFrame = function() {
|
388
|
+
if(!self.validScale()) return;
|
389
|
+
delete self.textField._parent.onEnterFrame;
|
390
|
+
self.scale(callback);
|
391
|
+
}
|
392
|
+
}
|
393
|
+
|
394
|
+
//= Scales the text field to the new scale of the Flash movie itself.
|
395
|
+
public function scale(callback) {
|
396
|
+
this.textField._parent._xscale = this.textField._parent._yscale = this.calculateScale();
|
397
|
+
if(callback) callback();
|
398
|
+
}
|
399
|
+
|
400
|
+
public function calculateScale() {
|
401
|
+
return 10 * Math.round(10 * Stage.height / this.renderHeight);
|
402
|
+
}
|
403
|
+
|
404
|
+
public function validScale() {
|
405
|
+
return Stage.height >= 10 && this.calculateScale() >= 20;
|
406
|
+
}
|
407
|
+
|
408
|
+
public function onResize() {
|
409
|
+
if(!this.validScale()) return;
|
410
|
+
|
411
|
+
var oldZoom = this.textField._parent._xscale;
|
412
|
+
var zoom = this.calculateScale();
|
413
|
+
|
414
|
+
this.scale();
|
415
|
+
if(oldZoom != zoom) sIFR.call('resizeAfterScale');
|
416
|
+
}
|
417
|
+
|
418
|
+
private function calculateRatios() {
|
419
|
+
var strings = ['x', 'x<br>x', 'x<br>x<br>x', 'x<br>x<br>x<br>x'];
|
420
|
+
var results = {};
|
421
|
+
|
422
|
+
this.setTextFieldSize(1000, 1000);
|
423
|
+
|
424
|
+
for(var i = 1; i <= strings.length; i++) {
|
425
|
+
var size = MIN_FONT_SIZE;
|
426
|
+
|
427
|
+
this.write(strings[i - 1]);
|
428
|
+
while(size < MAX_FONT_SIZE) {
|
429
|
+
var rootStyle = sIFR.styles.getStyle('.sIFR-root') || {};
|
430
|
+
rootStyle.fontSize = size;
|
431
|
+
sIFR.styles.setStyle('.sIFR-root', rootStyle);
|
432
|
+
this.textField.styleSheet = sIFR.styles;
|
433
|
+
this.repaint();
|
434
|
+
var ratio = (this.realHeight - PADDING_BOTTOM - tuneHeight) / i / size;
|
435
|
+
if(!results[size]) results[size] = ratio;
|
436
|
+
else results[size] = ((i - 1) * results[size] + ratio) / i;
|
437
|
+
size++;
|
438
|
+
}
|
439
|
+
}
|
440
|
+
|
441
|
+
var ratios = [];
|
442
|
+
|
443
|
+
// Here we round the ratios to two decimals and try to create an optimized array of ratios
|
444
|
+
// to be used by sIFR.
|
445
|
+
// lastRatio is the ratio we are currently optimizing
|
446
|
+
var lastRatio = roundDecimals(results[MIN_FONT_SIZE], 2);
|
447
|
+
for(var size = MIN_FONT_SIZE + 1; size < MAX_FONT_SIZE; size++) {
|
448
|
+
var ratio = roundDecimals(results[size], 2);
|
449
|
+
|
450
|
+
// If the lastRatio is different from the previous ratio, and from the current ratio,
|
451
|
+
// try to see if there's at least a 1px difference between the two. If so, store the
|
452
|
+
// lastRatio with the previous size, then optimize the current ratio.
|
453
|
+
if(lastRatio != results[size - 1] && lastRatio != ratio && Math.abs(Math.round(size * ratio) - Math.round(size * lastRatio)) >= 1) {
|
454
|
+
ratios.push(size -1, lastRatio);
|
455
|
+
lastRatio = ratio;
|
456
|
+
}
|
457
|
+
}
|
458
|
+
|
459
|
+
// Add the last optimized ratio as the default ratio.
|
460
|
+
ratios.push(lastRatio);
|
461
|
+
|
462
|
+
ExternalInterface.call('sIFR.debug.__ratiosCallback', _root.id, ratios);
|
463
|
+
}
|
464
|
+
|
465
|
+
private function roundDecimals(value, decimals) {
|
466
|
+
return Math.round(value * Math.pow(10, decimals)) / Math.pow(10, decimals);
|
467
|
+
}
|
468
|
+
|
469
|
+
public function replaceText(content) {
|
470
|
+
this.content = unescapeUnicode(content);
|
471
|
+
this.setupEvents();
|
472
|
+
this.write(this.content);
|
473
|
+
this.repaint();
|
474
|
+
}
|
475
|
+
|
476
|
+
public function resize(height) {
|
477
|
+
this.setTextFieldSize(height, this.realHeight);
|
478
|
+
this.repaint();
|
479
|
+
}
|
480
|
+
|
481
|
+
public function changeCSS(css) {
|
482
|
+
this.setStyles(unescapeUnicode(css), true);
|
483
|
+
this.repaint();
|
484
|
+
}
|
485
|
+
|
486
|
+
private function contentIsLink() {
|
487
|
+
return this.content.indexOf('<a ') == 0 && this.content.indexOf('<a ') == this.content.lastIndexOf('<a ')
|
488
|
+
&& this.content.indexOf('</a>') == this.content.length - 4;
|
489
|
+
}
|
490
|
+
|
491
|
+
private function setupEvents() {
|
492
|
+
if(_root.fixhover == 'true' && this.contentIsLink()) {
|
493
|
+
|
494
|
+
this.textField._parent.onRollOver = function() {
|
495
|
+
sIFR.call('fireEvent', 'onRollOver');
|
496
|
+
};
|
497
|
+
|
498
|
+
this.textField._parent.onRollOut = function() {
|
499
|
+
sIFR.instance.fixHover();
|
500
|
+
sIFR.call('fireEvent', 'onRollOut');
|
501
|
+
};
|
502
|
+
|
503
|
+
this.textField._parent.onRelease = function() {
|
504
|
+
sIFR.call('fireEvent', 'onRelease');
|
505
|
+
getURL(sIFR.instance.primaryLink, sIFR.instance.primaryLinkTarget);
|
506
|
+
};
|
507
|
+
|
508
|
+
menu.customItems = menuItems;
|
509
|
+
} else {
|
510
|
+
if(_root.events == 'true') {
|
511
|
+
this.textField._parent.onRollOver = function() { sIFR.call('fireEvent', 'onRollOver') };
|
512
|
+
this.textField._parent.onRollOut = function() { sIFR.call('fireEvent', 'onRollOut') };
|
513
|
+
this.textField._parent.onRelease = function() { sIFR.call('fireEvent', 'onRelease') };
|
514
|
+
} else {
|
515
|
+
if(_root.cursor == 'pointer') this.textField._parent.onRelease = function() {};
|
516
|
+
else delete this.textField._parent.onRelease;
|
517
|
+
delete this.textField._parent.onRollOver;
|
518
|
+
delete this.textField._parent.onRollOut;
|
519
|
+
}
|
520
|
+
|
521
|
+
menu.customItems = [];
|
522
|
+
}
|
523
|
+
}
|
524
|
+
|
525
|
+
private function fixHover() {
|
526
|
+
this.write('');
|
527
|
+
this.write(this.content);
|
528
|
+
}
|
529
|
+
|
530
|
+
public function blur() {
|
531
|
+
switch(Key.getCode()) {
|
532
|
+
case Key.SHIFT:
|
533
|
+
case Key.CONTROL:
|
534
|
+
break;
|
535
|
+
default:
|
536
|
+
sIFR.call('blurFlashElement');
|
537
|
+
}
|
538
|
+
}
|
539
|
+
|
540
|
+
private function setStyles(css, reset) {
|
541
|
+
if(reset) {
|
542
|
+
sIFR.styles = new SifrStyleSheet();
|
543
|
+
sIFR.setDefaultStyles();
|
544
|
+
}
|
545
|
+
|
546
|
+
sIFR.styles.fontSize = this.fontSize;
|
547
|
+
// Set font-size and other styles
|
548
|
+
sIFR.styles.parseCSS(css);
|
549
|
+
|
550
|
+
var rootStyle = sIFR.styles.getStyle('.sIFR-root') || {};
|
551
|
+
rootStyle.fontSize = this.fontSize; // won't go higher than 126!
|
552
|
+
sIFR.styles.setStyle('.sIFR-root', rootStyle);
|
553
|
+
this.textField.styleSheet = sIFR.styles;
|
554
|
+
}
|
555
|
+
}
|