Page Menu
Home
Code
Search
Configure Global Search
Log In
Files
F885569
user_css.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
user_css.js
View Options
/**
* modules/user_css/user_css.js
* Frontend code for setting user-defined per-site and global stylesheets
*
* Copyright Gottfried Haider, Danja Vasiliev 2010.
* This source code is licensed under the GNU General Public License.
* See the file COPYING for more details.
*/
$
(
document
).
ready
(
function
()
{
var
insert_at_cursor
=
function
(
elem
,
s
)
{
// inspired from http://forumsblogswikis.com/2008/07/20/how-to-insert-tabs-in-a-textarea/
// this only includes the code for Firefox and Webkit though
var
elem
=
$
(
elem
).
get
(
0
);
var
start
=
elem
.
selectionStart
;
var
end
=
elem
.
selectionEnd
;
elem
.
value
=
elem
.
value
.
substring
(
0
,
start
)
+
s
+
elem
.
value
.
substring
(
end
,
elem
.
value
.
length
);
elem
.
selectionStart
=
start
+
s
.
length
;
elem
.
selectionEnd
=
start
+
s
.
length
;
};
if
(
$
(
'#user_css_text'
).
val
().
length
)
{
$
(
'#user_css_text'
).
focus
();
}
$
(
'#user_css_text'
).
bind
(
'keydown'
,
function
(
e
)
{
if
(
e
.
which
==
9
)
{
// tab (key code 9)
insert_at_cursor
(
$
(
this
),
String
.
fromCharCode
(
9
));
e
.
preventDefault
();
return
false
;
}
});
$
(
'#user_css_save'
).
bind
(
'click'
,
function
(
e
)
{
$
(
this
).
attr
(
'disabled'
,
'disabled'
);
$
(
this
).
attr
(
'value'
,
'saving..'
);
var
that
=
this
;
$
.
glue
.
backend
({
method
:
'user_css.set_css'
,
page
:
$
.
glue
.
page
,
css
:
$
(
'#user_css_text'
).
val
()
},
function
(
data
)
{
$
(
that
).
removeAttr
(
'disabled'
);
$
(
that
).
attr
(
'value'
,
'saved'
);
setTimeout
(
function
()
{
$
(
that
).
attr
(
'value'
,
'save'
);
},
2000
);
if
(
$
.
glue
.
page
&&
$
(
'#user_css_page_link'
).
length
==
0
)
{
$
(
'body'
).
append
(
$
(
'<a id="user_css_page_link" href="'
+
$
.
glue
.
base_url
+
'?'
+
$
.
glue
.
page
+
'/edit">go to page</a>'
));
}
});
});
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 6, 17:12 (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
23566
Default Alt Text
user_css.js (1 KB)
Attached To
rZEDHG ZedLegacy
Event Timeline
Log In to Comment