|
1
|
|
|
<?php namespace XoopsModules\Tdmcreate\Files\Assets\Js; |
|
2
|
|
|
|
|
3
|
|
|
use XoopsModules\Tdmcreate; |
|
4
|
|
|
use XoopsModules\Tdmcreate\Files; |
|
5
|
|
|
|
|
6
|
|
|
/* |
|
7
|
|
|
You may not change or alter any portion of this comment or credits |
|
8
|
|
|
of supporting developers from this source code or any supporting source code |
|
9
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
10
|
|
|
|
|
11
|
|
|
This program is distributed in the hope that it will be useful, |
|
12
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
14
|
|
|
*/ |
|
15
|
|
|
/** |
|
16
|
|
|
* tdmcreate module. |
|
17
|
|
|
* |
|
18
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
19
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
20
|
|
|
* |
|
21
|
|
|
* @since 2.5.0 |
|
22
|
|
|
* |
|
23
|
|
|
* @author Txmod Xoops http://www.txmodxoops.org |
|
24
|
|
|
* |
|
25
|
|
|
* @version $Id: 1.91 JavascriptJQuery.php 12258 2014-01-02 09:33:29Z timgno $ |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Class JavascriptJQuery. |
|
30
|
|
|
*/ |
|
31
|
|
|
class JavascriptJQuery extends Files\CreateFile |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* @public function constructor |
|
35
|
|
|
* @param null |
|
36
|
|
|
*/ |
|
37
|
|
|
|
|
38
|
|
|
public function __construct() |
|
39
|
|
|
{ |
|
40
|
|
|
parent::__construct(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @static function getInstance |
|
45
|
|
|
* @param null |
|
46
|
|
|
* @return JavascriptJQuery |
|
47
|
|
|
*/ |
|
48
|
|
|
public static function getInstance() |
|
49
|
|
|
{ |
|
50
|
|
|
static $instance = false; |
|
51
|
|
|
if (!$instance) { |
|
52
|
|
|
$instance = new self(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
return $instance; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @public function write |
|
60
|
|
|
* @param string $module |
|
61
|
|
|
* @param string $filename |
|
62
|
|
|
*/ |
|
63
|
|
|
public function write($module, $filename) |
|
64
|
|
|
{ |
|
65
|
|
|
$this->setModule($module); |
|
66
|
|
|
$this->setFileName($filename); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @public function getJavascriptJQueryButtons |
|
71
|
|
|
* @param null |
|
72
|
|
|
* |
|
73
|
|
|
* @return string |
|
74
|
|
|
*/ |
|
75
|
|
|
public function getJavascriptJQueryButtons() |
|
76
|
|
|
{ |
|
77
|
|
|
$ret = <<<EOT |
|
78
|
|
|
$(document).ready(function(){ |
|
79
|
|
|
$( "button, input:button, input:submit, input:file, input:reset" ).css("color","inherit").button(); |
|
80
|
|
|
$( ".check" ).css("color","#fff").button(); |
|
81
|
|
|
$( ".radio" ).css("color","#fff").buttonset(); |
|
82
|
|
|
$( ".toolbar" ).css("color","#000").buttonset(); |
|
83
|
|
|
});\n\n |
|
84
|
|
|
EOT; |
|
85
|
|
|
|
|
86
|
|
|
return $ret; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @public function getJavascriptJQueryPrint |
|
91
|
|
|
* @param null |
|
92
|
|
|
* |
|
93
|
|
|
* @return string |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getJavascriptJQueryPrint() |
|
96
|
|
|
{ |
|
97
|
|
|
$ret = <<<'EOT' |
|
98
|
|
|
// <![CDATA[ |
|
99
|
|
|
/*------------------------------------------------------------------------------ |
|
100
|
|
|
Excerpts from the jsUtilities Library |
|
101
|
|
|
Version: 2.1 |
|
102
|
|
|
Homepage: http://www.easy-designs.net/code/jsUtilities/ |
|
103
|
|
|
License: Creative Commons Attribution-ShareAlike 2.0 License |
|
104
|
|
|
http://creativecommons.org/licenses/by-sa/2.0/ |
|
105
|
|
|
Note: If you change or improve on this script, please let us know. |
|
106
|
|
|
------------------------------------------------------------------------------*/ |
|
107
|
|
|
if(Array.prototype.push === null) { |
|
108
|
|
|
Array.prototype.push = function(item) { |
|
109
|
|
|
this[this.length] = item; |
|
110
|
|
|
return this.length; |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
// --------------------------------------------------------------------- |
|
114
|
|
|
// function.apply (if unsupported) |
|
115
|
|
|
// Courtesy of Aaron Boodman - http://youngpup.net |
|
116
|
|
|
// --------------------------------------------------------------------- |
|
117
|
|
|
if (!Function.prototype.apply) { |
|
118
|
|
|
Function.prototype.apply = function(oScope, args) { |
|
119
|
|
|
var sarg = []; |
|
120
|
|
|
var rtrn, call; |
|
121
|
|
|
if (!oScope) oScope = window; |
|
122
|
|
|
if (!args) args = []; |
|
123
|
|
|
for (var i = 0; i < args.length; i++) { |
|
124
|
|
|
sarg[i] = "args["+i+"]"; |
|
125
|
|
|
} |
|
126
|
|
|
call = "oScope.__applyTemp__(" + sarg.join(",") + ");"; |
|
127
|
|
|
oScope.__applyTemp__ = this; |
|
128
|
|
|
rtrn = eval(call); |
|
129
|
|
|
oScope.__applyTemp__ = null; |
|
130
|
|
|
return rtrn; |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
function inArray(needle) { |
|
134
|
|
|
for (var i=0; i < this.length; i++) { |
|
135
|
|
|
if (this[i] === needle) { |
|
136
|
|
|
return i; |
|
137
|
|
|
} |
|
138
|
|
|
} |
|
139
|
|
|
return false; |
|
140
|
|
|
} |
|
141
|
|
|
function addClass(theClass) { |
|
142
|
|
|
if (this.className != '') { |
|
143
|
|
|
this.className += ' ' + theClass; |
|
144
|
|
|
} else { |
|
145
|
|
|
this.className = theClass; |
|
146
|
|
|
} |
|
147
|
|
|
} |
|
148
|
|
|
function lastChildContainingText() { |
|
149
|
|
|
var testChild = this.lastChild; |
|
150
|
|
|
var contentCntnr = ['p','li','dd']; |
|
151
|
|
|
while (testChild.nodeType != 1) { |
|
152
|
|
|
testChild = testChild.previousSibling; |
|
153
|
|
|
} |
|
154
|
|
|
var tag = testChild.tagName.toLowerCase(); |
|
155
|
|
|
var tagInArr = inArray.apply(contentCntnr, [tag]); |
|
156
|
|
|
if (!tagInArr && tagInArr!==0) { |
|
157
|
|
|
testChild = lastChildContainingText.apply(testChild); |
|
158
|
|
|
} |
|
159
|
|
|
return testChild; |
|
160
|
|
|
} |
|
161
|
|
|
// ]]> |
|
162
|
|
|
EOT; |
|
163
|
|
|
|
|
164
|
|
|
return $ret; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* @public function render |
|
169
|
|
|
* @param null |
|
170
|
|
|
* |
|
171
|
|
|
* @return bool|string |
|
172
|
|
|
*/ |
|
173
|
|
|
public function render() |
|
174
|
|
|
{ |
|
175
|
|
|
$module = $this->getModule(); |
|
176
|
|
|
$filename = $this->getFileName(); |
|
177
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
178
|
|
|
$content = $this->getHeaderFilesComments($module, $filename); |
|
|
|
|
|
|
179
|
|
|
$content = $this->getJavascriptJQueryButtons(); |
|
180
|
|
|
$content .= $this->getJavascriptJQueryPrint(); |
|
181
|
|
|
|
|
182
|
|
|
$this->create($moduleDirname, 'assets/js', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
|
183
|
|
|
|
|
184
|
|
|
return $this->renderFile(); |
|
185
|
|
|
} |
|
186
|
|
|
} |
|
187
|
|
|
|