| author | ymh <ymh.work@gmail.com> |
| Thu, 23 Sep 2010 18:20:24 +0200 | |
| changeset 72 | d672f33a3a67 |
| parent 71 | fc1210bbb854 |
| child 76 | d2c2d9e8523e |
| permissions | -rw-r--r-- |
| 44 | 1 |
$.fn.realVal = function() { |
2 |
var obj = $(this[0]); |
|
3 |
if(obj.val) { |
|
4 |
if(obj.val() == obj.attr('defaultText')) { |
|
5 |
return ''; |
|
6 |
} |
|
7 |
else { |
|
8 |
return obj.val(); |
|
9 |
} |
|
10 |
} |
|
11 |
else { |
|
12 |
return null; |
|
13 |
} |
|
14 |
}; |
|
15 |
||
| 49 | 16 |
function init_events_base(base_node, embed_url) { |
| 44 | 17 |
|
18 |
$('.ldt_link',base_node).nyroModal({ |
|
19 |
type: 'iframe', |
|
20 |
forceType: 'iframe', |
|
| 47 | 21 |
windowResize: false, |
| 44 | 22 |
height:662, |
23 |
width:1022, |
|
24 |
bgColor: 'rgb(239, 239, 239)', |
|
25 |
padding: 5, |
|
26 |
titleFromIframe: false |
|
27 |
}); |
|
28 |
|
|
29 |
$('.ldt_link_create',base_node).nyroModal({ |
|
30 |
type: 'iframe', |
|
31 |
forceType: 'iframe', |
|
| 47 | 32 |
windowResize: false, |
|
45
db4e163c7c8e
first version of create project link
ymh <ymh.work@gmail.com>
parents:
44
diff
changeset
|
33 |
height:680, |
|
db4e163c7c8e
first version of create project link
ymh <ymh.work@gmail.com>
parents:
44
diff
changeset
|
34 |
width:500, |
| 44 | 35 |
bgColor: 'rgb(239, 239, 239)', |
36 |
padding: 5, |
|
37 |
titleFromIframe: false, |
|
38 |
beforeHideContent: function(elts, settings, callback){ |
|
39 |
try { |
|
40 |
var res = $('#ldtInitSwf',$('#nyroModalIframe').contents()); |
|
41 |
if(res.length > 0) |
|
42 |
{ |
|
43 |
res.get(0).forceSave(); |
|
44 |
} |
|
45 |
} |
|
46 |
catch(err) |
|
47 |
{ |
|
48 |
// do nothing |
|
49 |
} |
|
50 |
callback(); |
|
| 47 | 51 |
}, |
52 |
endShowContent: function(elts, settings){ |
|
53 |
var iframe = $('#nyroModalIframe', elts.content); |
|
54 |
iframe.load(function(){ |
|
55 |
var swfobject = $(this).contents().find("#ldtInitSwf"); |
|
56 |
if (swfobject.length) { |
|
57 |
$.nyroModalSettings({ |
|
58 |
height: swfobject.height() + 31, |
|
59 |
width: swfobject.width() + 21 |
|
60 |
}); |
|
61 |
} |
|
62 |
}); |
|
| 44 | 63 |
} |
64 |
}); |
|
65 |
||
66 |
$('.ldt_link_embed',base_node).click(function(e) { |
|
67 |
e.preventDefault(); |
|
68 |
var link = $(e.target); |
|
69 |
var json_url = link.attr("href"); |
|
70 |
var player_id = link.attr("id"); |
|
71 |
/*$.nyroModalSettings({ |
|
72 |
ajax: { data: ({ json_url:json_url, player_id:player_id }) } |
|
73 |
});*/ |
|
74 |
$.nyroModalManual({ |
|
| 47 | 75 |
type: 'iframe', |
76 |
forceType: 'iframe', |
|
77 |
titleFromIframe: false, |
|
78 |
height:662, |
|
| 62 | 79 |
width:750, |
| 47 | 80 |
bgColor: 'rgb(239, 239, 239)', |
81 |
padding: 5, |
|
| 49 | 82 |
url: embed_url+'?json_url='+escape(json_url)+'&player_id='+escape(player_id), |
| 44 | 83 |
}); |
84 |
return false; |
|
85 |
}); |
|
86 |
||
87 |
||
88 |
$('.imageline',base_node).each(function(i) { |
|
89 |
var tr = $(this); |
|
90 |
tr.mouseover(function() { |
|
91 |
$('.cellimgdiv',this).css('visibility', 'visible'); |
|
92 |
}); |
|
93 |
tr.mouseout(function() { |
|
94 |
$('.cellimgdiv',this).css('visibility', 'hidden'); |
|
95 |
}); |
|
96 |
}); |
|
97 |
|
|
98 |
$('.cellimgdiv img').qtip({ |
|
99 |
style: { |
|
100 |
'name': 'dark', |
|
101 |
'filter':'alpha(opacity=70)', |
|
102 |
'-moz-opacity':'0.7', |
|
103 |
'-khtml-opacity': '0.7', |
|
104 |
'opacity': '0.7', |
|
105 |
'border': { |
|
106 |
'width' : '0', |
|
107 |
'color': '#505050', |
|
108 |
}, |
|
109 |
'tip': true |
|
110 |
} |
|
111 |
}); |
|
112 |
|
|
113 |
||
114 |
}; |
|
115 |
||
116 |
||
117 |
function searchCallback(target, container_selector, url, timeout) { |
|
118 |
||
119 |
timeout = typeof(timeout) != 'undefined' ? timeout : 0; |
|
| 63 | 120 |
var target = $(target); |
121 |
|
|
| 72 | 122 |
// remove all qtip |
123 |
$(".qtip").remove(); |
|
124 |
|
|
| 63 | 125 |
if(target.realVal().length > 0) { |
126 |
target.nextAll(".searchclear").show(); |
|
127 |
} |
|
| 44 | 128 |
|
129 |
if(target.attr('timer')) { |
|
130 |
clearTimeout(target.attr('timer')); |
|
131 |
} |
|
132 |
|
|
133 |
target.attr('timer',setTimeout(function() { |
|
134 |
target.next(".searchajaxloader").show(); |
|
| 63 | 135 |
target.nextAll(".searchclear").hide(); |
|
71
fc1210bbb854
correct translation +some bug on update
ymh <ymh.work@gmail.com>
parents:
67
diff
changeset
|
136 |
var realVal = target.realVal(); |
|
fc1210bbb854
correct translation +some bug on update
ymh <ymh.work@gmail.com>
parents:
67
diff
changeset
|
137 |
if(realVal.length == 0) { |
|
fc1210bbb854
correct translation +some bug on update
ymh <ymh.work@gmail.com>
parents:
67
diff
changeset
|
138 |
realVal = "_"; |
|
fc1210bbb854
correct translation +some bug on update
ymh <ymh.work@gmail.com>
parents:
67
diff
changeset
|
139 |
} |
| 63 | 140 |
url = url.replace('__FILTER__',escape(target.realVal())); |
| 44 | 141 |
$(container_selector).load(url, null, function() { |
142 |
target.next(".searchajaxloader").hide(); |
|
| 63 | 143 |
if(target.realVal().length > 0) { |
144 |
target.nextAll(".searchclear").show(); |
|
145 |
} |
|
| 44 | 146 |
init_events($(container_selector)); |
147 |
target.removeAttr('timer'); |
|
148 |
}); |
|
149 |
}, |
|
150 |
300)); |
|
151 |
}; |
|
152 |
||
153 |
||
| 72 | 154 |
function init_events_contents(base_node, embed_url, content_filter_url) { |
| 44 | 155 |
|
| 49 | 156 |
init_events_base(base_node, embed_url); |
| 44 | 157 |
|
158 |
$('.content_link_create').nyroModal({ |
|
159 |
type: 'iframe', |
|
160 |
forceType: 'iframe', |
|
161 |
height:500, |
|
162 |
width:765, |
|
163 |
bgColor: 'rgb(239, 239, 239)', |
|
164 |
padding: 5, |
|
165 |
titleFromIframe: false, |
|
166 |
endRemove: function(elts, settings) { |
|
167 |
searchCallback($("#searchcontentsinput"),"#contentslistcontainer",content_filter_url) |
|
168 |
}, |
|
169 |
endShowContent: function(elts, settings) { |
|
170 |
$('#nyroModalIframe', elts.content).load(function() { |
|
171 |
var form_status = $(this).contents().find("#content_form_status").val(); |
|
172 |
if(form_status == 'saved') { |
|
173 |
$.nyroModalRemove(); |
|
174 |
} |
|
175 |
}); |
|
176 |
} |
|
177 |
}); |
|
| 67 | 178 |
|
179 |
$('.contenttitlelink').nyroModal({ |
|
180 |
type: 'iframe', |
|
181 |
forceType: 'iframe', |
|
182 |
height:500, |
|
183 |
width:765, |
|
184 |
bgColor: 'rgb(239, 239, 239)', |
|
185 |
padding: 5, |
|
186 |
titleFromIframe: false, |
|
187 |
endRemove: function(elts, settings) { |
|
188 |
searchCallback($("#searchcontentsinput"),"#contentslistcontainer",content_filter_url) |
|
189 |
}, |
|
190 |
endShowContent: function(elts, settings) { |
|
191 |
$('#nyroModalIframe', elts.content).load(function() { |
|
192 |
var form_status = $(this).contents().find("#content_form_status").val(); |
|
193 |
if(form_status == 'saved') { |
|
194 |
$.nyroModalRemove(); |
|
195 |
} |
|
196 |
}); |
|
197 |
} |
|
198 |
}); |
|
199 |
||
| 44 | 200 |
|
201 |
} |
|
202 |
||
| 72 | 203 |
function init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { |
204 |
|
|
205 |
$('.publishedproject', base_node).click(function(e) { |
|
206 |
e.preventDefault(); |
|
207 |
var target = $(e.target); |
|
208 |
var project_id = target.attr('id').replace('project_',''); |
|
209 |
var url = unpublishprojecturl.replace('__PROJECT_ID__', project_id); |
|
210 |
$.ajax({ |
|
211 |
url: url, |
|
212 |
type: 'POST', |
|
213 |
dataType: 'json', |
|
214 |
success: function(json, textStatus, XMLHttpRequest){ |
|
215 |
if(json.res) { |
|
216 |
searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
|
217 |
} |
|
218 |
} |
|
219 |
}); |
|
220 |
}); |
|
221 |
||
222 |
$('.unpublishedproject', base_node).click(function(e) { |
|
223 |
e.preventDefault(); |
|
224 |
var target = $(e.target); |
|
225 |
var project_id = target.attr('id').replace('project_',''); |
|
226 |
var url = publishprojecturl.replace('__PROJECT_ID__', project_id); |
|
227 |
$.ajax({ |
|
228 |
url: url, |
|
229 |
type: 'POST', |
|
230 |
dataType: 'json', |
|
231 |
success: function(json, textStatus, XMLHttpRequest){ |
|
232 |
if(json.res) { |
|
233 |
searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0); |
|
234 |
} |
|
235 |
} |
|
236 |
}); |
|
237 |
}); |
|
238 |
||
239 |
} |
|
240 |
||
241 |
function init_events_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { |
|
242 |
|
|
243 |
init_events_base(base_node, embed_url); |
|
244 |
init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl); |
|
245 |
} |
|
246 |
||
247 |
function init_events_all(base_node, embed_url, searchcontentfilterurl, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) { |
|
248 |
|
|
249 |
init_events_contents(base_node, embed_url, searchcontentfilterurl); |
|
250 |
init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl); |
|
251 |
} |
|
252 |
||
| 44 | 253 |
|
254 |
||
255 |
function searchFieldInit(input_list_init) { |
|
256 |
||
257 |
$(".searchfieldinputbase").keydown(function (e) { |
|
258 |
if(e.which == 27) { |
|
259 |
$(e.target).blur(); |
|
260 |
$(e.target).next(".searchajaxloader").hide(); |
|
261 |
} |
|
| 63 | 262 |
}); |
| 44 | 263 |
|
264 |
$('.searchfieldinput').each(function(i) { |
|
265 |
var sbox = $(this); |
|
266 |
if(sbox.val() != '') { |
|
267 |
sbox.attr('defaultText', sbox.val()); |
|
268 |
} |
|
269 |
|
|
270 |
sbox.focus(function() { |
|
271 |
box = $(this); |
|
272 |
if(box.val() == box.attr('defaultText')) { |
|
273 |
box.val(''); |
|
274 |
box.toggleClass("searchfieldinput"); |
|
275 |
} |
|
276 |
}); |
|
277 |
|
|
278 |
sbox.blur(function() { |
|
279 |
var box = $(this); |
|
280 |
if(box.val() == '' && box.attr('defaultText')) { |
|
281 |
box.val(box.attr('defaultText')); |
|
282 |
box.toggleClass("searchfieldinput"); |
|
283 |
} |
|
284 |
}); |
|
|
71
fc1210bbb854
correct translation +some bug on update
ymh <ymh.work@gmail.com>
parents:
67
diff
changeset
|
285 |
|
| 44 | 286 |
}); |
287 |
||
288 |
$.each(input_list_init, function(index, value) { |
|
289 |
$(value['input_selector']).keyup(function (e) { |
|
290 |
searchCallback(e.target, value['container_selector'], value['url']); |
|
291 |
}); |
|
292 |
}); |
|
| 63 | 293 |
|
294 |
$('.searchclear').click(function(e) { |
|
295 |
var box = $(e.target).parent().find("input"); |
|
296 |
box.val(box.attr('defaultText')); |
|
297 |
box.addClass("searchfieldinput"); |
|
298 |
box.blur(); |
|
299 |
box.keyup(); |
|
300 |
}); |
|
301 |
|
|
302 |
$('.searchclear').each(function(i) { |
|
303 |
$(this).hide(); |
|
304 |
}); |
|
| 44 | 305 |
|
306 |
} |