Created
August 7, 2012 15:31
-
-
Save wemakeweb/3286427 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CORE.Scripts.register('/widget/weather/0.01/js/input.js', { | |
widget : { | |
resize : { | |
aspectRatio : true | |
} | |
}, | |
onresize : function(){ | |
}, | |
start : function(dialog){ | |
var self = this; | |
var frame_widget_id = $("#config-widget").attr("data-widgetId"); | |
var locationList = []; | |
$('input:text[name=city]').autocomplete({ | |
source : function(content, callback){ | |
$.ajax({ | |
url : '/folien/folie/widget/' + frame_widget_id + '?action=city_acomp', | |
type : 'post', | |
dataType : 'json', | |
data : { | |
search_string : $('#city').attr('value') | |
}, | |
success : function(response){ | |
if(response.data.result){ | |
self.suggestionList = response.data.suggestions | |
var nameList = []; | |
self.suggestionList.forEach(function(location){ | |
nameList.push(location.name); | |
}) | |
callback(nameList); | |
} | |
} | |
}); | |
}, | |
select : function(event, ui){ | |
var item = ui.item; | |
var breaker = false; | |
self.suggestionList.forEach(function(location){ | |
if(breaker === false && location.name == item.value){ | |
$('input:hidden[name=link]').attr('value', location.link); | |
breaker = true; | |
} | |
}); | |
} | |
}); | |
}, | |
stop : function(dialog){ | |
$('#city').unbind('keypress'); | |
$('form', dialog).unbind('click'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment