Revision 9569cdc8 snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/common.js
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/common.js | ||
---|---|---|
1 | 1 |
ui = {}; |
2 | 2 |
|
3 | 3 |
|
4 |
|
|
5 |
|
|
6 |
|
|
4 | 7 |
ui.closeDiv = function(closeEl, divToCloseClass) { |
5 | 8 |
closeEl.click(function(e){ |
6 | 9 |
e.preventDefault(); |
... | ... | |
9 | 12 |
} |
10 | 13 |
|
11 | 14 |
|
15 |
|
|
16 |
ui.trimChars = function( str, chars) { |
|
17 |
if ( str.length>chars){ |
|
18 |
return jQuery.trim(str).substring(0, chars).split(" ").slice(0, -1).join(" ") + "..."; |
|
19 |
} else { |
|
20 |
return str; |
|
21 |
} |
|
22 |
} |
|
23 |
|
|
12 | 24 |
// set lt-sidebar height |
13 | 25 |
ui.setSidebarHeight = function(){ |
14 | 26 |
var WindowHeight = $(window).height(); |
... | ... | |
205 | 217 |
resetForm(e, $('.editable a.cancel')); |
206 | 218 |
}); |
207 | 219 |
|
208 |
|
|
220 |
} |
|
221 |
|
|
222 |
ui.overlay = function() { |
|
223 |
$('[data-overlay-id]').click(function(e){ |
|
224 |
e.preventDefault(); |
|
225 |
var el = $(this); |
|
226 |
|
|
227 |
// main-actions a need to be active to trigger overlay |
|
228 |
if ( (el.parents('.main-actions').find('li a.active').length == 0) && (el.parents('.main-actions').length > 0) ) { |
|
229 |
return false; |
|
230 |
} |
|
231 |
var id = el.data('overlay-id'); |
|
232 |
$('.overlay-area').show(); |
|
233 |
$(id).slideDown('slow'); |
|
234 |
|
|
235 |
|
|
236 |
}); |
|
237 |
|
|
209 | 238 |
|
210 | 239 |
} |
211 | 240 |
|
212 | 241 |
|
242 |
|
|
213 | 243 |
$(document).ready(function(){ |
214 | 244 |
|
245 |
|
|
215 | 246 |
ui.closeDiv($('.info .close'), '.info'); |
216 | 247 |
ui.closeDiv($('.dummy-navigation .close'), '.dummy-navigation'); |
217 | 248 |
|
... | ... | |
238 | 269 |
|
239 | 270 |
ui.entitiesActionsInit(); |
240 | 271 |
ui.editable(); |
272 |
ui.overlay(); |
|
241 | 273 |
|
242 | 274 |
$('.main-actions li a').click(function(e){ |
243 | 275 |
if (!($(this).hasClass('active'))) { |
... | ... | |
246 | 278 |
}) |
247 | 279 |
$('.scroll-pane').jScrollPane(); |
248 | 280 |
|
249 |
// TODO: more general function |
|
250 |
$('.has-overlay a').click(function(e){ |
|
251 |
e.preventDefault(); |
|
252 |
if ($(this).hasClass('active')){ |
|
253 |
$('.content').append('<div class="overlay-modal overlay"><a href="" class="close" title="cancel vm creation">close</a></div>'); |
|
254 |
$($(this).parents('.has-overlay').data('overlay-id')).fadeIn('slow'); |
|
255 |
} |
|
256 |
}) |
|
257 | 281 |
|
258 | 282 |
|
283 |
|
|
284 |
|
|
285 |
$('.main .items-list .title em').each(function(){ |
|
286 |
$(this).html( ui.trimChars($(this).html(), 22) ); |
|
287 |
|
|
288 |
}) |
|
289 |
|
|
259 | 290 |
$('.main-actions li a').click(function(e){ |
260 | 291 |
if (!($(this).hasClass('active'))) { |
261 | 292 |
e.preventDefault(); |
262 | 293 |
} |
263 | 294 |
}) |
264 |
|
|
295 |
$('.overlay-area .close').click(function(e){ |
|
296 |
e.preventDefault(); |
|
297 |
$(this).parents('.overlay-area').hide(); |
|
298 |
$(this).parents('.overlay-area').find($('[data-overlay-id]')).hide(); |
|
299 |
}) |
|
265 | 300 |
|
266 | 301 |
}) |
267 | 302 |
|
303 |
|
|
268 | 304 |
$(window).resize(function(e){ |
269 | 305 |
ui.setSidebarHeight(); |
270 | 306 |
$('.scroll-pane').jScrollPane(); |
Also available in: Unified diff